def __init__(self, image_set, devkit_path, data_path): imdb.__init__(self, image_set) self._image_set = image_set self._devkit_path = devkit_path self._data_path = data_path synsets_image = sio.loadmat( os.path.join(self._devkit_path, 'data', 'meta_det.mat')) synsets_video = sio.loadmat( os.path.join(self._devkit_path, 'data', 'meta_vid.mat')) self._classes_image = ('__background__', ) self._wnid_image = (0, ) self._classes = ('__background__', ) self._wnid = (0, ) for i in xrange(200): self._classes_image = self._classes_image + ( synsets_image['synsets'][0][i][2][0], ) self._wnid_image = self._wnid_image + ( synsets_image['synsets'][0][i][1][0], ) for i in xrange(30): self._classes = self._classes + ( synsets_video['synsets'][0][i][2][0], ) self._wnid = self._wnid + (synsets_video['synsets'][0][i][1][0], ) self._wnid_to_ind_image = dict(zip(self._wnid_image, xrange(201))) self._class_to_ind_image = dict(zip(self._classes_image, xrange(201))) self._wnid_to_ind = dict(zip(self._wnid, xrange(31))) self._class_to_ind = dict(zip(self._classes, xrange(31))) #check for valid intersection between video and image classes self._valid_image_flag = [0] * 201 for i in range(1, 201): if self._wnid_image[i] in self._wnid_to_ind: self._valid_image_flag[i] = 1 self._image_ext = ['.JPEG'] self._image_index = self._load_image_set_index() # Default to roidb handler self._roidb_handler = self.gt_roidb # Specific config options self.config = {'cleanup': True, 'use_salt': True, 'top_k': 2000} assert os.path.exists( self._devkit_path), 'Devkit path does not exist: {}'.format( self._devkit_path) assert os.path.exists( self._data_path), 'Path does not exist: {}'.format(self._data_path)
def __init__(self, image_set, year, devkit_path=None): imdb.__init__(self, 'voc_' + year + '_' + image_set) self._year = year self._image_set = image_set self._devkit_path = self._get_default_path() if devkit_path is None \ else devkit_path self._data_path = os.path.join(self._devkit_path, 'VOC' + self._year) self._classes = ( '__background__', # always index 0 'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor') self._class_to_ind = dict( list(zip(self.classes, list(range(self.num_classes))))) self._image_ext = '.jpg' self._image_index = self._load_image_set_index() # Default to roidb handler self._roidb_handler = self.gt_roidb self._salt = str(uuid.uuid4()) self._comp_id = 'comp4' # PASCAL specific config options self.config = { 'cleanup': True, 'use_salt': True, 'use_diff': False, 'matlab_eval': False, 'rpn_file': None } assert os.path.exists(self._devkit_path), \ 'VOCdevkit path does not exist: {}'.format(self._devkit_path) assert os.path.exists(self._data_path), \ 'Path does not exist: {}'.format(self._data_path)
def __init__(self, image_set, year): imdb.__init__(self, 'coco_' + year + '_' + image_set) # COCO specific config options self.config = {'use_salt': True, 'cleanup': True} # name, paths self._year = year self._image_set = image_set self._data_path = osp.join(cfg.DATA_DIR, 'coco') # load COCO API, classes, class <-> id mappings self._COCO = COCO(self._get_ann_file()) cats = self._COCO.loadCats(self._COCO.getCatIds()) self._classes = tuple(['__background__'] + [c['name'] for c in cats]) self._class_to_ind = dict(list(zip(self.classes, list(range(self.num_classes))))) self._class_to_coco_cat_id = dict(list(zip([c['name'] for c in cats], self._COCO.getCatIds()))) self._image_index = self._load_image_set_index() # Default to roidb handler self.set_proposal_method('gt') self.competition_mode(False) # Some image sets are "views" (i.e. subsets) into others. # For example, minival2014 is a random 5000 image subset of val2014. # This mapping tells us where the view's images and proposals come from. self._view_map = { 'minival2014': 'val2014', # 5k val2014 subset 'valminusminival2014': 'val2014', # val2014 \setminus minival2014 'test-dev2015': 'test2015', 'valminuscapval2014': 'val2014', 'capval2014': 'val2014', 'captest2014': 'val2014' } coco_name = image_set + year # e.g., "val2014" self._data_name = (self._view_map[coco_name] if coco_name in self._view_map else coco_name) # Dataset splits that have ground-truth annotations (test splits # do not have gt annotations) self._gt_splits = ('train', 'val', 'minival')
def __init__(self, version, image_set, xml_path): imdb.__init__(self, 'vg_' + version + '_' + image_set) self._version = version self.xml_path = xml_path self._image_set = image_set self._data_path = os.path.join(cfg.DATA_DIR, 'genome') self._img_path = os.path.join(cfg.DATA_DIR, 'vg') # VG specific config options self.config = {'cleanup' : False} # Load classes self._classes = ['__background__'] self._class_to_ind = {} self._class_to_ind[self._classes[0]] = 0 with open(os.path.join(self._data_path, self._version, 'objects_vocab.txt')) as f: count = 1 for object in f.readlines(): names = [n.lower().strip() for n in object.split(',')] self._classes.append(names[0]) for n in names: self._class_to_ind[n] = count count += 1 # Load attributes self._attributes = ['__no_attribute__'] self._attribute_to_ind = {} self._attribute_to_ind[self._attributes[0]] = 0 with open(os.path.join(self._data_path, self._version, 'attributes_vocab.txt')) as f: count = 1 for att in f.readlines(): names = [n.lower().strip() for n in att.split(',')] self._attributes.append(names[0]) for n in names: self._attribute_to_ind[n] = count count += 1 # Load relations self._relations = ['__no_relation__'] self._relation_to_ind = {} self._relation_to_ind[self._relations[0]] = 0 with open(os.path.join(self._data_path, self._version, 'relations_vocab.txt')) as f: count = 1 for rel in f.readlines(): names = [n.lower().strip() for n in rel.split(',')] self._relations.append(names[0]) for n in names: self._relation_to_ind[n] = count count += 1 self._image_ext = '.jpg' load_index_from_file = False if os.path.exists(os.path.join(self._data_path, "vg_image_index_{}.p".format(self._image_set))): with open(os.path.join(self._data_path, "vg_image_index_{}.p".format(self._image_set)), 'rb') as fp: self._image_index = pickle.load(fp) load_index_from_file = True load_id_from_file = False if os.path.exists(os.path.join(self._data_path, "vg_id_to_dir_{}.p".format(self._image_set))): with open(os.path.join(self._data_path, "vg_id_to_dir_{}.p".format(self._image_set)), 'rb') as fp: self._id_to_dir = pickle.load(fp) load_id_from_file = True if not load_index_from_file or not load_id_from_file: self._image_index, self._id_to_dir = self._load_image_set_index() with open(os.path.join(self._data_path, "vg_image_index_{}.p".format(self._image_set)), 'wb') as fp: pickle.dump(self._image_index, fp) with open(os.path.join(self._data_path, "vg_id_to_dir_{}.p".format(self._image_set)), 'wb') as fp: pickle.dump(self._id_to_dir, fp) self._roidb_handler = self.gt_roidb