我正在玩在这里找到的类 ObjectDetectionEvaluator() ,试图测试边缘情况以更好地理解对象检测评估指标。我遇到了一个有趣的情况,我对此感到困惑,希望能帮助我理解其背后的推理/合理性。
假设您有一张带有一个真实边界框和两个检测到的边界框的图像。这些检测都与 ground truth 属于同一类,超过了评估者的匹配 IoU 阈值,并且具有相同的置信度分数。为了说明情况,我在下面绘制并编码了问题。
from object_detection.utils import object_detection_evaluation as ode
import numpy as np
# create one ground truth box (boxes encoded as [ymin, xmin, ymax, xmax])
gt_dict = {}
gt_dict['groundtruth_boxes'] = np.array([[0, .25, 1, .75]])
gt_dict['groundtruth_classes'] = np.array([1])
#create two detection boxes in different locations with same score (.8), same IoU (.33),
# and same class
det_dict = {}
det_dict['detection_boxes'] = np.array([[0, 0, 1, .5], [0, .5, 1, 1]])
det_dict['detection_classes'] = np.array([1, 1])
det_dict['detection_scores'] = np.array([.8, .8])
# create and add above info to evaluator
categories = [{'id': 1, 'name':'1'}]
evaluator = ode.ObjectDetectionEvaluator(categories, evaluate_precision_recall=True,
matching_iou_threshold = .3)
evaluator.add_single_ground_truth_image_info('1', gt_dict)
evaluator.add_single_detected_image_info('1', det_dict)
#produce metrics
evaluator.evaluate()
出去:
{'Precision/mAP@0.3IOU': 0.5,
'PerformanceByCategory/AP@0.3IOU/1': 0.5,
'PerformanceByCategory/Precision@0.3IOU/1': array([0. , 0.5]),
'PerformanceByCategory/Recall@0.3IOU/1': array([0., 1.])}
正如我们在上面看到的,精度/召回率@k=1 都是 0/1=0,这是有道理的,因为尽管它们都满足分数/IoU 阈值,但将任一检测分类为真阳性是不正确的替代检测同样可能。但是在 k=2 时,其中一个检测被视为真阳性(精度 = 1/2,召回率 = 1/1)。我对这个结果感到困惑,因为是什么改变使其中一个检测比另一个更真实?我认为@k=2 的精度/召回率应该保持在 0。
如果这实际上是一个错误,那么我将创建一个 git 问题,但如果这实际上是预期的行为,如果有人能给我解释为什么,我将不胜感激?
谢谢你!