Mean Average Precision (mAP)
Mean average precision (mAP) scores detectors by averaging precision over recall, classes and IoU thresholds. How mAP50 and mAP50-95 are calculated.
Mean average precision (mAP) is the standard evaluation metric for object detection, and the same recipe scores instance segmentation, pose estimation, and oriented detection. It rewards a model for finding every object, for avoiding false detections, and for placing each bounding box tightly, and it compresses all three into one number between 0 and 1, often written as a percentage. Average precision (AP) is the area under one class's precision-recall curve, mAP is the mean of AP across classes, and the most widely reported form, mAP50-95, also averages over ten intersection over union (IoU) thresholds.
The Building Blocks#
- IoU: the overlap between a predicted box and a labeled box, from 0 to 1. A prediction is a true positive only when its IoU with a not-yet-matched label of the same class reaches the threshold, such as 0.5.
- Precision: the share of predictions that are correct, TP / (TP + FP).
- Recall: the share of labeled objects that the model finds, TP / (TP + FN).
- Confidence: the score that ranks detections. Each confidence cutoff gives one precision-recall pair, and all cutoffs together trace the precision-recall curve.
How mAP Is Calculated#
Evaluation pools every detection of one class across the whole dataset and sorts them by confidence. Walking down that list, each detection either claims the best-overlapping unmatched label of its class and becomes a true positive, or becomes a false positive. A label can be claimed only once, so a second box on an already-found object counts against precision. After each step, precision and recall are recomputed, which traces the precision-recall curve from the most confident detection to the least.
AP is the area under that curve. Before integrating, the curve is replaced by its envelope, the highest precision found at each recall level or beyond, so small zigzags do not change the score. The COCO evaluation samples the envelope at 101 recall points from 0 to 1, where the original PASCAL VOC benchmark used 11. Recall levels that the model never reaches contribute zero precision, so every missed object lowers AP.
import numpy as np
# One class: 8 detections sorted by confidence (1 = matched a label, 0 = false positive)
tp = np.array([1, 1, 0, 1, 0, 1, 0, 0])
num_labels = 5 # ground-truth objects of this class in the dataset
# Precision and recall after each detection in the ranked list
tp_cum = np.cumsum(tp)
precision = tp_cum / np.arange(1, len(tp) + 1)
recall = tp_cum / num_labels
# Precision envelope: best precision at this recall or any higher recall
envelope = np.maximum.accumulate(precision[::-1])[::-1]
# COCO-style AP: average the envelope at 101 recall points (0 beyond the highest recall reached)
points = np.linspace(0, 1, 101)
idx = np.searchsorted(recall, points, side="left")
ap = np.mean([envelope[i] if i < len(envelope) else 0.0 for i in idx])
print(f"Max recall: {recall[-1]:.1f}, AP: {ap:.3f}")The script prints Max recall: 0.8, AP: 0.686. One of the five labeled objects is never detected, so the last fifth of the recall axis adds nothing to the area, and AP stays at 0.686 even though the two most confident detections are both correct.
mAP vs. Related Metrics#
- Accuracy divides correct predictions by all predictions, which requires counting true negatives. A detector's true negatives would be every empty patch of background, so accuracy has no meaningful value in detection.
- F1-score combines precision and recall at one confidence threshold and describes a single operating point, such as the threshold a deployed model runs at.
- Confusion matrix counts which classes a detector mixes up at one threshold, the detail that a single mAP number hides.
mAP50, mAP75, and mAP50-95#
Because mAP is a plain mean over classes, a rare class counts as much as a common one. The IoU threshold sets how tight a box must be to count:
- mAP50: a detection is correct at IoU 0.5, the PASCAL VOC rule.
- mAP75: the threshold rises to 0.75, a strict test of localization.
- mAP50-95: mAP averaged over ten thresholds, 0.50 to 0.95 in steps of 0.05. COCO calls this number simply "AP," makes no distinction between AP and mAP, and uses it as its primary challenge metric.
Ultralytics YOLO26 training keeps best.pt from the epoch with the highest validation mAP50-95, and validation reports all three variants on every run.
from ultralytics import YOLO
# Load a pretrained YOLO26 nano detector
model = YOLO("yolo26n.pt")
# Validate on the small COCO8 dataset to compute mAP
metrics = model.val(data="coco8.yaml")
# The same detections scored at three IoU thresholds
print(f"mAP50: {metrics.box.map50:.3f}")
print(f"mAP75: {metrics.box.map75:.3f}")
print(f"mAP50-95: {metrics.box.map:.3f}")The looser the IoU threshold, the more detections count as correct, so mAP50 comes out highest and mAP50-95 below it. COCO also splits AP by object size: small objects cover less than 32 × 32 pixels of area, medium objects up to 96 × 96, and large objects more than that.










