gpt4 book ai didi

Tensorflow 物体检测评估

转载 作者:行者123 更新时间:2023-12-03 23:57:57 24 4
gpt4 key购买 nike

我喜欢用 mAP(平均精度)评估我的对象检测模型。在 https://github.com/tensorflow/models/tree/master/research/object_detection/utils/我想使用 object_detection_evaluation.py。

我对 groundtruth 框使用以下内容:

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](其他Box序列)

我得到以下结果:

{'PASCAL/Precision/mAP@0.1IOU': 0.5, 'PASCAL/PerformanceByCategory/AP@0.1IOU/face': 0.5}

为什么会这样?还是bug?

迈克尔干杯

最佳答案

虽然您不是很清楚,但我认为我在您的代码中发现了错误。您提到对于不同顺序的边界框您会得到不同的结果。这看起来很奇怪,如果是真的,那肯定是一个错误。

但是,由于我自己测试了代码,您可能没有更改相应的分数 (detected_scores = np.array([0.8, 0.9], dtype=float)) 到边界框。但是这样你也改变了问题,而不仅仅是边界框的顺序。如果您应用正确的边界框, map 在两种情况下都保持不变:

{'PascalBoxes_Precision/mAP@0.5IOU': 1.0, 'PascalBoxes_PerformanceByCategory/AP@0.5IOU/person': 1.0}

关于Tensorflow 物体检测评估,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49014512/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com