我喜欢使用mAP(平均精度均值)来评估我的物体检测模型。在https://github.com/tensorflow/models/tree/master/research/object_detection/utils/中,有一个名为object_detection_evaluation.py的文件,我希望能够使用它。
我使用以下内容作为真实框:
pascal_evaluator = object_detection_evaluation.PascalDetectionEvaluator(
categories, matching_iou_threshold=0.1)
groundtruth_boxes = np.array([[10, 10, 11, 11]], dtype=float)
groundtruth_class_labels = np.array([1], dtype=int)
groundtruth_is_difficult_list = np.array([False], dtype=bool)
pascal_evaluator.add_single_ground_truth_image_info(
'img2',
{
standard_fields.InputDataFields.groundtruth_boxes: groundtruth_boxes,
standard_fields.InputDataFields.groundtruth_classes: groundtruth_class_labels,
standard_fields.InputDataFields.groundtruth_difficult: groundtruth_is_difficult_list
}
)
并且这是预测框的内容:
# Add detections
image_key = 'img2'
detected_boxes = np.array(
[ [100, 100, 220, 220], [10, 10, 11, 11]],
dtype=float)
detected_class_labels = np.array([1,1], dtype=int)
detected_scores = np.array([0.8, 0.9], dtype=float)
pascal_evaluator.add_single_detected_image_info(image_key, {
standard_fields.DetectionResultFields.detection_boxes:
detected_boxes,
standard_fields.DetectionResultFields.detection_scores:
detected_scores,
standard_fields.DetectionResultFields.detection_classes:
detected_class_labels
})
我使用以下方式打印结果:
metrics = pascal_evaluator.evaluate()
print(metrics)
我的问题是:
如果我使用这个预测框 [100, 100, 220, 220]
,[10, 10, 11, 11]
,结果是:
{'PASCAL/Precision/mAP@0.1IOU': 1.0, 'PASCAL/PerformanceByCategory/AP@0.1IOU/face': 1.0}
如果我使用 [10, 10, 11, 11]
,[100, 100, 220, 220]
(其他框的顺序),我会得到以下结果:
{'PASCAL/Precision/mAP@0.1IOU': 0.5, 'PASCAL/PerformanceByCategory/AP@0.1IOU/face': 0.5}
为什么会这样?或者这是个错误吗?
谢谢 Michael