コード例 #1
0
def get_gt_data_paths(directory):
    """
    Parameters
    ----------
    directory: string
        parent directory with gt and data folder inside

    Returns
    -------
    paths: list of tuples

    """

    paths = []
    directory = os.path.expanduser(directory)

    path_imgs = os.path.join(directory, "data")
    path_gts = os.path.join(directory, "gt")

    if not (os.path.isdir(path_imgs) or os.path.isdir(path_gts)):
        logging.error("folder data or gt not found in " + str(directory))

    for img_name, gt_name in zip(sorted(os.listdir(path_imgs)),
                                 sorted(os.listdir(path_gts))):
        if has_extension(img_name, IMG_EXTENSIONS) and has_extension(
                gt_name, IMG_EXTENSIONS):
            paths.append(
                (os.path.join(path_imgs,
                              img_name), os.path.join(path_gts, gt_name)))

    return paths
コード例 #2
0
 def _get_filenames(self, path):
     file_names = []
     for item in get_all_files_in_folders_and_subfolders(path):
         if has_extension(
                 item,
             ['.jpg', '.jpeg', '.png', '.ppm', '.bmp', '.pgm', '.tif']):
             file_names.append(item)
     return file_names
def get_img_paths(path_imgs):
    if not os.path.isdir(path_imgs):
        print("Folder data or gt not found in " + path_imgs)

    images = []

    for _, _, fnames in sorted(os.walk(path_imgs)):
        for fname in sorted(fnames):
            if has_extension(fname, IMG_EXTENSIONS):
                path_img = os.path.join(path_imgs, fname)
                images.append(path_img)

    return images
コード例 #4
0
def get_list_images(dir):
    images = get_all_files_in_folders_and_subfolders(dir)
    images = [item for item in images if has_extension(item, IMG_EXTENSIONS)]
    return images