예제 #1
0
    def __init__(self):
        task_paths = sly.DtlPaths()
        self.in_dir = task_paths.data_dir
        self.out_dir = task_paths.results_dir
        self.settings = sly.json_load(task_paths.settings_path)

        self.classes = set()
        self.tags = set()
예제 #2
0
 def __init__(self):
     task_paths = sly.DtlPaths()
     self.in_dir = task_paths.data_dir
     self.out_dir = task_paths.results_dir
     self.settings = sly.json_load(task_paths.settings_path)
     self.colors_file = osp.join(self.in_dir, 'colors.json')
     self._read_colors()
     self._read_datasets()
예제 #3
0
    def __init__(self):
        task_paths = sly.DtlPaths()
        self.in_dir = task_paths.data_dir
        self.out_dir = task_paths.results_dir
        self.settings = sly.json_load(task_paths.settings_path)

        if len(task_paths.project_dirs) > 1:
            raise RuntimeError('The project should consist of only one folder.')

        self.dataset_dir = task_paths.project_dirs[0]
        self._define_classes()
예제 #4
0
    def __init__(self):
        task_paths = sly.DtlPaths()
        self.in_dir = task_paths.data_dir
        self.out_dir = task_paths.results_dir
        self.settings = sly.json_load(task_paths.settings_path)

        if len(task_paths.project_dirs) != 1:
            raise RuntimeError(
                'Invalid data format. Input folder should contain only "images_and_annotations" dir'
            )
        self.data_dir = join(self.in_dir, 'images_and_annotations')
예제 #5
0
    def __init__(self):
        task_paths = sly.DtlPaths()
        self.in_dir = task_paths.data_dir
        self.out_dir = task_paths.results_dir
        self.settings = sly.json_load(task_paths.settings_path)

        if not os.path.exists(join(self.in_dir, 'img')) or not os.path.exists(
            (join(self.in_dir, 'ann'))):
            raise RuntimeError(
                'Invalid data format. Input folder should contain "img" and "ann" dirs'
            )
        self.img_dir = join(self.in_dir, 'img')
        self.ann_dir = join(self.in_dir, 'ann')
예제 #6
0
    results_counter = 0
    for pr_name, pr_dir in helper.in_project_dirs.items():
        root_path, project_name = sly.ProjectFS.split_dir_project(pr_dir)
        project_fs = sly.ProjectFS.from_disk(root_path, project_name, by_annotations=True)
        progress = sly.progress_counter_dtl(pr_name, project_fs.image_cnt)
        for sample in project_fs:
            try:
                img_desc = sly.ImageDescriptor(sample)
                ann = sly.json_load(sample.ann_path)
                data_el = (img_desc, ann)
                export_output_generator = net.start(data_el)
                for res_export in export_output_generator:
                    logger.trace("image processed", extra={'img_name': res_export[0][0].get_img_name()})
                    results_counter += 1
            except Exception:
                ex = {
                    'project_name': sample.project_name,
                    'ds_name': sample.ds_name,
                    'image_name': sample.image_name
                }
                logger.warn('Image was skipped because some error occured', exc_info=True, extra=ex)
            progress.iter_done_report()

    logger.info('DTL finished', extra={'event_type': EventType.DTL_APPLIED, 'new_proj_size': results_counter})


if __name__ == '__main__':
    if os.getenv('DEBUG_LOG_TO_FILE', None):
        sly.add_default_logging_into_file(logger, sly.DtlPaths().debug_dir)
    sly.main_wrapper('DTL', main)