def __list_dirs(self, root_dir, dataset): img_list = list() json_list = list() image_dir = os.path.join(root_dir, dataset, 'image') json_dir = os.path.join(root_dir, dataset, 'json') for file_name in os.listdir(json_dir): image_name = '.'.join(file_name.split('.')[:-1]) img_path = ImageHelper.imgpath(image_dir, image_name) json_path = os.path.join(json_dir, file_name) if not os.path.exists(json_path) or img_path is None: Log.warn('Json Path: {} not exists.'.format(json_path)) continue json_list.append(json_path) img_list.append(img_path) if dataset == 'train' and self.configer.get('data', 'include_val'): image_dir = os.path.join(root_dir, 'val/image') json_dir = os.path.join(root_dir, 'val/json') for file_name in os.listdir(json_dir): image_name = '.'.join(file_name.split('.')[:-1]) img_path = ImageHelper.imgpath(image_dir, image_name) json_path = os.path.join(json_dir, file_name) if not os.path.exists(json_path) or img_path is None: Log.warn('Json Path: {} not exists.'.format(json_path)) continue json_list.append(json_path) img_list.append(img_path) return img_list, json_list
def __list_dirs(self, root_dir, dataset): imgA_list = list() imgB_list = list() imageA_dir = os.path.join(root_dir, dataset, 'imageA') imageB_dir = os.path.join(root_dir, dataset, 'imageB') for file_name in os.listdir(imageA_dir): image_name = '.'.join(file_name.split('.')[:-1]) imgA_path = ImageHelper.imgpath(imageA_dir, image_name) imgB_path = ImageHelper.imgpath(imageB_dir, image_name) if not os.path.exists(imgA_path) or not os.path.exists(imgB_path): Log.warn('Img Path: {} not exists.'.format(imgA_path)) continue imgA_list.append(imgA_path) imgB_list.append(imgB_path) if dataset == 'train' and self.configer.get('data', 'include_val'): imageA_dir = os.path.join(root_dir, 'val/imageA') imageB_dir = os.path.join(root_dir, 'val/imageB') for file_name in os.listdir(imageA_dir): image_name = '.'.join(file_name.split('.')[:-1]) imgA_path = ImageHelper.imgpath(imageA_dir, image_name) imgB_path = ImageHelper.imgpath(imageB_dir, image_name) if not os.path.exists(imgA_path) or not os.path.exists( imgB_path): Log.warn('Img Path: {} not exists.'.format(imgA_path)) continue imgA_list.append(imgA_path) imgB_list.append(imgB_path) return imgA_list, imgB_list
def __list_dirs(self, root_dir, dataset): img_list = list() label_list = list() image_dir = os.path.join(root_dir, dataset, 'image') label_dir = os.path.join(root_dir, dataset, 'label') def _inner_list_file(path): if ImageHelper.is_zip_path(path): return ZipReader.list_files(path) else: return os.listdir(path) def _inner_exist_file(path): if ImageHelper.is_zip_path(path): return ZipReader.exist_file(path) else: return os.path.exists(path) for file_name in _inner_list_file(label_dir): image_name = '.'.join(file_name.split('.')[:-1]) label_path = os.path.join(label_dir, file_name) img_path = ImageHelper.imgpath(image_dir, image_name) if not _inner_exist_file(label_path) or img_path is None: Log.warn('Label Path: {} not exists.'.format(label_path)) continue img_list.append(img_path) label_list.append(label_path) if dataset == 'train' and self.configer.get('data', 'include_val'): image_dir = os.path.join(root_dir, 'val/image') label_dir = os.path.join(root_dir, 'val/label') for file_name in _inner_list_file(dataset, label_dir): image_name = '.'.join(file_name.split('.')[:-1]) label_path = os.path.join(label_dir, file_name) img_path = ImageHelper.imgpath(image_dir, image_name) if not _inner_exist_file(label_path) or img_path is None: Log.warn('Label Path: {} not exists.'.format(label_path)) continue img_list.append(img_path) label_list.append(label_path) return img_list, label_list