desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'Setup the GtDataLayer.'
def setup(self, bottom, top):
layer_params = yaml.load(self.param_str_) self._num_classes = layer_params['num_classes'] self._name_to_top_map = {'data': 0, 'info_boxes': 1, 'parameters': 2} num_scale_base = len(cfg.TRAIN.SCALES_BASE) top[0].reshape(num_scale_base, 3, 100, 100) top[1].reshape(1, 18) num_scale = len(cfg.TR...
'Get blobs and copy them into this layer\'s top blob vector.'
def forward(self, bottom, top):
blobs = self._get_next_minibatch() for (blob_name, blob) in blobs.iteritems(): top_ind = self._name_to_top_map[blob_name] top[top_ind].reshape(*blob.shape) top[top_ind].data[...] = blob.astype(np.float32, copy=False)
'This layer does not propagate gradients.'
def backward(self, top, propagate_down, bottom):
pass
'Reshaping happens during the call to forward.'
def reshape(self, bottom, top):
pass
'Return the absolute path to image i in the image sequence.'
def image_path_at(self, i):
return self.image_path_from_index(self.image_index[i])
'Construct an image path from the image\'s "index" identifier.'
def image_path_from_index(self, index):
prefix = self._image_set image_path = os.path.join(self._data_path, prefix, (index + self._image_ext)) assert os.path.exists(image_path), 'Path does not exist: {}'.format(image_path) return image_path
'Load the indexes listed in this dataset\'s image set file.'
def _load_image_set_index(self):
image_set_file = os.path.join(self._data_path, (self._image_set + '.txt')) assert os.path.exists(image_set_file), 'Path does not exist: {}'.format(image_set_file) with open(image_set_file) as f: image_index = [x.rstrip('\n') for x in f.readlines()] return image_index
'Return the default path where NISSAN is expected to be installed.'
def _get_default_path(self):
return os.path.join(datasets.ROOT_DIR, 'data', 'NISSAN')
'Return the database of ground-truth regions of interest. No implementation.'
def gt_roidb(self):
gt_roidb = [] return gt_roidb
'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.'
def region_proposal_roidb(self):
cache_file = os.path.join(self.cache_path, (((self.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...
'all_boxes is a list of length number-of-classes. Each list element is a list of length number-of-images. Each of those list elements is either an empty list [] or a numpy array of detection. all_boxes[class][image] = [] or np.array of shape #dets x 5'
def evaluate_detections(self, all_boxes, output_dir=None):
raise NotImplementedError
'Evaluate detection proposal recall metrics. Returns: results: dictionary of results with keys \'ar\': average recall \'recalls\': vector recalls at each IoU overlap threshold \'thresholds\': vector of IoU overlap thresholds \'gt_overlaps\': vector of all ground-truth overlaps'
def evaluate_recall(self, candidate_boxes=None, thresholds=None, area='all', limit=None):
areas = {'all': 0, 'small': 1, 'medium': 2, 'large': 3, '96-128': 4, '128-256': 5, '256-512': 6, '512-inf': 7} area_ranges = [[(0 ** 2), (100000.0 ** 2)], [(0 ** 2), (32 ** 2)], [(32 ** 2), (96 ** 2)], [(96 ** 2), (100000.0 ** 2)], [(96 ** 2), (128 ** 2)], [(128 ** 2), (256 ** 2)], [(256 ** 2), (512 ** 2)], [(5...
'Turn competition mode on or off.'
def competition_mode(self, on):
pass
'Return the absolute path to image i in the image sequence.'
def image_path_at(self, i):
return self.image_path_from_index(self.image_index[i])
'Construct an image path from the image\'s "index" identifier.'
def image_path_from_index(self, index):
prefix = self._image_set image_path = os.path.join(self._data_path, prefix, (index + self._image_ext)) assert os.path.exists(image_path), 'Path does not exist: {}'.format(image_path) return image_path
'Load the indexes listed in this dataset\'s image set file.'
def _load_image_set_index(self):
image_set_file = os.path.join(self._data_path, (self._image_set + '.txt')) assert os.path.exists(image_set_file), 'Path does not exist: {}'.format(image_set_file) with open(image_set_file) as f: image_index = [x.rstrip('\n') for x in f.readlines()] return image_index
'Return the default path where nthu is expected to be installed.'
def _get_default_path(self):
return os.path.join(datasets.ROOT_DIR, 'data', 'NTHU')
'Return the database of ground-truth regions of interest. No implementation.'
def gt_roidb(self):
gt_roidb = [] return gt_roidb
'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.'
def region_proposal_roidb(self):
cache_file = os.path.join(self.cache_path, (((self.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 the absolute path to image i in the image sequence.'
def image_path_at(self, i):
return self.image_path_from_index(self._image_index[i])
'Construct an image path from the image\'s "index" identifier.'
def image_path_from_index(self, index):
image_path = os.path.join(self._data_path, 'JPEGImages', (index + self._image_ext)) assert os.path.exists(image_path), 'Path does not exist: {}'.format(image_path) return image_path
'Load the indexes listed in this dataset\'s image set file.'
def _load_image_set_index(self):
image_set_file = os.path.join(self._data_path, 'ImageSets', 'Main', (self._image_set + '.txt')) assert os.path.exists(image_set_file), 'Path does not exist: {}'.format(image_set_file) with open(image_set_file) as f: image_index = [x.strip() for x in f.readlines()] return image_index
'Return the default path where PASCAL VOC is expected to be installed.'
def _get_default_path(self):
return os.path.join(cfg.DATA_DIR, ('VOCdevkit' + self._year))
'Return the database of ground-truth regions of interest. This function loads/saves from/to a cache file to speed up future calls.'
def gt_roidb(self):
cache_file = os.path.join(self.cache_path, (self.name + '_gt_roidb.pkl')) if os.path.exists(cache_file): with open(cache_file, 'rb') as fid: roidb = cPickle.load(fid) print '{} gt roidb loaded from {}'.format(self.name, cache_file) return roidb gt_roidb = [...
'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.'
def selective_search_roidb(self):
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 ...
'Load image and bounding boxes info from XML file in the PASCAL VOC format.'
def _load_pascal_annotation(self, index):
filename = os.path.join(self._data_path, 'Annotations', (index + '.xml')) tree = ET.parse(filename) objs = tree.findall('object') if (not self.config['use_diff']): non_diff_objs = [obj for obj in objs if (int(obj.find('difficult').text) == 0)] objs = non_diff_objs num_objs = len(objs...
'Return the absolute path to image i in the image sequence.'
def image_path_at(self, i):
return self.image_path_from_index(self._image_index[i])
'Construct an image path from the image\'s "index" identifier.'
def image_path_from_index(self, index):
image_path = os.path.join(self._data_path, 'JPEGImages', (index + self._image_ext)) assert os.path.exists(image_path), 'Path does not exist: {}'.format(image_path) return image_path
'Load the indexes listed in this dataset\'s image set file.'
def _load_image_set_index(self):
image_set_file = os.path.join(self._data_path, 'ImageSets', 'Main', (self._image_set + '.txt')) assert os.path.exists(image_set_file), 'Path does not exist: {}'.format(image_set_file) with open(image_set_file) as f: image_index = [x.strip() for x in f.readlines()] return image_index
'Return the default path where PASCAL VOC is expected to be installed.'
def _get_default_path(self):
return os.path.join(datasets.ROOT_DIR, 'data', 'PASCAL')
'Return the database of ground-truth regions of interest. This function loads/saves from/to a cache file to speed up future calls.'
def gt_roidb(self):
cache_file = os.path.join(self.cache_path, (self.name + '_gt_roidb.pkl')) if os.path.exists(cache_file): with open(cache_file, 'rb') as fid: roidb = cPickle.load(fid) print '{} gt roidb loaded from {}'.format(self.name, cache_file) return roidb gt_roidb = [...
'Load image and bounding boxes info from XML file in the PASCAL VOC format.'
def _load_pascal_annotation(self, index):
filename = os.path.join(self._data_path, 'Annotations', (index + '.xml')) def get_data_from_tag(node, tag): return node.getElementsByTagName(tag)[0].childNodes[0].data with open(filename) as f: data = minidom.parseString(f.read()) objs = data.getElementsByTagName('object') num_objs =...
'Load image and bounding boxes info from txt file in the pascal subcategory exemplar format.'
def _load_pascal_subcategory_exemplar_annotation(self, index):
if (self._image_set == 'test'): return self._load_pascal_annotation(index) filename = os.path.join(self._pascal_path, 'subcategory_exemplars', (index + '.txt')) assert os.path.exists(filename), 'Path does not exist: {}'.format(filename) lines = [] lines_flipped = [] with open...
'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.'
def region_proposal_roidb(self):
cache_file = os.path.join(self.cache_path, (((self.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 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.'
def selective_search_roidb(self):
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 ...
'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.'
def selective_search_IJCV_roidb(self):
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(se...
'Load image ids.'
def _load_image_set_index(self):
image_ids = self._COCO.getImgIds() return image_ids
'Return the absolute path to image i in the image sequence.'
def image_path_at(self, i):
return self.image_path_from_index(self._image_index[i])
'Construct an image path from the image\'s "index" identifier.'
def image_path_from_index(self, index):
file_name = (((('COCO_' + self._data_name) + '_') + str(index).zfill(12)) + '.jpg') image_path = osp.join(self._data_path, 'images', self._data_name, file_name) assert osp.exists(image_path), 'Path does not exist: {}'.format(image_path) return image_path
'Creates a roidb from pre-computed proposals of a particular methods.'
def _roidb_from_proposals(self, method):
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 = cPickle.load(fid) print '{:s} {:s} roidb loaded from {:s...
'Load pre-computed proposals in the format provided by Jan Hosang: http://www.mpi-inf.mpg.de/departments/computer-vision-and-multimodal- computing/research/object-recognition-and-scene-understanding/how- good-are-detection-proposals-really/ For MCG, use boxes from http://www.eecs.berkeley.edu/Research/Projects/ CS/visi...
def _load_proposals(self, method, gt_roidb):
box_list = [] top_k = self.config['top_k'] valid_methods = ['MCG', 'selective_search', 'edge_boxes_AR', 'edge_boxes_70'] assert (method in valid_methods) print 'Loading {} boxes'.format(method) for (i, index) in enumerate(self._image_index): if ((i % 1000) == 0): print ...
'Return the database of ground-truth regions of interest. This function loads/saves from/to a cache file to speed up future calls.'
def gt_roidb(self):
cache_file = osp.join(self.cache_path, (self.name + '_gt_roidb.pkl')) if osp.exists(cache_file): with open(cache_file, 'rb') as fid: roidb = cPickle.load(fid) print '{} gt roidb loaded from {}'.format(self.name, cache_file) return roidb gt_roidb = [self._lo...
'Loads COCO bounding-box instance annotations. Crowd instances are handled by marking their overlaps (with all categories) to -1. This overlap value means that crowd "instances" are excluded from training.'
def _load_coco_annotation(self, index):
im_ann = self._COCO.loadImgs(index)[0] width = im_ann['width'] height = im_ann['height'] annIds = self._COCO.getAnnIds(imgIds=index, iscrowd=None) objs = self._COCO.loadAnns(annIds) valid_objs = [] for obj in objs: x1 = np.max((0, obj['bbox'][0])) y1 = np.max((0, obj['bbox'][...
'Return the absolute path to image i in the image sequence.'
def image_path_at(self, i):
return self.image_path_from_index(self.image_index[i])
'Construct an image path from the image\'s "index" identifier.'
def image_path_from_index(self, index):
image_path = os.path.join(self._data_path, (index + self._image_ext)) assert os.path.exists(image_path), 'Path does not exist: {}'.format(image_path) return image_path
'Load the indexes listed in this dataset\'s image set file.'
def _load_image_set_index(self):
image_set_file = os.path.join(self._imagenet3d_path, 'Image_sets', (self._image_set + '.txt')) assert os.path.exists(image_set_file), 'Path does not exist: {}'.format(image_set_file) with open(image_set_file) as f: image_index = [x.rstrip('\n') for x in f.readlines()] return image_in...
'Return the default path where imagenet3d is expected to be installed.'
def _get_default_path(self):
return os.path.join(datasets.ROOT_DIR, 'data', 'ImageNet3D')
'Return the database of ground-truth regions of interest. This function loads/saves from/to a cache file to speed up future calls.'
def gt_roidb(self):
cache_file = os.path.join(self.cache_path, (((self.name + '_') + cfg.SUBCLS_NAME) + '_gt_roidb.pkl')) if os.path.exists(cache_file): with open(cache_file, 'rb') as fid: roidb = cPickle.load(fid) print '{} gt roidb loaded from {}'.format(self.name, cache_file) r...
'Load image and bounding boxes info from txt file in the imagenet3d format.'
def _load_imagenet3d_annotation(self, index):
if ((self._image_set == 'test') or (self._image_set == 'test_1') or (self._image_set == 'test_2')): lines = [] else: filename = os.path.join(self._imagenet3d_path, 'Labels', (index + '.txt')) lines = [] with open(filename) as f: for line in f: lines.ap...
'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.'
def region_proposal_roidb(self):
cache_file = os.path.join(self.cache_path, (((self.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 the absolute path to image i in the image sequence.'
def image_path_at(self, i):
return self.image_path_from_index(self.image_index[i])
'Construct an image path from the image\'s "index" identifier.'
def image_path_from_index(self, index):
if (self._image_set == 'test'): prefix = 'testing/image_2' else: prefix = 'training/image_2' image_path = os.path.join(self._data_path, prefix, (index + self._image_ext)) assert os.path.exists(image_path), 'Path does not exist: {}'.format(image_path) return image_path
'Load the indexes listed in this dataset\'s image set file.'
def _load_image_set_index(self):
image_set_file = os.path.join(self._kitti_path, (self._image_set + '.txt')) assert os.path.exists(image_set_file), 'Path does not exist: {}'.format(image_set_file) with open(image_set_file) as f: image_index = [x.rstrip('\n') for x in f.readlines()] return image_index
'Return the default path where KITTI is expected to be installed.'
def _get_default_path(self):
return os.path.join(datasets.ROOT_DIR, 'data', 'KITTI')
'Return the database of ground-truth regions of interest. This function loads/saves from/to a cache file to speed up future calls.'
def gt_roidb(self):
cache_file = os.path.join(self.cache_path, (((self.name + '_') + cfg.SUBCLS_NAME) + '_gt_roidb.pkl')) if os.path.exists(cache_file): with open(cache_file, 'rb') as fid: roidb = cPickle.load(fid) print '{} gt roidb loaded from {}'.format(self.name, cache_file) r...
'Load image and bounding boxes info from txt file in the KITTI format.'
def _load_kitti_annotation(self, index):
if (self._image_set == 'test'): lines = [] else: filename = os.path.join(self._data_path, 'training', 'label_2', (index + '.txt')) lines = [] with open(filename) as f: for line in f: line = line.replace('Van', 'Car') words = line.split(...
'Load image and bounding boxes info from txt file in the KITTI voxel exemplar format.'
def _load_kitti_voxel_exemplar_annotation(self, index):
if (self._image_set == 'train'): prefix = 'validation' elif (self._image_set == 'trainval'): prefix = 'test' else: return self._load_kitti_annotation(index) filename = os.path.join(self._kitti_path, cfg.SUBCLS_NAME, prefix, (index + '.txt')) assert os.path.exists(filename), '...
'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.'
def region_proposal_roidb(self):
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 {}'....
'Return the absolute path to image i in the image sequence.'
def image_path_at(self, i):
return self.image_path_from_index(self._image_index[i])
'Construct an image path from the image\'s "index" identifier.'
def image_path_from_index(self, index):
image_path = os.path.join(self._data_path, 'JPEGImages', (index + self._image_ext)) assert os.path.exists(image_path), 'Path does not exist: {}'.format(image_path) return image_path
'Load the indexes listed in this dataset\'s image set file.'
def _load_image_set_index(self):
image_set_file = os.path.join(self._data_path, 'ImageSets', 'Main', (self._image_set + '.txt')) assert os.path.exists(image_set_file), 'Path does not exist: {}'.format(image_set_file) with open(image_set_file) as f: image_index = [x.strip() for x in f.readlines()] return image_index
'Return the default path where PASCAL3D is expected to be installed.'
def _get_default_path(self):
return os.path.join(datasets.ROOT_DIR, 'data', 'PASCAL3D')
'Return the database of ground-truth regions of interest. This function loads/saves from/to a cache file to speed up future calls.'
def gt_roidb(self):
cache_file = os.path.join(self.cache_path, (((self.name + '_') + cfg.SUBCLS_NAME) + '_gt_roidb.pkl')) if os.path.exists(cache_file): with open(cache_file, 'rb') as fid: roidb = cPickle.load(fid) print '{} gt roidb loaded from {}'.format(self.name, cache_file) r...
'Load image and bounding boxes info from XML file in the PASCAL VOC format.'
def _load_pascal_annotation(self, index):
filename = os.path.join(self._data_path, 'Annotations', (index + '.xml')) def get_data_from_tag(node, tag): return node.getElementsByTagName(tag)[0].childNodes[0].data with open(filename) as f: data = minidom.parseString(f.read()) objs = data.getElementsByTagName('object') num_objs =...
'Load image and bounding boxes info from txt file in the pascal subcategory exemplar format.'
def _load_pascal3d_voxel_exemplar_annotation(self, index):
if (self._image_set == 'val'): return self._load_pascal_annotation(index) filename = os.path.join(self._pascal3d_path, cfg.SUBCLS_NAME, (index + '.txt')) assert os.path.exists(filename), 'Path does not exist: {}'.format(filename) lines = [] lines_flipped = [] with open(filena...
'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.'
def region_proposal_roidb(self):
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 {}'....
'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.'
def selective_search_roidb(self):
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 ...
'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.'
def selective_search_IJCV_roidb(self):
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(se...
'Return the absolute path to image i in the image sequence.'
def image_path_at(self, i):
return self.image_path_from_index(self.image_index[i])
'Construct an image path from the image\'s "index" identifier.'
def image_path_from_index(self, index):
image_path = os.path.join(self._data_path, (index + self._image_ext)) assert os.path.exists(image_path), 'Path does not exist: {}'.format(image_path) return image_path
'Load the indexes listed in this dataset\'s image set file.'
def _load_image_set_index(self):
kitti_train_nums = [154, 447, 233, 144, 314, 297, 270, 800, 390, 803, 294, 373, 78, 340, 106, 376, 209, 145, 339, 1059, 837] kitti_test_nums = [465, 147, 243, 257, 421, 809, 114, 215, 165, 349, 1176, 774, 694, 152, 850, 701, 510, 305, 180, 404, 173, 203, 436, 430, 316, 176, 170, 85, 175] if ((self._seq_name...
'Return the default path where kitti_tracking is expected to be installed.'
def _get_default_path(self):
return os.path.join(datasets.ROOT_DIR, 'data', 'KITTI_Tracking')
'Return the database of ground-truth regions of interest.'
def gt_roidb(self):
cache_file = os.path.join(self.cache_path, (((self.name + '_') + cfg.SUBCLS_NAME) + '_gt_roidb.pkl')) if os.path.exists(cache_file): with open(cache_file, 'rb') as fid: roidb = cPickle.load(fid) print '{} gt roidb loaded from {}'.format(self.name, cache_file) r...
'Load image and bounding boxes info from txt file in the KITTI voxel exemplar format.'
def _load_kitti_voxel_exemplar_annotation(self, index):
if ((self._image_set == 'training') and (self._seq_name != 'trainval')): prefix = 'train' elif (self._image_set == 'training'): prefix = 'trainval' else: prefix = '' if (prefix == ''): lines = [] lines_flipped = [] else: filename = os.path.join(self._k...
'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.'
def region_proposal_roidb(self):
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 {}'....
'all_boxes is a list of length number-of-classes. Each list element is a list of length number-of-images. Each of those list elements is either an empty list [] or a numpy array of detection. all_boxes[class][image] = [] or np.array of shape #dets x 5'
def evaluate_detections(self, all_boxes, output_dir=None):
raise NotImplementedError
'all_boxes is a list of length number-of-classes. Each list element is a list of length number-of-images. Each of those list elements is either an empty list [] or a numpy array of detection. all_boxes[class][image] = [] or np.array of shape #dets x 5'
def evaluate_proposals(self, all_boxes, output_dir=None):
raise NotImplementedError
'Turn competition mode on or off.'
def competition_mode(self, on):
pass
'This layer does not propagate gradients.'
def backward(self, top, propagate_down, bottom):
pass
'Reshaping happens during the call to forward.'
def reshape(self, bottom, top):
pass
'This layer does not propagate gradients.'
def backward(self, top, propagate_down, bottom):
pass
'Reshaping happens during the call to forward.'
def reshape(self, bottom, top):
pass
'Set the roidb to be used by this layer during training.'
def __init__(self, roidb, num_classes):
self._roidb = roidb self._num_classes = num_classes self._shuffle_roidb_inds()
'Randomly permute the training roidb.'
def _shuffle_roidb_inds(self):
self._perm = np.random.permutation(np.arange(len(self._roidb))) self._cur = 0
'Return the roidb indices for the next minibatch.'
def _get_next_minibatch_inds(self):
if cfg.TRAIN.HAS_RPN: if ((self._cur + cfg.TRAIN.IMS_PER_BATCH) >= len(self._roidb)): self._shuffle_roidb_inds() db_inds = self._perm[self._cur:(self._cur + cfg.TRAIN.IMS_PER_BATCH)] self._cur += cfg.TRAIN.IMS_PER_BATCH else: db_inds = np.zeros(cfg.TRAIN.IMS_PER_BATCH...
'Return the blobs to be used for the next minibatch. If cfg.TRAIN.USE_PREFETCH is True, then blobs will be computed in a separate process and made available through self._blob_queue.'
def _get_next_minibatch(self):
db_inds = self._get_next_minibatch_inds() minibatch_db = [self._roidb[i] for i in db_inds] return get_minibatch(minibatch_db, self._num_classes)
'Get blobs and copy them into this layer\'s top blob vector.'
def forward(self):
blobs = self._get_next_minibatch() return blobs
'Initialize the SolverWrapper.'
def __init__(self, sess, saver, network, imdb, roidb, output_dir, pretrained_model=None):
self.net = network self.imdb = imdb self.roidb = roidb self.output_dir = output_dir self.pretrained_model = pretrained_model print 'Computing bounding-box regression targets...' if cfg.TRAIN.BBOX_REG: (self.bbox_means, self.bbox_stds) = rdl_roidb.add_bbox_regression_targets(...
'Take a snapshot of the network after unnormalizing the learned bounding-box regression weights. This enables easy use at test-time.'
def snapshot(self, sess, iter):
net = self.net if (cfg.TRAIN.BBOX_REG and net.layers.has_key('bbox_pred')): with tf.variable_scope('bbox_pred', reuse=True): weights = tf.get_variable('weights') biases = tf.get_variable('biases') orig_0 = weights.eval() orig_1 = biases.eval() weights_shap...
'ResultLoss = outside_weights * SmoothL1(inside_weights * (bbox_pred - bbox_targets)) SmoothL1(x) = 0.5 * (sigma * x)^2, if |x| < 1 / sigma^2 |x| - 0.5 / sigma^2, otherwise'
def _modified_smooth_l1(self, sigma, bbox_pred, bbox_targets, bbox_inside_weights, bbox_outside_weights):
sigma2 = (sigma * sigma) inside_mul = tf.multiply(bbox_inside_weights, tf.subtract(bbox_pred, bbox_targets)) smooth_l1_sign = tf.cast(tf.less(tf.abs(inside_mul), (1.0 / sigma2)), tf.float32) smooth_l1_option1 = tf.multiply(tf.multiply(inside_mul, inside_mul), (0.5 * sigma2)) smooth_l1_option2 = tf.s...
'Network training loop.'
def train_model(self, sess, max_iters):
data_layer = get_data_layer(self.roidb, self.imdb.num_classes) rpn_cls_score = tf.reshape(self.net.get_output('rpn_cls_score_reshape'), [(-1), 2]) rpn_label = tf.reshape(self.net.get_output('rpn-data')[0], [(-1)]) rpn_cls_score = tf.reshape(tf.gather(rpn_cls_score, tf.where(tf.not_equal(rpn_label, (-1))...
'Yield (token_type, str_data) tokens. The last token will be (EOF, None) where EOF is the singleton object defined in this module.'
def lex(self, text):
for match in self.regex.finditer(text): for (name, _) in self.lexicon: m = match.group(name) if (m is not None): (yield (name, m)) break (yield (EOF, None))
'Parse a string of SVG <path> data.'
def parse(self, text):
next = self.lexer.lex(text).next token = next() return self.rule_svg_path(next, token)
'Yield (token_type, str_data) tokens. The last token will be (EOF, None) where EOF is the singleton object defined in this module.'
def lex(self, text):
for match in self.regex.finditer(text): for (name, _) in self.lexicon: m = match.group(name) if (m is not None): (yield (name, m)) break (yield (EOF, None))
'Parse a string of SVG transform="" data.'
def parse(self, text):
next = self.lexer.lex(text).next commands = [] token = next() while (token[0] is not EOF): (command, token) = self.rule_svg_transform(next, token) commands.append(command) return commands
'Cheap function to invert a hash.'
def _invert(h):
i = {} for (k, v) in h.items(): i[v] = k return i
'Sets up the initial relations between this element and other elements.'
def setup(self, parent=None, previous=None):
self.parent = parent self.previous = previous self.next = None self.previousSibling = None self.nextSibling = None if (self.parent and self.parent.contents): self.previousSibling = self.parent.contents[(-1)] self.previousSibling.nextSibling = self
'Destructively rips this element out of the tree.'
def extract(self):
if self.parent: try: del self.parent.contents[self.parent.index(self)] except ValueError: pass lastChild = self._lastRecursiveChild() nextElement = lastChild.next if self.previous: self.previous.next = nextElement if nextElement: nextElement.pr...
'Finds the last element beneath this object to be parsed.'
def _lastRecursiveChild(self):
lastChild = self while (hasattr(lastChild, 'contents') and lastChild.contents): lastChild = lastChild.contents[(-1)] return lastChild
'Appends the given tag to the contents of this tag.'
def append(self, tag):
self.insert(len(self.contents), tag)