Sub topic 3
Backbones Turn Pixels into Feature Maps
This chapter assumes you know basic Python, convolutional neural networks, feature maps, classification versus regression, and gradient-descent training. Transformers are not required yet.
An object detector does not usually predict boxes directly from raw pixels. It first passes the image through a backbone, a neural network that converts pixels into increasingly useful feature maps. A feature map is a grid of learned values. Each grid location summarizes visual information from a region of the original image.
A backbone commonly contains convolutional layers, normalization, and nonlinear activation functions. Early layers respond to simple patterns such as edges and color changes. Deeper layers combine these patterns into textures, parts, and object-level evidence.
Spatial resolution and semantic detail
Suppose an input image has height \(H\) and width \(W\). A backbone may reduce its spatial resolution several times:
| Backbone stage | Stride relative to input | Feature-map size for 640 × 640 input |
|---|---|---|
| Early stage | 4 | 160 × 160 |
| Middle stage | 16 | 40 × 40 |
| Deep stage | 32 | 20 × 20 |
Stride is the distance between neighboring feature-map locations measured in input pixels. A stride-16 map has one location for roughly every 16 input pixels.
As resolution decreases, the number of channels usually increases. The map becomes smaller but stores richer semantic information. This creates a trade-off:
- High-resolution maps preserve edges and small objects.
- Low-resolution maps provide larger context and stronger object-level features.
- Very deep maps may miss small details because several input pixels share one location.
The area of the original image that can influence one feature-map location is its receptive field. Larger receptive fields help recognize large objects and interpret ambiguous local patterns.
def feature_map_size(height, width, stride):
"""Compute a feature-map size using integer downsampling."""
return height // stride, width // stride
image = (640, 640)
for stride in (4, 8, 16, 32):
print(stride, feature_map_size(*image, stride))
# 4 (160, 160)
# 8 (80, 80)
# 16 (40, 40)
# 32 (20, 20)Features flow into the detection head
The detector’s head consumes backbone features and predicts class scores and box information. A two-stage detector may use deep features to propose regions before refining them. A one-stage detector may predict many candidates directly from one or more backbone maps.
Using only the deepest map is inefficient for objects of very different sizes. Modern detectors often combine maps from several stages. A feature pyramid network, or FPN, uses lateral connections and upsampling to pass deep semantic information into higher-resolution maps.
When comparing backbones, consider accuracy, speed, memory use, and the smallest objects that must be detected. A larger backbone may produce stronger features but increase latency and deployment cost.
Exercise
Why can a detector benefit from both a stride-4 feature map and a stride-32 feature map?
Show answer
The stride-4 map preserves details needed for small objects, while the stride-32 map has a larger receptive field and stronger semantic information for large or context-dependent objects.