def test_net(net, imdb, max_per_image=100, thresh=0.05, vis=False): """Test a Fast R-CNN network on an image database.""" if vis: from datasets.kitti import kitti kitti = kitti("valsplit") num_images = len(imdb.image_index) # all detections are collected into: # all_boxes[cls][image] = N x 5 array of detections in # (x1, y1, x2, y2, score, [cfg.VIEWP_BINS x viewpoint prob. dist]) all_boxes = [[[] for _ in xrange(num_images)] for _ in xrange(imdb.num_classes)] output_dir = get_output_dir(imdb, net) cache_file = os.path.join(output_dir, 'detections.pkl') times_vector_ = [] if os.path.exists(cache_file): with open(cache_file, 'rb') as fid: all_boxes = cPickle.load(fid) #print '{} gt roidb loaded from {}'.format(self.name, cache_file) print 'Detections cache loaded' warnings.warn( "PLEASE MAKE SURE THAT YOU REALLY WANT TO USE THE CACHE!", UserWarning) #return roidb else: # timers _t = {'im_detect': Timer(), 'misc': Timer()} if not cfg.TEST.HAS_RPN: roidb = imdb.roidb ndetections = 0 if cfg.SMOOTH_L1_ANGLE: viewp_bins = 1 elif cfg.CONTINUOUS_ANGLE: viewp_bins = 1 else: viewp_bins = cfg.VIEWP_BINS if cfg.SMOOTH_L1_ANGLE: allclasses_viewp_bins = imdb.num_classes elif cfg.CONTINUOUS_ANGLE: allclasses_viewp_bins = 1 else: allclasses_viewp_bins = imdb.num_classes * cfg.VIEWP_BINS for i, img_file in enumerate(imdb.image_index): if vis: detts = np.empty([0, 6]) # filter out any ground truth boxes if cfg.TEST.HAS_RPN: box_proposals = None else: # The roidb may contain ground-truth rois (for example, if the roidb # comes from the training or val split). We only want to evaluate # detection on the *non*-ground-truth rois. We select those the rois # that have the gt_classes field set to 0, which means there's no # ground truth. if cfg.TEST.GTPROPOSALS: box_proposals = roidb[i]['boxes'][ roidb[i]['gt_classes'] > -1] else: box_proposals = roidb[i]['boxes'][roidb[i]['gt_classes'] == 0] if box_proposals is not None and box_proposals.shape[0] <= 0: # if there are no proposals.... scores = np.empty((0, imdb.num_classes), dtype=np.float32) boxes = np.empty((0, imdb.num_classes * 4), dtype=np.float32) if cfg.VIEWPOINTS: assert cfg.CONTINUOUS_ANGLE == False and cfg.SMOOTH_L1_ANGLE == False, 'not implemented' viewpoints = np.empty((0, allclasses_viewp_bins), dtype=np.float32) else: if cfg.TEST.FOURCHANNELS: im = cv2.imread(imdb.image_path_at(i), cv2.IMREAD_UNCHANGED) else: im = cv2.imread(imdb.image_path_at(i)) _t['im_detect'].tic() if cfg.VIEWPOINTS: scores, boxes, viewpoints = im_detect( net, im, box_proposals) else: scores, boxes = im_detect(net, im, box_proposals) if i > 3: # CUDA warmup times_vector_.append( _t['im_detect'].toc(average=False)) _t['misc'].tic() # skip j = 0, because it's the background class for j in xrange(1, imdb.num_classes): inds = np.where(scores[:, j] > thresh)[0] ndetections += len(inds) cls_scores = scores[inds, j] cls_boxes = boxes[inds, j * 4:(j + 1) * 4] if cfg.VIEWPOINTS: if cfg.SMOOTH_L1_ANGLE: viewp = viewpoints[inds, j] cls_dets = np.hstack((cls_boxes, cls_scores[:, np.newaxis], viewp[:, np.newaxis])) \ .astype(np.float32, copy=False) elif cfg.CONTINUOUS_ANGLE: viewp = viewpoints[inds] cls_dets = np.hstack((cls_boxes, cls_scores[:, np.newaxis], viewp)) \ .astype(np.float32, copy=False) # TODO: cls_dets = np.hstack((cls_boxes, cls_scores[:, np.newaxis], viewp)) \ ? else: # Softmax is only performed over the class N_BINSx "slot" # (that is why we apply it outside Caffe) cls_viewp = softmax( viewpoints[inds, j * cfg.VIEWP_BINS:(j + 1) * cfg.VIEWP_BINS]) # Assert that the result from softmax makes sense assert (all(abs(np.sum(cls_viewp, axis=1) - 1) < 0.1)) cls_dets = np.hstack((cls_boxes, cls_scores[:, np.newaxis], cls_viewp)) \ .astype(np.float32, copy=False) else: cls_dets = np.hstack((cls_boxes, cls_scores[:, np.newaxis])) \ .astype(np.float32, copy=False) if cfg.TEST.DO_NMS: if cfg.USE_CUSTOM_NMS: if cfg.VIEWPOINTS: nms_returns = nms(cls_dets[:, :-viewp_bins], cfg.TEST.NMS, force_cpu=True) else: nms_returns = nms(cls_dets, cfg.TEST.NMS, force_cpu=True) if nms_returns: keep = nms_returns[0] suppress = nms_returns[1] else: keep = [] elif cfg.TEST.SOFT_NMS > 0: if cfg.VIEWPOINTS: keep = soft_nms(cls_dets[:, :-viewp_bins], method=cfg.TEST.SOFT_NMS) else: keep = soft_nms(cls_dets, method=cfg.TEST.SOFT_NMS) else: if cfg.VIEWPOINTS: keep = nms(cls_dets[:, :-viewp_bins], cfg.TEST.NMS) else: keep = nms(cls_dets, cfg.TEST.NMS) cls_dets = cls_dets[keep, :] else: if cfg.VIEWPOINTS: cls_dets = cls_dets[cls_dets[:, -viewp_bins - 1].argsort()[::-1], :] else: cls_dets = cls_dets[cls_dets[:, -1].argsort()[::-1], :] if vis: pre_detts = np.hstack( (np.array(cls_dets[:, :5]), j * np.ones( (np.array(cls_dets[:, :5]).shape[0], 1)))) detts = np.vstack((detts, pre_detts)) all_boxes[j][i] = cls_dets if vis: gt_roidb = kitti._load_kitti_annotation(img_file) vis_detections(im, imdb.classes, detts, gt_roidb) # Limit to max_per_image detections *over all classes* if max_per_image > 0: if cfg.VIEWPOINTS: image_scores = np.hstack([ all_boxes[j][i][:, -viewp_bins - 1] for j in xrange(1, imdb.num_classes) ]) else: image_scores = np.hstack([ all_boxes[j][i][:, -1] for j in xrange(1, imdb.num_classes) ]) if len(image_scores) > max_per_image: # We usually don't want to do this print "WARNING! Limiting the number of detections" image_thresh = np.sort(image_scores)[-max_per_image] for j in xrange(1, imdb.num_classes): if cfg.VIEWPOINTS: keep = np.where( all_boxes[j][i][:, -viewp_bins - 1] >= image_thresh)[0] else: keep = np.where( all_boxes[j][i][:, -1] >= image_thresh)[0] all_boxes[j][i] = all_boxes[j][i][keep, :] _t['misc'].toc() print 'im_detect: {:d}/{:d} - {:d} detections - {:.3f}s {:.3f}s' \ .format(i + 1, num_images, ndetections,_t['im_detect'].average_time, _t['misc'].average_time) det_file = os.path.join(output_dir, 'detections.pkl') with open(det_file, 'wb') as f: cPickle.dump(all_boxes, f, cPickle.HIGHEST_PROTOCOL) print 'Evaluating detections' imdb.evaluate_detections(all_boxes, output_dir) np.array(times_vector_) print 'Times:' print 'mean: {:.3f}s'.format(np.mean(times_vector_)) print 'std: {:.3f}s'.format(np.std(times_vector_)) print 'quartiles: {:.3f}s / {:.3f}s / {:.3f}s'.format( np.percentile(times_vector_, 25), np.percentile(times_vector_, 50), np.percentile(times_vector_, 75)) print 'max: {:.3f}s / min: {:.3f}s'.format(np.max(times_vector_), np.min(times_vector_))
name = '{}_{}'.format('letters', split) __sets[name] = ( lambda split=split: container_letters(split, letters_devkit_path)) #train container digits digits_devkit_path = 'data/containerdigits' for split in ['train', 'test']: name = '{}_{}'.format('digits', split) __sets[name] = ( lambda split=split: container_digits(split, digits_devkit_path)) #kitti kitti_devkit_path = 'data/kitti' for split in ['trainval', 'test']: name = '{}_{}'.format('kitti', split) __sets[name] = (lambda split=split: kitti(split, kitti_devkit_path)) #train container digits ROI regions roi_devkit_path = 'data/ROIRegions' for split in ['train', 'test']: name = '{}_{}'.format('roi', split) __sets[name] = (lambda split=split: roi_regions(split, roi_devkit_path)) # # Set up voc_<year>_<split> using selective search "fast" mode # for year in ['2007', '2012']: # for split in ['train', 'val', 'trainval', 'test']: # name = 'voc_{}_{}'.format(year, split) # __sets[name] = (lambda split=split, year=year: pascal_voc(split, year)) # # # Set up coco_2014_<split> # for year in ['2014']:
def evaluate_detections(self, all_boxes, output_dir): self._write_kitti_results_file(all_boxes) self._do_python_eval(output_dir) if self.config['matlab_eval']: self._do_matlab_eval(output_dir) if self.config['cleanup']: for cls in self._classes: if cls == '__background__': continue filename = self._get_kitti_results_file_template().format(cls) os.remove(filename) def competition_mode(self, on): if on: self.config['use_salt'] = False self.config['cleanup'] = False else: self.config['use_salt'] = True self.config['cleanup'] = True if __name__ == '__main__': from datasets.kitti import kitti d = kitti('trainval') res = d.roidb from IPython import embed embed()
for year in ['2012']: for split in ['taste', 'all', 'test', 'train']: name = 'sun_{}_{}'.format(year, split) __sets[name] = (lambda split=split, year=year: sun(split, year)) # Set up caltech_2009_<split> for year in ['2009']: for split in ['val', 'train', 'test', 'all', 'taste', 'medium']: name = 'caltech_{}_{}'.format(year, split) __sets[name] = (lambda split=split, year=year: caltech(split, year)) # Set up kitti_2013_<split> # TODO for year in ['2013']: for split in ['val', 'train', 'test', 'all']: name = 'kitti_{}_{}'.format(year, split) __sets[name] = (lambda split=split, year=year: kitti(split, year)) # Set up inria_2005_<split> # TODO for year in ['2005']: for split in ['val', 'train', 'test', 'all']: name = 'inria_{}_{}'.format(year, split) __sets[name] = (lambda split=split, year=year: inria(split, year)) def get_imdb(name): """Get an imdb (image database) by name.""" if not __sets.has_key(name): raise KeyError('Unknown dataset: {}'.format(name)) return __sets[name]()
ret = np.empty((count, ), dtype=np.float32) ret.fill(fill) ret[inds] = data else: ret = np.empty((count, ) + data.shape[1:], dtype=np.float32) ret.fill(fill) ret[inds, :] = data return ret if __name__ == '__main__': cfg_from_file('experiments/cfgs/faster_rcnn_end2end_kitti.yml') # Load dataset from datasets.kitti import kitti imdb = kitti('train', '2012') roidb = imdb.roidb im_scale = float(576) / float(375) # Load anchors from rpn.generate_anchors import generate_anchors anchors = generate_anchors(scales=np.array(range(1,10)), ratios=[0.5, 1., 1.5, 2., 2.5, 3.]) anchors = anchors * im_scale num_anchors = anchors.shape[0] #height, width = (375, 1242) height, width = (int(375*im_scale/16), int(1242*im_scale/16)) feat_stride = 16
# Written by Ross Girshick # -------------------------------------------------------- """Factory method for easily getting imdbs by name.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function __sets = {} from datasets.kitti import kitti import numpy as np # # KITTI dataset for split in ['train', 'val', 'trainval', 'test']: name = 'kitti_{}'.format(split) # print name data_path = './data/kitti/object' __sets[name] = (lambda split=split: kitti(split, data_path)) def get_imdb(name): """Get an imdb (image database) by name.""" if name not in __sets: raise KeyError('Unknown dataset: {}'.format(name)) return __sets[name]() def list_imdbs(): """List all registered imdbs.""" return list(__sets.keys())
from datasets.sim10k_cycle import sim10k_cycle from datasets.cityscape import cityscape from datasets.cityscape_car import cityscape_car from datasets.foggy_cityscape import foggy_cityscape from datasets.kitti import kitti import numpy as np import os for split in ['train', 'trainval','val','test','detection_train']: for data_percentage in ['', '_1_00', '_1_01', '_1_02', '_10_samples', '_10_samples_2', '_10_samples_3']: name = 'cityscapes{}_{}'.format(data_percentage, split) __sets[name] = (lambda split=split, data_percentage=data_percentage : cityscape("cityscapes_" + split, devkit_path="datasets/voc_cityscapes{}".format(data_percentage))) for split in ['train', 'trainval','val','test']: name = 'kitti_{}'.format(split) __sets[name] = (lambda split=split : kitti("kitti_" + split, devkit_path="datasets/voc_kitti")) for split in ['train', 'trainval','val','test']: name = 'cityscape_car_{}'.format(split) __sets[name] = (lambda split=split : cityscape_car(split)) for split in ['train', 'trainval','test']: for data_percentage in ['', '_1_00', '_1_01', '_1_02', '_10_samples', '_10_samples_2', '_10_samples_3']: name = 'foggy_cityscapes{}_{}'.format(data_percentage, split) __sets[name] = (lambda split=split, data_percentage=data_percentage : foggy_cityscape("foggy_" + split, devkit_path="datasets/voc_cityscapes2foggy{}".format(data_percentage))) for split in ['train', 'trainval','test']: for data_percentage in ['', '_1_00', '_1_01', '_1_02', '_10_samples', '_10_samples_2', '_10_samples_3']: name = 'kitti{}_{}'.format(data_percentage, split) __sets[name] = (lambda split=split, data_percentage=data_percentage : kitti("kitti_" + split, devkit_path="datasets/voc_kitti{}".format(data_percentage))) for split in ['train','val']: name = 'sim10k_{}'.format(split) __sets[name] = (lambda split=split : sim10k(split)) for split in ['train', 'val']:
anchors = np.hstack((-1 * wh_centers / 2., wh_centers / 2.)) return anchors if __name__ == '__main__': cfg_from_file( os.path.join(cfg.ROOT_DIR, 'experiments', 'cfgs', 'faster_rcnn_end2end_kitti_ZF.yml')) # cfg_from_file('../../experiments/cfgs/faster_rcnn_end2end_kitti_vgg16.yml') # cfg_from_file('../../experiments/cfgs/faster_rcnn_end2end_kitti_alexnet.yml') from datasets.kitti import kitti # imdb = kitti('train', '2012') imdb = kitti('trainval', '2012') # Apply data augmentation imdb.append_flipped_images() # imdb.append_crop_resize_images() # imdb.append_photometric_transformed_images() roidb = imdb.roidb plt.ion() num_anchors = 20 # anchors_person = gen_anchors(imdb.roidb, 10, [1]) # anchors_cyclist = gen_anchors(imdb.roidb, 10, [2]) # anchors_car = gen_anchors(imdb.roidb, 60, [3])
def evaluate_detections(self, all_boxes, output_dir): # for each image for im_idx, index in enumerate(self.image_index): filename = os.path.join(output_dir, index + '.txt') print 'Writing KITTI {:s} results to file {:s}'.format(self._image_set, filename) with open(filename, 'wt') as f: # for each class for cls_idx, cls in enumerate(self.classes): if cls == '__background__': continue dets = all_boxes[cls_idx][im_idx] if dets == []: continue for k in xrange(dets.shape[0]): f.write('{:s} -1 -1 -10 {:f} {:f} {:f} {:f} -1 -1 -1 -1 -1 -1 -1 {:.32f}\n'.format(\ cls, dets[k, 0], dets[k, 1], dets[k, 2], dets[k, 3], dets[k, 4])) def competition_mode(self, on): if on: self.config['use_salt'] = False self.config['cleanup'] = False else: self.config['use_salt'] = True self.config['cleanup'] = True if __name__ == '__main__': from datasets.kitti import kitti d = kitti('train') res = d.roidb from IPython import embed; embed()
for split in ['train', 'val', 'trainval', 'test']: name = 'voc_{}_{}'.format(year, split) __sets[name] = (lambda split=split, year=year: pascal_voc(split, year)) # Set up coco_2014_<split> for year in ['2014']: for split in ['train', 'val', 'minival', 'valminusminival']: name = 'coco_{}_{}'.format(year, split) __sets[name] = (lambda split=split, year=year: coco(split, year)) # Set up coco_2015_<split> for year in ['2015']: for split in ['test', 'test-dev']: name = 'coco_{}_{}'.format(year, split) __sets[name] = (lambda split=split, year=year: coco(split, year)) for split in ['train', 'test']: name = 'kitti_{}'.format(split) __sets[name] = (lambda split=split: kitti(split)) def get_imdb(name): """Get an imdb (image database) by name.""" if not __sets.has_key(name): raise KeyError('Unknown dataset: {}'.format(name)) return __sets[name]() def list_imdbs(): """List all registered imdbs.""" return __sets.keys()
print('Running:\n{}'.format(cmd)) status = subprocess.call(cmd, shell=True) def evaluate_detections(self, all_boxes, output_dir): self._write_voc_results_file(all_boxes) self._do_python_eval(output_dir) if self.config['matlab_eval']: self._do_matlab_eval(output_dir) if self.config['cleanup']: for cls in self._classes: if cls == '__background__': continue filename = self._get_voc_results_file_template().format(cls) os.remove(filename) def competition_mode(self, on): if on: self.config['use_salt'] = False self.config['cleanup'] = False else: self.config['use_salt'] = True self.config['cleanup'] = True if __name__ == '__main__': from datasets.kitti import kitti d = kitti('trainval', '2007') res = d.roidb from IPython import embed embed()
tgt_name = 'city_multi_{}_tgt'.format(split) __sets[tgt_name] = ( lambda split=split, num_shot=num_shot: city_multi(split, num_shot)) # set up foggy cityscapes <split> for split in ['train', 'val']: name = 'fog_city_{}'.format(split) __sets[name] = (lambda split=split: fog_city(split)) tgt_name = 'fog_city_{}_tgt'.format(split) __sets[tgt_name] = ( lambda split=split, num_shot=num_shot: fog_city(split, num_shot)) # set up kitti <split> for split in ['train', 'val']: name = 'kitti_{}'.format(split) __sets[name] = (lambda split=split: kitti(split)) tgt_name = 'kitti_{}_tgt'.format(split) __sets[tgt_name] = ( lambda split=split, num_shot=num_shot: kitti(split, num_shot)) def get_imdb(name): """Get an imdb (image database) by name.""" if name not in __sets: raise KeyError('Unknown dataset: {}'.format(name)) return __sets[name]() def list_imdbs(): """List all registered imdbs."""
def _selective_search_IJCV_top_k(split, year, top_k): """Return an imdb that uses the top k proposals from the selective search IJCV code. """ imdb = datasets.pascal_voc(split, year) imdb.roidb_handler = imdb.selective_search_IJCV_roidb imdb.config['top_k'] = top_k return imdb # Set up voc_<year>_<split> using selective search "fast" mode # for split in ['train', 'val', 'val1', 'val2', 'test']: for split in ['train_kitti']: name = '{}'.format(split) devkit_path = 'data/kitti-object' __sets[name] = (lambda split=split, devkit_path = devkit_path: kitti(split,devkit_path)) print name print __sets[name] ''' # Set up voc_<year>_<split>_top_<k> using selective search "quality" mode # but only returning the first k boxes for top_k in np.arange(1000, 11000, 1000): for year in ['2007', '2012']: for split in ['train', 'val', 'trainval', 'test']: name = 'voc_{}_{}_top_{:d}'.format(year, split, top_k) __sets[name] = (lambda split=split, year=year, top_k=top_k:_selective_search_IJCV_top_k(split, year, top_k)) ''' def get_imdb(name): """Get an imdb (image database) by name."""
"""Return an imdb that uses the top k proposals from the selective search IJCV code. """ imdb = datasets.pascal_voc(split, year) imdb.roidb_handler = imdb.selective_search_IJCV_roidb imdb.config['top_k'] = top_k return imdb # Set up voc_<year>_<split> using selective search "fast" mode # for split in ['train', 'val', 'val1', 'val2', 'test']: for split in ['train_kitti']: name = '{}'.format(split) devkit_path = 'data/kitti-object' __sets[name] = ( lambda split=split, devkit_path=devkit_path: kitti(split, devkit_path)) print name print __sets[name] ''' # Set up voc_<year>_<split>_top_<k> using selective search "quality" mode # but only returning the first k boxes for top_k in np.arange(1000, 11000, 1000): for year in ['2007', '2012']: for split in ['train', 'val', 'trainval', 'test']: name = 'voc_{}_{}_top_{:d}'.format(year, split, top_k) __sets[name] = (lambda split=split, year=year, top_k=top_k:_selective_search_IJCV_top_k(split, year, top_k)) ''' def get_imdb(name): """Get an imdb (image database) by name."""
# Set up coco_2014_cap_<split> for year in ['2014']: for split in ['train', 'val', 'capval', 'valminuscapval', 'trainval']: name = 'coco_{}_{}'.format(year, split) __sets[name] = (lambda split=split, year=year: coco(split, year)) # Set up coco_2015_<split> for year in ['2015']: for split in ['test', 'test-dev']: name = 'coco_{}_{}'.format(year, split) __sets[name] = (lambda split=split, year=year: coco(split, year)) for split in ['train', 'val', 'test']: name = 'kitti_{}'.format(split) __sets[name] = (lambda split=split: kitti(split)) # Set up vg_<split> # for version in ['1600-400-20']: # for split in ['minitrain', 'train', 'minival', 'val', 'test']: # name = 'vg_{}_{}'.format(version,split) # __sets[name] = (lambda split=split, version=version: vg(version, split)) for version in ['150-50-20', '150-50-50', '500-150-80', '750-250-150', '1750-700-450', '1600-400-20']: for split in ['minitrain', 'smalltrain', 'train', 'minival', 'smallval', 'val', 'test']: name = 'vg_{}_{}'.format(version,split) __sets[name] = (lambda split=split, version=version: vg(version, split)) # set up image net. for split in ['train', 'val', 'val1', 'val2', 'test']: name = 'imagenet_{}'.format(split) devkit_path = 'data/imagenet/ILSVRC/devkit'
n = 0 for j in range(len(all_boxes[i])): n += len(all_boxes[i][j]) print("{}: {}".format(i, n)) self._do_python_eval(output_dir) if self.config['matlab_eval']: self._do_matlab_eval(output_dir) if self.config['cleanup']: for cls in self._classes: if cls == '__background__': continue filename = self._get_kitti_results_file_template().format(cls) os.remove(filename) def competition_mode(self, on): if on: self.config['use_salt'] = False self.config['cleanup'] = False else: self.config['use_salt'] = True self.config['cleanup'] = True if __name__ == '__main__': from datasets.kitti import kitti d = kitti('all', '2012') res = d.roidb from IPython import embed embed()
__sets[name] = (lambda split=split, year=year: pascal_voc(split, year)) # Set up coco_2014_<split> for year in ['2014']: for split in ['train', 'val', 'minival', 'valminusminival', 'trainval']: name = 'coco_{}_{}'.format(year, split) __sets[name] = (lambda split=split, year=year: coco(split, year)) # Set up coco_2015_<split> for year in ['2015']: for split in ['test', 'test-dev']: name = 'coco_{}_{}'.format(year, split) __sets[name] = (lambda split=split, year=year: coco(split, year)) new_name = 'kitti' __sets[new_name] = (lambda split=False: kitti(split)) new_name = 'tunnel' __sets[new_name] = (lambda split=False: tunnel(split)) new_name = 'horizontal' __sets[new_name] = (lambda split=False: horizontal(split)) new_name = 'damage' __sets[new_name] = (lambda split=False: damage(split)) new_name = 'vertical' __sets[new_name] = (lambda split=False: vertical(split)) def get_imdb(name):
def __init__(self, image_set, year, devkit_path=None, shuffled=None): imdb.__init__(self, 'merged_' + image_set) self._year = year self._image_set = image_set self._anno_set_dir = image_set if "val" in image_set: self._image_set_dir = "val" if "val1" in image_set: self._anno_set_dir = "val1" if "val2" in image_set: self._anno_set_dir = "val2" elif "train" in image_set: self._anno_set_dir = "train" elif "test" in image_set: self._anno_set_dir = "test" if image_set == "train": self.imdbs = [imagenet(image_set),\ coco(image_set, '2015'),\ cam2(image_set,'2017'),\ sun(image_set,'2012'),\ caltech(image_set,'2009'),\ kitti(image_set,'2013'),\ inria(image_set,'2005'),\ pascal_voc(image_set,'2007'),\ pascal_voc(image_set,'2012')] elif image_set == "test": self.imdbs = [imagenet('val'),\ coco('test-dev', '2015'),\ cam2('all','2017'),\ sun('test','2012'),\ caltech('test','2009'),\ kitti('val','2013'),\ inria('all','2005'),\ pascal_voc('test','2007')] self.roidbs = [None for _ in range(len(self.datasets))] for idx,imdb in enumerate(self.imdbs): self.roidbs[idx] = get_training_roidb(imdb) 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 'voc', 'imagenet', 'caltech', 'coco', 'sun', 'kitti', 'inria', 'cam2') self._class_to_ind = dict(zip(self.classes, xrange(self.num_classes))) self._image_ext = '.jpg' self._image_index = self._load_image_set_index() # Default to roidb handler self._roidb_handler = self.selective_search_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, 'min_size' : 2} 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)