- map50定义:
map@0.5" 通常是指目标检测任务中的平均精确度(mAP)评估指标,其中 IoU 阈值设为 0.5。mAP@0.5 衡量了模型在检测目标时的准确性。 - 代码简单:
predictions = [
[50, 50, 150, 150, 0.9, 0],
[60, 60, 160, 160, 0.85, 1],
[70, 70, 170, 170, 0.8, 0],
]
ground_truth = [
[55, 55, 155, 155, 0],
[65, 65, 165, 165, 1],
]
iou_threshold = 0.5
mAP = 0.0
correct_detections = 0
for prediction in predictions:
max_iou = 0.0
best_match = None
for gt in ground_truth:
iou = calculate_iou(prediction[:4], gt[:4])
if iou > max_iou:
max_iou = iou
best_match = gt
if max_iou >= iou_threshold and prediction[4] >= confidence_threshold:
correct_detections += 1
mAP = correct_detections / len(predictions)
print("mAP@0.5:", mAP)
- 上述示例中的 calculate_iou 函数用于计算两个矩形框的 IoU。这个示例是一个非常基本的目标检测评估示例,实际情况可能更加复杂,包括多类别目标、多个IoU阈值、坐标解码等考虑因素。