Intersection over Union - IoU - 交并比 (一)

Intersection over Union - IoU - 交并比 (一)

1. Intersection over Union
The IoU is the ratio of the overlapping area of ground truth and predicted area to the total area. Here is a visual explanation of the metric:

Intersection over Union - IoU - 交并比 (一)

The two squares represent the bounding boxes of ground truth and predictions. The IoU is calculated as a ratio of the area of overlap to the area of the union. Here is the script to compute the IoU is given ground truth and prediction bounding boxes.
def calculate_iou(gt_bb, pred_bb)
gt_bb: ground truth bounding box
pred_bb: prediction bounding box

2. Intersection over Union (IoU,交并比)
目标检测的评价体系中,有一个参数叫做 IoU (交并比),即模型产生的目标窗口与原来标记窗口的交叠率。检测结果 (Detection Result) 与 Ground Truth 的交集除以它们的并集,即为检测的准确率 IoU。

Intersection over Union - IoU - 交并比 (一)

Intersection over Union - IoU - 交并比 (一)

理想情况下,IOU = 1,即完全重合。

GT = GroundTruth
DR = DetectionResult
交集:GT ⋂ DR
并集:GT ⋃ DR

Intersection over Union - IoU - 交并比 (一)

蓝色的框:GroundTruth
黄色的框:DetectionResult
绿色的框:DetectionResult ⋂ GroundTruth
红色的框:DetectionResult ⋃ GroundTruth
最理想的情况就是 DR 与 GT 完全重合,即 IOU = 1。
评价一个算法的时候,一种常见的方法是先设置一个 IOU 的阈值,只要算法找到的 IOU 大于这个阈值,就是一个有效的检测。一般来说,这个 score > 0.5 就可以被认为一个不错的结果。