What is Intersection over Union (IoU) and Why Does It Matter?
IoU = (Area of Overlap) / (Area of Union). IoU ranges from 0 (no overlap) to 1 (perfect match).WHY SIMPLE METRICS FAIL
You cannot evaluate detection by counting "correct" predictions alone. A box that overlaps 10% of a car is technically a detection, but useless. A box twice the size of the object is also a detection, but wasteful. IoU quantifies localization quality, not just presence.
IOU THRESHOLDS
A detection is considered "correct" if IoU exceeds a threshold. IoU=0.5: The PASCAL VOC standard. Lenient; allows boxes 50% off. IoU=0.75: Stricter; requires tight localization. IoU=0.5:0.95: The COCO standard averages across 10 thresholds (0.5, 0.55, ..., 0.95) to reward both detection and precise localization.
CALCULATING IOU
Given two boxes with corners (x1, y1, x2, y2): find intersection area = max(0, min(x2a, x2b) - max(x1a, x1b)) × max(0, min(y2a, y2b) - max(y1a, y1b)). Union area = area_a + area_b - intersection. Computationally cheap: 10-20 operations per pair.