def register_all_coco(root="datasets"): for key, (image_root, json_file) in _PREDEFINED_SPLITS_NUCLEI.items(): # Assume pre-defined datasets live in `./datasets`. register_coco_instances( key, metadata_nuc, os.path.join(root, json_file) if "://" not in json_file else json_file, os.path.join(root, image_root), ) for key, (image_root, json_file) in _PREDEFINED_SPLITS_PIC.items(): # Assume pre-defined datasets live in `./datasets`. register_coco_instances( key, metadata_pic, os.path.join(root, json_file) if "://" not in json_file else json_file, os.path.join(root, image_root), ) for key, (image_root, json_file) in _PREDEFINED_SPLITS_TEXT.items(): # Assume pre-defined datasets live in `./datasets`. register_text_instances( key, metadata_text, os.path.join(root, json_file) if "://" not in json_file else json_file, os.path.join(root, image_root), )
def register_coco_person(root): for key, (image_root, json_file) in _COCO_PERSON_INSTANCES.items(): register_coco_instances( key, _get_coco_instances_person_only_meta(), os.path.join(root, json_file) if "://" not in json_file else json_file, os.path.join(root, image_root), )
def register_all_df2(root="datasets"): for key, (image_root, json_file) in _DEEPFASHION2_SPLITS.items(): register_coco_instances( key, metadata=df2_55_metadata if "55" in json_file else df2_metadata, json_file=os.path.join(root, json_file) if "://" not in json_file else json_file, image_root=os.path.join(root, image_root), )
def register_all_food(root="datasets"): for dataset_name, splits_per_dataset in _PREDEFINED_SPLITS_FOOD.items(): for key, (image_root, json_file) in splits_per_dataset.items(): # Assume pre-defined datasets live in `./datasets`. register_coco_instances( key, {}, os.path.join(root, json_file), os.path.join(root, image_root), )
def register_all_voc_sbd(root): for key, (image_root, json_file) in _PREDEFINED_SPLITS_VOC_SBD.items(): # Assume pre-defined datasets live in `./datasets`. register_coco_instances( key, _get_builtin_metadata(key), os.path.join(root, json_file) if "://" not in json_file else json_file, os.path.join(root, image_root), )
def register_all_coco(root="datasets"): for key, (image_root, json_file) in _PREDEFINED_SPLITS_PIC.items(): # Assume pre-defined datasets live in `./datasets`. register_coco_instances( key, {"thing_classes": ["person"]}, os.path.join(root, json_file) if "://" not in json_file else json_file, os.path.join(root, image_root), )
def register_hie(root): for key, (image_root, json_file) in _HIE_DATASETS.items(): # Assume pre-defined datasets live in `./datasets`. register_coco_instances( key, _get_hie_metadata(), # _get_builtin_metadata("coco"), os.path.join(root, json_file) if "://" not in json_file else json_file, os.path.join(root, image_root), )
def register_all_web(root): for dataset_name, splits_per_dataset in _PREDEFINED_SPLITS_WEB.items(): for key, (image_root, json_file) in splits_per_dataset.items(): # Assume pre-defined datasets live in `./datasets`. register_coco_instances( key, _get_builtin_metadata(key), os.path.join(root, json_file) if "://" not in json_file else json_file, os.path.join(root, image_root), )
def register_all_coco(root="datasets"): for key, (image_root, json_file) in _PREDEFINED_SPLITS_SBD.items(): # Assume pre-defined datasets live in `./datasets`. register_coco_instances( key, metadata, os.path.join(root, json_file) if "://" not in json_file else json_file, os.path.join(root, image_root), )
def register_cocodev(root="datasets"): for dataset_name, splits_per_dataset in COCODEV.items(): for key, (image_root, json_file) in splits_per_dataset.items(): # Assume pre-defined datasets live in `./datasets`. register_coco_instances( key, _get_builtin_metadata(dataset_name), os.path.join(root, json_file) if "://" not in json_file else json_file, os.path.join(root, image_root), )
def _register_coco_2017_if_not_present(self, ): if 'coco_2017_train_copy' not in DatasetCatalog.keys(): register_coco_instances( 'coco_2017_train_copy', _get_builtin_metadata('coco'), "/scratch/ssd001/home/skhandel/FewshotDetection/WSASOD/data/data_utils/data/MSCOCO2017/annotations/instances_train2017.json", "/scratch/ssd001/home/skhandel/FewshotDetection/WSASOD/data/data_utils/data/MSCOCO2017/images/train2017/" ) if 'coco_2017_val_copy' not in DatasetCatalog.keys(): register_coco_instances( 'coco_2017_val_copy', _get_builtin_metadata('coco'), "/scratch/ssd001/home/skhandel/FewshotDetection/WSASOD/data/data_utils/data/MSCOCO2017/annotations/instances_val2017.json", "/scratch/ssd001/home/skhandel/FewshotDetection/WSASOD/data/data_utils/data/MSCOCO2017/images/val2017/" )
def _get_builtin_metadata(): thing_dataset_id_to_contiguous_id = { x['id']: i for i, x in enumerate(sorted(categories, key=lambda x: x['id'])) } thing_classes = [ x['name'] for x in sorted(categories, key=lambda x: x['id']) ] return { "thing_dataset_id_to_contiguous_id": thing_dataset_id_to_contiguous_id, "thing_classes": thing_classes } _PREDEFINED_SPLITS_ = { "kitti_train": ("kitti/data_semantics/training/image_2/", "kitti/train.json"), "kitti_test": ("kitti/data_semantics/testing/image_2/", "kitti/kitti_test.json"), } for key, (image_root, json_file) in _PREDEFINED_SPLITS_.items(): register_coco_instances( key, _get_builtin_metadata(), os.path.join("datasets", json_file) if "://" not in json_file else json_file, os.path.join("datasets", image_root), )
year, keepclasses, sid, ) MetadataCatalog.get(name).evaluator_type = "pascal_voc" # Register them all under "./datasets" register_all_coco() register_all_lvis() register_all_pascal_voc() from detectron2.data.datasets import register_coco_instances json_dir = 'datasets/coco_experiments/seed1/full_box_30shot_person_train.json' image_dir = 'datasets/coco/trainval2014' register_coco_instances("30shot_person_train", {}, json_dir, image_dir) json_dir = 'datasets/coco_experiments/seed1/full_box_30shot_bicycle_train.json' image_dir = 'datasets/coco/trainval2014' register_coco_instances("30shot_bicycle_train", {}, json_dir, image_dir) json_dir = 'datasets/coco_experiments/seed1/full_box_30shot_horse_train.json' image_dir = 'datasets/coco/trainval2014' register_coco_instances("30shot_horse_train", {}, json_dir, image_dir) json_dir = 'datasets/coco_experiments/seed1/full_box_30shot_airplane_train.json' image_dir = 'datasets/coco/trainval2014' register_coco_instances("30shot_airplane_train", {}, json_dir, image_dir) json_dir = 'datasets/coco_experiments/seed1/full_box_500shot_person_train.json' image_dir = 'datasets/coco/trainval2014'
def register_all_coco(root="datasets"): register_coco_instances("davis_train", {}, TRAIN_JSON_PATH, TRAIN_IMG_DIR) register_coco_instances("davis_val", {}, VAL_JSON_PATH, VAL_IMG_DIR)