def __init__(self, name): assert name in DATASETS.keys(), \ 'Unknown dataset name: {}'.format(name) assert os.path.exists(DATASETS[name][IM_DIR]), \ 'Image directory \'{}\' not found'.format(DATASETS[name][IM_DIR]) assert os.path.exists(DATASETS[name][ANN_FN]), \ 'Annotation file \'{}\' not found'.format(DATASETS[name][ANN_FN]) logger.debug('Creating: {}'.format(name)) self.name = name self.image_directory = DATASETS[name][IM_DIR] self.image_prefix = ( '' if IM_PREFIX not in DATASETS[name] else DATASETS[name][IM_PREFIX] ) self.COCO = COCO(DATASETS[name][ANN_FN]) self.debug_timer = Timer() # Set up dataset classes category_ids = self.COCO.getCatIds() categories = [c['name'] for c in self.COCO.loadCats(category_ids)] self.category_to_id_map = dict(zip(categories, category_ids)) self.classes = ['__background__'] + categories self.num_classes = len(self.classes) self.json_category_id_to_contiguous_id = { v: i + 1 for i, v in enumerate(self.COCO.getCatIds()) } self.contiguous_category_id_to_json_id = { v: k for k, v in self.json_category_id_to_contiguous_id.items() } self._init_keypoints()
def __init__(self, name): assert name in DATASETS.keys(), \ 'Unknown dataset name: {}'.format(name) assert os.path.exists(DATASETS[name][IM_DIR]), \ 'Image directory \'{}\' not found'.format(DATASETS[name][IM_DIR]) assert os.path.exists(DATASETS[name][ANN_FN]), \ 'Annotation file \'{}\' not found'.format(DATASETS[name][ANN_FN]) logger.debug('Creating: {}'.format(name)) self.name = name self.image_directory = DATASETS[name][IM_DIR] self.image_prefix = ('' if IM_PREFIX not in DATASETS[name] else DATASETS[name][IM_PREFIX]) self.COCO = COCO(DATASETS[name][ANN_FN]) self.debug_timer = Timer() # Set up dataset classes category_ids = self.COCO.getCatIds() categories = [c['name'] for c in self.COCO.loadCats(category_ids)] self.category_to_id_map = dict(zip(categories, category_ids)) self.classes = ['__background__'] + categories self.num_classes = len(self.classes) self.json_category_id_to_contiguous_id = { v: i + 1 for i, v in enumerate(self.COCO.getCatIds()) } self.contiguous_category_id_to_json_id = { v: k for k, v in self.json_category_id_to_contiguous_id.items() } self._init_keypoints()
def __init__(self, name): assert name in DATASETS.keys(), \ 'Unknown dataset name: {}'.format(name) assert os.path.exists(DATASETS[name][IM_DIR]), \ 'Image directory \'{}\' not found'.format(DATASETS[name][IM_DIR]) assert os.path.exists(DATASETS[name][ANN_FN]), \ 'Annotation file \'{}\' not found'.format(DATASETS[name][ANN_FN]) logger.debug('Creating: {}'.format(name)) self.name = name self.image_directory = DATASETS[name][IM_DIR] self.image_prefix = ('' if IM_PREFIX not in DATASETS[name] else DATASETS[name][IM_PREFIX]) self.image_list = self.load_image_list(DATASETS[name][ANN_FN]) self.debug_timer = Timer() # Set up dataset classes #category_ids = self.COCO.getCatIds() #categories = [c['name'] for c in self.COCO.loadCats(category_ids)] #self.category_to_id_map = dict(zip(categories, category_ids)) #self.classes = ['__background__'] + categories """self.num_classes = len(self.classes)