Intersection over Union (IoU) is an evaluation metric that computes the ratio of the area of overlap between a predicted bounding box and the ground truth bounding box to their total area of union. It measures localization accuracy by producing a score between 0 (no overlap) and 1 (perfect alignment), directly quantifying how precisely a model identifies an object's spatial position.
Glossary
Intersection over Union (IoU)

What is Intersection over Union (IoU)?
Intersection over Union (IoU) is a fundamental evaluation metric in computer vision that quantifies the spatial overlap accuracy between a predicted bounding box and the ground truth annotation.
In object detection pipelines, IoU serves as the core criterion for determining true positives during evaluation. A standard threshold—typically 0.5—classifies predictions as correct matches. The metric also underpins Non-Maximum Suppression (NMS) and directly influences Mean Average Precision (mAP) calculations, making it the foundational measure for benchmarking models like YOLO and Faster R-CNN.
Key Characteristics of IoU
Intersection over Union (IoU) is the foundational metric for evaluating object detection and segmentation models. It quantifies spatial overlap between predicted and ground truth regions, providing a single score that penalizes both localization errors and size mismatches.
Mathematical Definition
IoU is computed as the ratio of the area of overlap to the area of union between two bounding boxes or segmentation masks.
- Formula: IoU = (Area of Intersection) / (Area of Union)
- Range: 0.0 (no overlap) to 1.0 (perfect overlap)
- Interpretation: A score of 0.5 means the predicted region covers exactly half of the combined area
- Symmetry: IoU(A, B) = IoU(B, A), making it a true distance metric
The denominator (union) prevents the metric from being gamed by predicting oversized boxes that cover the ground truth but lack precision.
Role in Object Detection Evaluation
IoU serves as the gatekeeper for determining whether a predicted bounding box counts as a true positive detection.
- An IoU threshold (typically 0.5 or 0.75) is set to classify predictions
- Predictions with IoU ≥ threshold are true positives
- Predictions with IoU < threshold are false positives
- Ground truth boxes with no matching prediction are false negatives
This thresholding directly feeds into the computation of Precision, Recall, and ultimately Mean Average Precision (mAP) , the standard aggregate metric for detection models.
IoU vs. Other Overlap Metrics
While IoU is the most common overlap metric, alternatives exist for specific use cases:
- Dice Coefficient (F1 Score): 2 × |A ∩ B| / (|A| + |B|). Emphasizes overlap relative to individual sizes, common in medical image segmentation
- GIoU (Generalized IoU): Extends IoU to penalize the distance between non-overlapping boxes by considering the smallest enclosing convex shape
- DIoU (Distance IoU): Adds a penalty term based on the normalized distance between box centers, improving convergence speed during training
- CIoU (Complete IoU): Incorporates aspect ratio consistency alongside overlap and center distance, often used as a loss function in YOLO variants
IoU as a Loss Function
IoU can be directly optimized during model training by converting it into a differentiable loss.
- IoU Loss = 1 − IoU, which the model minimizes via gradient descent
- Directly optimizing IoU aligns the training objective with the evaluation metric
- Standard L1 or L2 losses on box coordinates do not correlate perfectly with IoU improvement
- Modern detectors like YOLO and DETR use IoU-based loss variants (CIoU, GIoU) for bounding box regression
This approach ensures the model learns to produce boxes that maximize spatial overlap rather than simply minimizing coordinate error.
Threshold Selection Trade-offs
The choice of IoU threshold creates a fundamental precision-recall trade-off in detection evaluation:
- Low threshold (0.5): More lenient, accepts loosely localized boxes. Higher recall but potentially lower precision
- High threshold (0.75): Strict localization requirement. Rewards precise models but may penalize acceptable detections
- COCO mAP: Evaluates at multiple thresholds (0.50 to 0.95 in 0.05 steps) and averages, providing a comprehensive view
- Pascal VOC mAP: Historically used a single 0.5 threshold
In manufacturing quality inspection, higher thresholds (0.75+) are often preferred to ensure defect bounding boxes tightly enclose the anomaly for accurate downstream measurement.
Limitations and Edge Cases
IoU has known failure modes that practitioners must account for:
- Scale insensitivity: A small 10×10 box with perfect overlap scores 1.0, same as a large 500×500 box with perfect overlap. IoU does not reflect absolute size accuracy
- Non-overlapping boxes: When intersection is zero, IoU is always 0.0 regardless of how close the boxes are, providing no gradient for optimization
- Concave shapes: IoU is typically computed on axis-aligned rectangles; for instance segmentation masks, pixel-wise IoU is used but does not capture boundary smoothness
- Crowded scenes: In dense object scenarios, multiple predictions may overlap the same ground truth, requiring Non-Maximum Suppression (NMS) to resolve duplicates using IoU as the suppression criterion
Frequently Asked Questions
Explore the mechanics, limitations, and practical applications of Intersection over Union, the foundational metric for evaluating object detection and segmentation models in manufacturing quality inspection.
Intersection over Union (IoU) is an evaluation metric that quantifies the spatial overlap between a predicted bounding box and the ground truth bounding box by dividing the area of their intersection by the area of their union. The calculation follows a strict geometric formula: IoU = Area of Overlap / Area of Union. The resulting score ranges from 0.0 (no overlap) to 1.0 (perfect overlap). In practice, the area of overlap is the region where the predicted box and ground truth box cover the same pixels, while the area of union is the total area encompassed by both boxes combined, subtracting the intersection once to avoid double-counting. For pixel-level tasks like semantic segmentation, IoU is computed per-class by dividing the number of correctly classified pixels by the total number of pixels predicted as that class plus the ground truth pixels of that class minus the correct ones. This metric is also known as the Jaccard Index or Jaccard Similarity Coefficient, named after botanist Paul Jaccard who first formalized the concept for comparing ecological samples.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Understanding IoU requires familiarity with the broader object detection pipeline, from the algorithms that generate bounding boxes to the post-processing steps that refine them.
Non-Maximum Suppression (NMS)
A post-processing algorithm that relies directly on IoU thresholds to filter redundant bounding boxes. When multiple boxes predict the same object, NMS selects the one with the highest confidence score and suppresses all others whose IoU exceeds a set threshold (typically 0.5). This eliminates duplicate detections and ensures a single, clean bounding box per object instance.
Mean Average Precision (mAP)
The primary evaluation metric for object detection models, calculated by averaging precision across all recall levels and object classes. IoU is the foundational gatekeeper: a predicted bounding box is considered a true positive only if its IoU with the ground truth exceeds a defined threshold. Common benchmarks report [email protected] (IoU > 0.5) and the stricter [email protected]:0.95, which averages performance across multiple IoU thresholds from 0.50 to 0.95 in 0.05 increments.
Ground Truth Annotation
The human-labeled bounding boxes that serve as the objective reference for calculating IoU. Annotation quality directly impacts metric reliability—inaccurate or inconsistent ground truth renders IoU meaningless. In manufacturing, ground truth is established by quality engineers who meticulously label defect regions on component images, often using specialized tools that enforce polygon precision for non-rectangular anomalies.
Bounding Box Regression
The mechanism by which object detectors refine the coordinates of anchor boxes or initial proposals to better fit objects. During training, the model learns to predict offsets (Δx, Δy, Δw, Δh) that transform a default box into a tight-fitting prediction. The smooth L1 loss or CIoU loss functions directly optimize these regressions to maximize IoU with the ground truth, penalizing both coordinate errors and scale mismatches.
Confusion Matrix for Detection
A tabular framework that classifies predictions based on IoU thresholds:
- True Positive (TP): IoU ≥ threshold and correct class
- False Positive (FP): IoU < threshold or incorrect class
- False Negative (FN): Ground truth box with no matching prediction
- True Negative (TN): Rarely used in detection; typically background regions correctly ignored
From these counts, precision (TP / (TP + FP)) and recall (TP / (TP + FN)) are derived to plot the precision-recall curve used in mAP calculation.
CIoU and DIoU Loss Functions
Advanced loss functions that extend standard IoU to address its limitations as a training objective:
- DIoU (Distance IoU): Adds a penalty for the normalized distance between the center points of predicted and ground truth boxes, enabling faster convergence when boxes do not overlap.
- CIoU (Complete IoU): Further incorporates aspect ratio consistency, ensuring the predicted box matches both the position and shape of the target.
These are preferred over raw IoU loss because standard IoU provides no gradient when boxes are disjoint.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us