def selective_search_IJCV_roidb(self): """ Return the database of selective search regions of interest. Ground-truth ROIs are also included. This function loads/saves from/to a cache file to speed up future calls. """ cache_file = os.path.join( self.cache_path, '{:s}_selective_search_IJCV_top_{:d}_roidb.pkl'.format( self.name, self.config['top_k'])) if os.path.exists(cache_file): with open(cache_file, 'rb') as fid: roidb = cPickle.load(fid) print('{} ss roidb loaded from {}'.format(self.name, cache_file)) return roidb gt_roidb = self.gt_roidb() ss_roidb = self._load_selective_search_IJCV_roidb(gt_roidb) roidb = imdb.merge_roidbs(gt_roidb, ss_roidb) with open(cache_file, 'wb') as fid: cPickle.dump(roidb, fid, cPickle.HIGHEST_PROTOCOL) print('wrote ss roidb to {}'.format(cache_file)) return roidb
def selective_search_roidb(self): """ Return the database of selective search regions of interest. Ground-truth ROIs are also included. This function loads/saves from/to a cache file to speed up future calls. """ cache_file = os.path.join(self.cache_path, self.name + '_selective_search_roidb.pkl') if os.path.exists(cache_file): with open(cache_file, 'rb') as fid: roidb = cPickle.load(fid) print '{} ss roidb loaded from {}'.format(self.name, cache_file) return roidb if int(self._year) == 2007 or self._image_set != 'test': gt_roidb = self.gt_roidb() ss_roidb = self._load_selective_search_roidb(gt_roidb) roidb = imdb.merge_roidbs(gt_roidb, ss_roidb) else: roidb = self._load_selective_search_roidb(None) with open(cache_file, 'wb') as fid: cPickle.dump(roidb, fid, cPickle.HIGHEST_PROTOCOL) print 'wrote ss roidb to {}'.format(cache_file) return roidb
def _roidb_from_proposals(self, method): """ Creates a roidb from pre-computed proposals of a particular methods. """ top_k = self.config['top_k'] cache_file = osp.join(self.cache_path, self.name + '_{:s}_top{:d}'.format(method, top_k) + '_roidb.pkl') if osp.exists(cache_file): with open(cache_file, 'rb') as fid: roidb = pickle.load(fid) print('{:s} {:s} roidb loaded from {:s}'.format(self.name, method, cache_file)) return roidb if self._image_set in self._gt_splits: gt_roidb = self.gt_roidb() method_roidb = self._load_proposals(method, gt_roidb) roidb = imdb.merge_roidbs(gt_roidb, method_roidb) # Make sure we don't use proposals that are contained in crowds roidb = _filter_crowd_proposals(roidb, self.config['crowd_thresh']) else: roidb = self._load_proposals(method, None) with open(cache_file, 'wb') as fid: pickle.dump(roidb, fid, pickle.HIGHEST_PROTOCOL) print('wrote {:s} roidb to {:s}'.format(method, cache_file)) return roidb
def rpn_roidb(self): gt_roidb = self.gt_roidb() rpn_roidb = self._load_rpn_roidb(gt_roidb) roidb = imdb.merge_roidbs(gt_roidb, rpn_roidb) return roidb
def rpn_roidb(self): if int(self._year) == 2007 or self._image_set != 'test': gt_roidb = self.gt_roidb() rpn_roidb = self._load_rpn_roidb(gt_roidb) roidb = imdb.merge_roidbs(gt_roidb, rpn_roidb) else: roidb = self._load_rpn_roidb(None) return roidb
def region_proposal_roidb(self): """ Return the database of regions of interest. Ground-truth ROIs are also included. This function loads/saves from/to a cache file to speed up future calls. """ cache_file = os.path.join( self.cache_path, self.name + '_' + cfg.SUBCLS_NAME + '_' + cfg.REGION_PROPOSAL + '_region_proposal_roidb.pkl') if os.path.exists(cache_file): with open(cache_file, 'rb') as fid: roidb = cPickle.load(fid) print('{} roidb loaded from {}'.format(self.name, cache_file)) return roidb if self._image_set != 'test': gt_roidb = self.gt_roidb() print('Loading region proposal network boxes...') model = cfg.REGION_PROPOSAL rpn_roidb = self._load_rpn_roidb(gt_roidb, model) print('Region proposal network boxes loaded') roidb = imdb.merge_roidbs(rpn_roidb, gt_roidb) else: print('Loading region proposal network boxes...') model = cfg.REGION_PROPOSAL roidb = self._load_rpn_roidb(None, model) print('Region proposal network boxes loaded') print('{} region proposals per image'.format(self._num_boxes_proposal / len(self.image_index))) with open(cache_file, 'wb') as fid: cPickle.dump(roidb, fid, cPickle.HIGHEST_PROTOCOL) print('wrote roidb to {}'.format(cache_file)) return roidb
def selective_search_roidb(self): """ Return the database of selective search regions of interest. Ground-truth ROIs are also included. This function loads/saves from/to a cache file to speed up future calls. """ cache_file = os.path.join(self.cache_path, self.name + '_selective_search_roidb.pkl') if os.path.exists(cache_file): with open(cache_file, 'rb') as fid: roidb = cPickle.load(fid) print '{} ss roidb loaded from {}'.format(self.name, cache_file) return roidb if int(self._year) == 2007 or not self._image_set.startswith('test'): gt_roidb = self.gt_roidb() ss_roidb = self._load_selective_search_roidb(gt_roidb) roidb = imdb.merge_roidbs(gt_roidb, ss_roidb) else: roidb = self._load_selective_search_roidb(None) # Keep max of e.g. 2000 rois if type(self._maxNrRois) == int: print "Only keep the first %d ROIs..." % self._maxNrRois for i in xrange(self.num_images): gt_overlaps = roidb[i]['gt_overlaps'] gt_overlaps = gt_overlaps.todense()[:self._maxNrRois] gt_overlaps = scipy.sparse.csr_matrix(gt_overlaps) roidb[i]['boxes'] = roidb[i]['boxes'][:self._maxNrRois, :] roidb[i]['gt_classes'] = roidb[i]['gt_classes'][:self._maxNrRois] roidb[i]['gt_overlaps'] = roidb[i]['gt_overlaps'] = gt_overlaps with open(cache_file, 'wb') as fid: cPickle.dump(roidb, fid, cPickle.HIGHEST_PROTOCOL) print 'wrote ss roidb to {}'.format(cache_file) return roidb
def region_proposal_roidb(self): """ Return the database of regions of interest. Ground-truth ROIs are also included. This function loads/saves from/to a cache file to speed up future calls. """ cache_file = os.path.join( self.cache_path, self.name + '_' + cfg.SUBCLS_NAME + '_' + cfg.REGION_PROPOSAL + '_region_proposal_roidb.pkl') if os.path.exists(cache_file): with open(cache_file, 'rb') as fid: roidb = pickle.load(fid) print('{} roidb loaded from {}'.format(self.name, cache_file)) return roidb if self._image_set != 'test': gt_roidb = self.gt_roidb() print('Loading region proposal network boxes...') if self._image_set == 'trainval': model = cfg.REGION_PROPOSAL + '_227/' else: model = cfg.REGION_PROPOSAL + '_125/' rpn_roidb = self._load_rpn_roidb(gt_roidb, model) print('Region proposal network boxes loaded') roidb = imdb.merge_roidbs(rpn_roidb, gt_roidb) # print 'Loading voxel pattern boxes...' # if self._image_set == 'trainval': # model = '3DVP_227' # else: # model = '3DVP_125/' # vp_roidb = self._load_voxel_pattern_roidb(gt_roidb, model) # print 'Voxel pattern boxes loaded' # roidb = imdb.merge_roidbs(vp_roidb, gt_roidb) # print 'Loading selective search boxes...' # ss_roidb = self._load_selective_search_roidb(gt_roidb) # print 'Selective search boxes loaded' # print 'Loading ACF boxes...' # acf_roidb = self._load_acf_roidb(gt_roidb) # print 'ACF boxes loaded' # roidb = imdb.merge_roidbs(ss_roidb, gt_roidb) # roidb = imdb.merge_roidbs(roidb, acf_roidb) else: print('Loading region proposal network boxes...') model = cfg.REGION_PROPOSAL + '_227/' roidb = self._load_rpn_roidb(None, model) print('Region proposal network boxes loaded') # print 'Loading voxel pattern boxes...' # model = '3DVP_227/' # roidb = self._load_voxel_pattern_roidb(None, model) # print 'Voxel pattern boxes loaded' # print 'Loading selective search boxes...' # roidb = self._load_selective_search_roidb(None) # print 'Selective search boxes loaded' # print 'Loading ACF boxes...' # acf_roidb = self._load_acf_roidb(None) # print 'ACF boxes loaded' # roidb = imdb.merge_roidbs(roidb, acf_roidb) print('{} region proposals per image'.format(self._num_boxes_proposal / len(self.image_index))) with open(cache_file, 'wb') as fid: pickle.dump(roidb, fid, pickle.HIGHEST_PROTOCOL) print('wrote roidb to {}'.format(cache_file)) return roidb