Intersection over Union (IoU)
You'll learn how to measure how well your predicted bounding box overlaps with the actual object location.
The Core Idea
When your object detection model predicts where an object is in an image, you need a way to measure how accurate that prediction is. Intersection over Union (IoU) is the standard metric that tells you: "How much do these two boxes overlap?"
IoU compares your predicted bounding box with the ground truth (actual) bounding box by calculating:
IoU = Area of Overlap / Area of Union
Think of it like two overlapping circles in a Venn diagram. The intersection is where both circles overlap. The union is the total area covered by either circle. IoU gives you a ratio between 0 and 1:
- IoU = 1.0: Perfect match! Boxes overlap completely
- IoU = 0.5: Decent overlap, commonly used as a threshold
- IoU = 0.0: No overlap at all
Why It Matters
IoU is essential for:
- Training: Determining which predicted boxes match which ground truth objects
- Evaluation: Deciding if a detection counts as correct (typically IoU > 0.5)
- Non-Maximum Suppression: Filtering out duplicate detections of the same object
Practical Example
Imagine detecting a car. Your model predicts a box, and the ground truth box is slightly offset. If 60% of the predicted box overlaps the ground truth, and this overlapping region represents 40% of the total area both boxes cover, your IoU = 0.4.
Key Takeaway: IoU quantifies bounding box accuracy by measuring overlap relative to total coverage—higher IoU means better localization, with values above 0.5 typically considered successful detections.