Computer Vision / Modern Vision
From "what" to "what and where".
Reviewed by Yuvaraj
Image classification answers one question, "what is the main thing in this picture?", with a single label. That is not enough for most real systems. A self-driving car needs to know there are three pedestrians and where each one is. A medical tool needs the exact outline of a tumor, not just "tumor: yes." Moving from a whole-image label to per-object boxes and per-pixel outlines is the leap from recognition to localization, and it changes both the model's output and the way we measure success.
The vision tasks form a ladder of increasing spatial precision. Each demands a different output structure and a different metric.
| Task | Question answered | Output |
|---|---|---|
| Classification | What is in the image? | One (or a few) class labels for the image |
| Object detection | What, and where? | A bounding box + class + score per object |
| Semantic segmentation | Which class is each pixel? | A class label for every pixel |
| Instance segmentation | Which pixels belong to which object? | A separate pixel mask per object |
The key distinction inside segmentation: semantic segmentation labels every pixel by category but does not separate two adjacent cars, all their pixels are just "car." Instance segmentation gives each car its own mask, so you can count them and outline each one. (Panoptic segmentation unifies both: every pixel gets a class, and every object instance gets an id.)
A bounding box is four numbers, commonly the corner coordinates . To score a predicted box against a ground-truth box, we need a measure of overlap that is scale-invariant and forgiving of small offsets. That measure is : the area where the two boxes overlap, divided by the total area they jointly cover.
Ask about this lesson, or about anything in AI. Answers cite the lessons they draw on.
Finished this lesson?
Mark it complete to earn XP, keep your streak, and schedule a review.
IoU ranges from 0 (no overlap) to 1 (perfect match). Work a concrete case. Let the predicted box be the square and the ground-truth box be , same size, each offset by 10 pixels.
Detectors count a prediction as correct only when its IoU with a ground-truth box clears a threshold. At the common threshold of , this prediction passes; a stricter threshold of would reject the very same box, since falls below it. That sensitivity to the threshold is exactly why modern benchmarks average over many of them.
A detector does not emit one clean box per object. It proposes many overlapping boxes around each object, each with a confidence score. Non-max suppression (NMS) prunes this thicket down to one box per object.
Set the NMS IoU threshold too low and you delete genuine nearby objects; too high and you keep duplicate boxes. It is a real hyperparameter, not an afterthought.
A single accuracy number cannot capture detection quality, because a detector trades off finding more objects (recall) against being right when it fires (precision), and that trade-off shifts as you move the confidence cutoff. The field's answer is mean Average Precision (mAP).
For a curious beginner
A good detector is right when it is confident (precision) and still finds most of the real objects (recall). mAP rolls both into one number: it sweeps the confidence cutoff from strict to lenient, records how precision and recall trade off along the way, and then averages that performance across every object category.
How it is actually used
Per class, sort predictions by confidence and walk down the list, matching each to an unclaimed ground-truth box by IoU above a threshold. Each match is a true positive, each unmatched prediction a false positive, each missed object a false negative. Plot the precision-recall curve this traces and take its area, that is Average Precision (AP). Average AP over all classes to get mAP; the COCO benchmark averages again over IoU thresholds from 0.5 to 0.95.
The underlying mechanism
, the area under the precision-recall curve, in practice a finite sum over recall levels. Then over the classes. COCO's headline metric averages this over ten IoU thresholds , written mAP@[.5:.95], rewarding tight localization rather than merely loose overlap.
Detector architectures split into two families, trading speed against accuracy, a gap that has narrowed sharply over time.
Segmentation pushes localization to its limit, a per-pixel decision. Semantic segmentation outputs a map the same height and width as the input, with a class id at every pixel; architecturally this is usually an encoder that downsamples to extract features followed by a decoder that upsamples back to full resolution (a U-Net-style design). Instance segmentation adds a mask per detected object: Mask R-CNN, for example, extends a two-stage detector with a small branch that predicts a binary foreground mask inside each box. IoU reappears here too, now measured between predicted and true masks rather than boxes, as the natural overlap metric for pixel regions.
Common mistakes