Object detection identifies what objects appear in one image and where they are. Unlike image classification, it can produce zero, one, or many predictions per image. section 8.0
A practical detector usually predicts a class and a bounding box for each object. A box is represented by four absolute coordinates, such as (x1, y1, x2, y2), and should tightly contain the entire object without duplicating it. section 8.4 section 8.4.2
Two common ways to obtain object locations are:
- Image segmentation classifies every pixel as an object category or background, then connected regions can reveal each object. It is precise but requires expensive pixel-level labels. section 8.1
- Bounding-box detection finds candidate locations in one pass and classifies the objects found there. Faster R-CNN combines a convolutional backbone with networks for proposing regions and deciding their classes. section 8.4 section 8.7
- Non-maximum suppression reduces false positives by filtering overlapping predictions. section 8.7
A minimal PyTorch detection dataset
A toy MNIST detector places a random number of digits on a 100 × 100 canvas. Each sample returns an image and a dictionary: boxes has shape (k, 4), while labels has shape (k), allowing k to vary between images. Faster R-CNN receives lists of images and dictionaries through a custom collate function rather than a padded tensor batch. section 8.4.2
Figure 8.8 A stop sign as the target for bounding-box-based object detection. The green box shows the ground truth, a box just large enough to contain the entire object. The red box shows a potential prediction, which is close but not quite correct. Water doesn’t obey the whimsical desires of the lowly stop sign.
Use the stop-sign diagram to compare a ground-truth box with a nearby but imperfect prediction. section 8.4




