我们从Python开源项目中,提取了以下30个代码示例,用于说明如何使用datasets.imagenet3d()。
def evaluate_detections(self, all_boxes, output_dir): # for each image for im_ind, index in enumerate(self.image_index): filename = os.path.join(output_dir, index + '.txt') print 'Writing imagenet3d results to file ' + filename with open(filename, 'wt') as f: # for each class for cls_ind, cls in enumerate(self.classes): if cls == '__background__': continue dets = all_boxes[cls_ind][im_ind] if dets == []: continue # detection and viewpoint for k in xrange(dets.shape[0]): f.write('{:s} {:f} {:f} {:f} {:f} {:.32f} {:f} {:f} {:f}\n'.format(\ cls, dets[k, 0], dets[k, 1], dets[k, 2], dets[k, 3], dets[k, 4], dets[k, 6], dets[k, 7], dets[k, 8])) # write detection results into one file
def evaluate_detections_one_file(self, all_boxes, output_dir): # for each class for cls_ind, cls in enumerate(self.classes): if cls == '__background__': continue # open results file filename = os.path.join(output_dir, 'detections_{}.txt'.format(cls)) print 'Writing imagenet3d results to file ' + filename with open(filename, 'wt') as f: # for each image for im_ind, index in enumerate(self.image_index): dets = all_boxes[cls_ind][im_ind] if dets == []: continue # detection and viewpoint for k in xrange(dets.shape[0]): f.write('{:s} {:f} {:f} {:f} {:f} {:.32f} {:f} {:f} {:f}\n'.format(\ index, dets[k, 0], dets[k, 1], dets[k, 2], dets[k, 3], dets[k, 4], dets[k, 6], dets[k, 7], dets[k, 8]))
def evaluate_proposals(self, all_boxes, output_dir): # for each image for im_ind, index in enumerate(self.image_index): filename = os.path.join(output_dir, index + '.txt') print 'Writing imagenet3d results to file ' + filename with open(filename, 'wt') as f: # for each class for cls_ind, cls in enumerate(self.classes): if cls == '__background__': continue dets = all_boxes[cls_ind][im_ind] if dets == []: continue for k in xrange(dets.shape[0]): f.write('{:f} {:f} {:f} {:f} {:.32f}\n'.format(\ dets[k, 0], dets[k, 1], dets[k, 2], dets[k, 3], dets[k, 4]))
def __init__(self, image_set, imagenet3d_path=None): datasets.imdb.__init__(self, 'imagenet3d_' + image_set) self._image_set = image_set self._imagenet3d_path = self._get_default_path() if imagenet3d_path is None \ else imagenet3d_path self._data_path = os.path.join(self._imagenet3d_path, 'Images') self._classes = ('__background__', 'aeroplane', 'ashtray', 'backpack', 'basket', \ 'bed', 'bench', 'bicycle', 'blackboard', 'boat', 'bookshelf', 'bottle', 'bucket', \ 'bus', 'cabinet', 'calculator', 'camera', 'can', 'cap', 'car', 'cellphone', 'chair', \ 'clock', 'coffee_maker', 'comb', 'computer', 'cup', 'desk_lamp', 'diningtable', \ 'dishwasher', 'door', 'eraser', 'eyeglasses', 'fan', 'faucet', 'filing_cabinet', \ 'fire_extinguisher', 'fish_tank', 'flashlight', 'fork', 'guitar', 'hair_dryer', \ 'hammer', 'headphone', 'helmet', 'iron', 'jar', 'kettle', 'key', 'keyboard', 'knife', \ 'laptop', 'lighter', 'mailbox', 'microphone', 'microwave', 'motorbike', 'mouse', \ 'paintbrush', 'pan', 'pen', 'pencil', 'piano', 'pillow', 'plate', 'pot', 'printer', \ 'racket', 'refrigerator', 'remote_control', 'rifle', 'road_pole', 'satellite_dish', \ 'scissors', 'screwdriver', 'shoe', 'shovel', 'sign', 'skate', 'skateboard', 'slipper', \ 'sofa', 'speaker', 'spoon', 'stapler', 'stove', 'suitcase', 'teapot', 'telephone', \ 'toaster', 'toilet', 'toothbrush', 'train', 'trash_bin', 'trophy', 'tub', 'tvmonitor', \ 'vending_machine', 'washing_machine', 'watch', 'wheelchair') self._class_to_ind = dict(zip(self.classes, xrange(self.num_classes))) self._image_ext = '.JPEG' self._image_index = self._load_image_set_index() # Default to roidb handler if cfg.IS_RPN: self._roidb_handler = self.gt_roidb else: self._roidb_handler = self.region_proposal_roidb self.config = {'top_k': 100000} # statistics for computing recall self._num_boxes_all = np.zeros(self.num_classes, dtype=np.int) self._num_boxes_covered = np.zeros(self.num_classes, dtype=np.int) self._num_boxes_proposal = 0 assert os.path.exists(self._imagenet3d_path), \ 'imagenet3d path does not exist: {}'.format(self._imagenet3d_path) assert os.path.exists(self._data_path), \ 'Path does not exist: {}'.format(self._data_path)
def _get_default_path(self): """ Return the default path where imagenet3d is expected to be installed. """ return os.path.join(datasets.ROOT_DIR, 'data', 'ImageNet3D')