Intersection over union (IoU) is a key evaluation metric in computer vision, particularly for tasks like object detection, instance segmentation, and semantic segmentation. IoU measures the overlap between two areas: a predicted region (like a bounding box or mask produced by a model) and the ground truth region (the correct, labeled area). The calculation is straightforward: IoU equals the area of overlap divided by the area of union between the predicted and ground truth shapes. Mathematically, IoU = (Area of Overlap) / (Area of Union).
IoU values range from 0 to 1. A value of 0 means there is no overlap at all, while 1 means perfect, complete overlap—the prediction matches the ground truth exactly. In practice, higher IoU scores indicate better model performance. For many applications, a threshold is set (often 0.5) to decide whether a prediction counts as a ‘correct’ detection. For example, if a predicted bounding box for a car in an image has an IoU of 0.6 with the ground truth box, and the threshold is 0.5, that prediction is considered accurate.
IoU helps address the challenge of evaluating model predictions in spatial tasks, where the precise location and shape of predictions matter. Unlike accuracy metrics used for simple classification, IoU provides a more nuanced view by penalizing both missing parts of the object and predicting too much background. This is especially useful when objects are closely packed or have complex boundaries.
In research and industry, IoU is often used alongside other metrics like precision and recall to get a fuller picture of model performance. For example, mean average precision (mAP) at different IoU thresholds is a common summary metric for object detection competitions. IoU can also be extended to evaluate segmentation masks, not just bounding boxes, making it a flexible tool in computer vision.
Many deep learning frameworks have built-in functions for calculating IoU, and it’s standard practice to monitor IoU during model training and validation. However, IoU has some limitations. For small objects, a slight misalignment can drastically reduce the IoU score. Also, it does not take into account how close a predicted object is to the correct location if there is no overlap at all.
Understanding IoU is essential for anyone working with computer vision models. It helps ensure that models are not just making predictions, but making accurate ones in the right places. The metric’s simplicity and interpretability have made it a go-to choice for comparing models and tracking improvements over time.