Deep Learning Object Detection
Image classification answers one question: what is in this picture? Object detection answers two: what objects appear, and where does each one sit? A detector draws a box around every object and attaches a label and a confidence score to each box.
Classification, Detection, and Segmentation
Classification: "This image contains a dog."
Detection: "A dog sits at box (40, 60, 200, 220)
and a ball sits at box (260, 180, 310, 230)."
Segmentation: "These exact pixels belong to the dog."
Detection sits between the other two tasks. It gives location without tracing exact outlines.
Bounding Boxes
A bounding box is a rectangle that wraps an object. Four numbers describe it: the left edge, the top edge, the width, and the height. The network predicts these numbers along with a class label.
+-----------------------+ | +---------+ | | | CAT | | | | 0.94 | | | +---------+ | | +-----+| | | DOG || | | 0.88|| | +-----+| +-----------------------+
Measuring Box Quality with IoU
Intersection over Union, or IoU, scores how well a predicted box matches the true box. Divide the overlapping area by the combined area.
True box area: 100 Predicted box area: 100 Overlap area: 60 Combined area: 140 IoU = 60 / 140 = 0.43
An IoU of 1.0 means a perfect match, and 0 means no overlap. Many benchmarks count a detection as correct when IoU reaches 0.5 or higher.
How a Detector Works
Step 1: Extract Features
A convolutional backbone scans the image and builds feature maps that capture edges, textures, and shapes.
Step 2: Propose Candidate Boxes
The network proposes many possible boxes across the image. Some systems use preset shapes called anchor boxes in different sizes and ratios.
Step 3: Classify and Refine
Each candidate receives a class score and small corrections to its position and size.
Step 4: Remove Duplicates
Several boxes often land on the same object. Non-maximum suppression keeps the box with the highest score and removes boxes that overlap it heavily.
Before: 5 boxes on one cat (scores 0.95, 0.90, 0.85, 0.70, 0.60) After: 1 box on the cat (score 0.95)
Popular Detector Families
| Family | Approach | Strength |
|---|---|---|
| Faster R-CNN | Two stages: propose, then classify | High accuracy |
| SSD | One stage with multi-scale boxes | Balanced speed and accuracy |
| YOLO | One stage on a grid | Very fast, suits live video |
The YOLO Grid Idea
YOLO splits an image into a grid. Each grid cell predicts boxes for objects whose centre falls inside that cell. One pass through the network produces every detection, which makes the method fast.
+---+---+---+ | | | | +---+---+---+ | | * | | * = centre of a cat +---+---+---+ The middle cell predicts the cat box | | | | +---+---+---+
Measuring Performance
Mean Average Precision, or mAP, summarizes detector quality across all classes and confidence levels. A higher mAP means more correct boxes with fewer mistakes. Frames per second measures speed.
Real-World Uses
- Driver-assistance systems that spot pedestrians and road signs
- Retail shelf monitoring that counts products
- Medical imaging that highlights regions for expert review
- Warehouse robots that find and pick packages
- Wildlife cameras that count animal species
Key Terms
- Bounding box - a rectangle around an object
- IoU - overlap score between two boxes
- Anchor box - a preset box shape used for proposals
- Non-maximum suppression - removal of duplicate boxes
- mAP - the standard accuracy score for detectors
