Tensorflow对象检测评估

问题描述 投票:3回答:1

我喜欢用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/[email protected]: 1.0, 'Pascal/performance by category/[email protected]/face: 1.0}

如果我使用[10, 10, 11, 11][100, 100, 220, 220](其他Box序列)

我得到以下结果:

{'Pascal/precision/[email protected]: 0.5, 'Pascal/performance by category/[email protected]/face: 0.5}

为什么会这样?还是它的错误?

干杯迈克尔

tensorflow object-detection evaluation
1个回答
0
投票

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

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

{'Pascal boxes_precision/[email protected]: 1.0, 'Pascal boxes_performance by category/[email protected]/person: 1.0}

© www.soinside.com 2019 - 2024. All rights reserved.