A detector can miss an object, predict the wrong class, draw an inaccurate box, or report the same object several times. Counting “correct images” hides these different errors. Detection metrics instead compare individual predictions with labeled objects and examine how the result changes as more predictions are accepted.
Match before counting
In this example, predictions are processed by decreasing score within each class. Each prediction can match the best still-unmatched ground-truth box of that class if IoU reaches the chosen threshold. A match is a true positive (TP); an unmatched prediction is a false positive (FP). A labeled object without a match is a false negative (FN).
Start with cars at IoU 0.50. Prediction B overlaps the first car, but A has already claimed it. Lower the confidence threshold to include E: recall improves because the second car finally receives a match.
Dashed: ground truth. Teal: matched prediction. Amber: unmatched prediction. Only the selected class is evaluated below.
- TP / FP / FN
- 1 / 2 / 1
- Precision
- 0.333
- Recall
- 0.500
- car AP@0.50
- 0.752
- Mean AP · two classes
- 0.876
Authored predictions, calculated metrics. Changing confidence moves the operating point; AP still uses the full ranking. This single-image example omits crowd/ignore handling, area ranges and detection caps. It is not the full COCO evaluation protocol.
Precision and recall describe one operating point
At the initial car settings, three predictions are retained: A is correct, B is a duplicate, and D is misplaced. There are two labeled cars. Precision is therefore 1/3, recall is 1/2, and one car is missed.
Lowering the score threshold to 0.40 adds E. Precision becomes 2/4 = 0.5, and recall reaches 1. Lowering a threshold does not guarantee that precision always decreases; this example adds a true positive after two false positives.
With no retained predictions, precision has a zero denominator and the explorer displays a dash. Recall is zero because the selected class has labeled objects. Handling a class with no ground truth is a different edge case; define that policy before aggregating metrics.
Average precision summarizes a ranking
Sweeping the confidence cutoff traces precision against recall. The explorer constructs an interpolated precision envelope: for each requested recall level, take the best precision achieved at that recall or higher, or zero if it is unreachable. AP is the mean of this envelope at 101 levels from 0 to 1.
For the car ranking at IoU 0.50, the TP/FP sequence is TP, FP, FP, TP. The envelope is 1 through recall 0.5 and 0.5 above it. This gives:
The 51 samples include both 0 and 0.5. This discrete convention explains why the value is slightly above the continuous area 0.75. Moving the confidence slider changes the operating point, not the full ranking used for AP.
State which mean you report
At one fixed IoU threshold, the explorer averages car AP and person AP. This is a two-class mean AP for one synthetic image. Raising the IoU threshold can turn a loose match into a false positive, changing both the curve and AP.
COCO's main detection AP additionally averages over IoU thresholds 0.50 through 0.95 in steps of 0.05. Its evaluator also handles crowd/ignored annotations, object-area ranges, and detection caps. The explorer omits those cases and is not a replacement for the benchmark evaluator. COCO evaluation implementation
Compare models without hiding the errors
Report the dataset split, classes, IoU protocol, score filtering, and evaluation implementation with any AP number. For deployment, also examine the chosen operating point: how many objects are missed, and how many false alarms remain under the conditions that matter?
Inspect errors by object size, crowding, lighting, and class. A single mean can hide poor recall for small objects or a class with very few examples. The next useful question is often about the error pattern, not another decimal place in mAP.
Related concepts
Compare anchor-based vs anchor-free object detection: Faster R-CNN and RetinaNet anchors vs FCOS and CenterNet point-based methods.
Learn how DETR assigns unordered object targets to prediction slots, why greedy choices can fail, and how matching differs from training loss and evaluation.
Learn how normalized box coordinates, L1 loss, IoU, and Generalized IoU guide object localization, including disjoint boxes and containment limits.
Convert between xyxy, xywh and center-size boxes, normalize coordinates correctly, and avoid mistakes when resizing, clipping or flipping detection labels.
Follow a query from a spatial reference through learned offsets, bilinear feature sampling and weighted aggregation, with exact non-square coordinate arithmetic.
Evaluate frozen image features with nearest neighbors and linear probes, separate training from validation and test data, and understand what each protocol can establish.
