▶ Sign up free for the video, slides & prompts
The lesson below is open to all. Enter your email once to unlock every video, slide deck, prompt and code example on this device.
Checking…
Computer Vision in Practice · Lesson 8 of 15 · 2 min read · 5 min video
Measuring detection: IoU and mAP
How to tell if a detector is good, and which mistakes it makes.
📄 Download slides (PDF)· free sign-upAccuracy doesn't work for detection. A box can be in roughly the right place, a bit too big, or completely wrong. Detection has its own metrics: IoU and mAP.
IoU: how well do two boxes match?
Intersection over Union compares a predicted box with the true box:
IoU = area where they overlap ÷ total area they cover together
- 1.0: a perfect match
- 0.5: a decent match, and the usual cut-off for "correct"
- 0: no overlap at all
Precision and recall for boxes
A prediction counts as a true positive if it has the right class and an IoU above the threshold with a real object.
- Precision: of the boxes the model drew, how many were right?
- Recall: of the real objects, how many did it find?
Changing the confidence threshold trades one for the other, which gives a precision–recall curve.
mAP: one number to compare models
- AP (average precision): the area under the precision–recall curve for one class
- mAP: the average AP across all classes
- mAP@0.5: using IoU 0.5 as the cut-off
- mAP@0.5:0.95: averaged over stricter IoU cut-offs too, which rewards tight boxes. This is the COCO standard
Look beyond the single number
- Per-class AP: maybe buses are great but bikes are poor
- Object size: small, distant objects are usually the weak spot
- Conditions: night, rain and crowded scenes, tested separately
In one line
IoU measures how well a predicted box overlaps the real one, and mAP averages precision across recall levels and classes, but always check per-class results and real images too.
Share with a friend