未验证 提交 3519626d 编写于 作者: W wangguanzhong 提交者: GitHub

fix error info in map_utils (#3317)

上级 a40349a4
......@@ -22,9 +22,7 @@ import numpy as np
import logging
logger = logging.getLogger(__name__)
__all__ = [
'bbox_area', 'jaccard_overlap', 'DetectionMAP'
]
__all__ = ['bbox_area', 'jaccard_overlap', 'DetectionMAP']
def bbox_area(bbox, is_bbox_normalized):
......@@ -48,13 +46,11 @@ def jaccard_overlap(pred, gt, is_bbox_normalized=False):
inter_ymin = max(pred[1], gt[1])
inter_xmax = min(pred[2], gt[2])
inter_ymax = min(pred[3], gt[3])
inter_size = bbox_area([inter_xmin, inter_ymin,
inter_xmax, inter_ymax],
inter_size = bbox_area([inter_xmin, inter_ymin, inter_xmax, inter_ymax],
is_bbox_normalized)
pred_size = bbox_area(pred, is_bbox_normalized)
gt_size = bbox_area(gt, is_bbox_normalized)
overlap = float(inter_size) / (
pred_size + gt_size - inter_size)
overlap = float(inter_size) / (pred_size + gt_size - inter_size)
return overlap
......@@ -126,15 +122,12 @@ class DetectionMAP(object):
if self.evaluate_difficult or \
int(np.array(difficult[max_idx])) == 0:
if not visited[max_idx]:
self.class_score_poss[
int(label)].append([score, 1.0])
self.class_score_poss[int(label)].append([score, 1.0])
visited[max_idx] = True
else:
self.class_score_poss[
int(label)].append([score, 0.0])
self.class_score_poss[int(label)].append([score, 0.0])
else:
self.class_score_poss[
int(label)].append([score, 0.0])
self.class_score_poss[int(label)].append([score, 0.0])
def reset(self):
"""
......@@ -190,7 +183,7 @@ class DetectionMAP(object):
mAP += ap
valid_cnt += 1
else:
logger.error("Unspported mAP type {}".format(map_type))
logger.error("Unspported mAP type {}".format(self.map_type))
sys.exit(1)
self.mAP = mAP / float(valid_cnt) if valid_cnt > 0 else mAP
......@@ -208,9 +201,7 @@ class DetectionMAP(object):
Calculate accumulating true/false positive results from
[score, pos] records
"""
sorted_list = sorted(score_pos_list,
key=lambda s: s[0],
reverse=True)
sorted_list = sorted(score_pos_list, key=lambda s: s[0], reverse=True)
accum_tp = 0
accum_fp = 0
accum_tp_list = []
......@@ -221,4 +212,3 @@ class DetectionMAP(object):
accum_fp += 1 - int(pos)
accum_fp_list.append(accum_fp)
return accum_tp_list, accum_fp_list
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册