def _do_mscnn_eval(self, file_dict): """ file_dict: 'cls' -> 'mscnn eval file' """ anno_filename = self._label_file image_set_file = self._get_image_set_file() aps = [] use_07_metric = self.config['use_07_metric'] print 'VOC07 metric? ' + ('Yes' if use_07_metric else 'No') print('~~~~~~~~') weighted_ap = 0 weighted_n = 0 for i, cls in enumerate(self._classes): if cls == '__background__': continue if cls in file_dict: filename = file_dict[cls] else: print('No file found for {}'.format(cls)) continue rec, prec, ap, ground_truth_box_num = sz_eval( filename, anno_filename, image_set_file, cls, ovthresh=0.5, use_07_metric=use_07_metric) aps += [ap] weighted_n += ground_truth_box_num weighted_ap += ground_truth_box_num * ap print('AP for %s = %f (%d samples)' % (cls, ap, ground_truth_box_num)) print('Mean AP = {:.4f}'.format(np.mean(aps))) print('Weighted AP = {:.4f}'.format(float(weighted_ap) / weighted_n)) print('~~~~~~~~')
def _do_python_eval(self, output_dir='output'): anno_filename = self._label_file image_set_file = self._get_image_set_file() aps = [] use_07_metric = self.config['use_07_metric'] print 'VOC07 metric? ' + ('Yes' if use_07_metric else 'No') if not os.path.isdir(output_dir): os.mkdir(output_dir) print('~~~~~~~~') weighted_ap = 0 weighted_n = 0 for i, cls in enumerate(self._classes): if cls == '__background__': continue filename = self._get_sz_results_file_template().format(cls) rec, prec, ap, ground_truth_box_num = sz_eval( filename, anno_filename, image_set_file, cls, ovthresh=0.5, use_07_metric=use_07_metric) aps += [ap] weighted_n += ground_truth_box_num weighted_ap += ground_truth_box_num * ap print('AP for %s = %f (%d samples)' % (cls, ap, ground_truth_box_num)) with open(os.path.join(output_dir, cls + '_pr.pkl'), 'w') as f: cPickle.dump({'rec': rec, 'prec': prec, 'ap': ap}, f) print('Mean AP = {:.4f}'.format(np.mean(aps))) print('Weighted AP = {:.4f}'.format(float(weighted_ap) / weighted_n)) print('~~~~~~~~')