MCPcopy
hub / github.com/msracver/Deformable-ConvNets / pred_eval

Function pred_eval

fpn/core/tester.py:113–204  ·  view source on GitHub ↗

wrapper for calculating offline validation for faster data analysis in this example, all threshold are set by hand :param predictor: Predictor :param test_data: data iterator, must be non-shuffle :param imdb: image database :param vis: controls visualization :param thres

(predictor, test_data, imdb, cfg, vis=False, thresh=1e-3, logger=None, ignore_cache=True)

Source from the content-addressed store, hash-verified

111
112
113def pred_eval(predictor, test_data, imdb, cfg, vis=False, thresh=1e-3, logger=None, ignore_cache=True):
114 """
115 wrapper for calculating offline validation for faster data analysis
116 in this example, all threshold are set by hand
117 :param predictor: Predictor
118 :param test_data: data iterator, must be non-shuffle
119 :param imdb: image database
120 :param vis: controls visualization
121 :param thresh: valid detection threshold
122 :return:
123 """
124
125 det_file = os.path.join(imdb.result_path, imdb.name + '_detections.pkl')
126 if os.path.exists(det_file) and not ignore_cache:
127 with open(det_file, 'rb') as fid:
128 all_boxes = cPickle.load(fid)
129 info_str = imdb.evaluate_detections(all_boxes)
130 if logger:
131 logger.info('evaluate detections: \n{}'.format(info_str))
132 return
133
134 assert vis or not test_data.shuffle
135 data_names = [k[0] for k in test_data.provide_data[0]]
136
137 if not isinstance(test_data, PrefetchingIter):
138 test_data = PrefetchingIter(test_data)
139
140 # limit detections to max_per_image over all classes
141 max_per_image = cfg.TEST.max_per_image
142 num_images = imdb.num_images
143
144 for test_scale_index, test_scale in enumerate(cfg.TEST_SCALES):
145 det_file_single_scale = os.path.join(imdb.result_path, imdb.name + '_detections_' + str(test_scale_index) + '.pkl')
146 # if os.path.exists(det_file_single_scale):
147 # continue
148 cfg.SCALES = [test_scale]
149 test_data.reset()
150
151 # all detections are collected into:
152 # all_boxes[cls][image] = N x 5 array of detections in
153 # (x1, y1, x2, y2, score)
154 all_boxes_single_scale = [[[] for _ in range(num_images)]
155 for _ in range(imdb.num_classes)]
156
157 detect_at_single_scale(predictor, data_names, imdb, test_data, cfg, thresh, vis, all_boxes_single_scale, logger)
158
159 with open(det_file_single_scale, 'wb') as f:
160 cPickle.dump(all_boxes_single_scale, f, protocol=cPickle.HIGHEST_PROTOCOL)
161
162 # all detections are collected into:
163 # all_boxes[cls][image] = N x 5 array of detections in
164 # (x1, y1, x2, y2, score)
165 all_boxes = [[[] for _ in range(num_images)] for _ in range(imdb.num_classes)]
166
167 for test_scale_index, test_scale in enumerate(cfg.TEST_SCALES):
168 det_file_single_scale = os.path.join(imdb.result_path, imdb.name + '_detections_' + str(test_scale_index) + '.pkl')
169 if os.path.exists(det_file_single_scale):
170 with open(det_file_single_scale, 'rb') as fid:

Callers 1

test_rcnnFunction · 0.90

Calls 10

resetMethod · 0.95
PrefetchingIterClass · 0.90
py_softnms_wrapperFunction · 0.90
py_nms_wrapperFunction · 0.90
nmsFunction · 0.90
detect_at_single_scaleFunction · 0.85
soft_nmsFunction · 0.85
infoMethod · 0.80
loadMethod · 0.45
evaluate_detectionsMethod · 0.45

Tested by

no test coverage detected