Sub topic 11
Feature Pyramids for Objects of Different Sizes
Assume you understand convolutional neural networks, feature maps, and gradient-based training. This chapter explains how a detector uses several feature-map resolutions so it can detect both small and large objects.
Why one feature map is not enough
A backbone network, such as ResNet, repeatedly reduces an image's spatial size. Early layers contain detailed edges and textures. Later layers cover larger parts of the image and contain stronger semantic information, such as “this region may contain a car.”
This creates a problem:
- A large object remains visible in a deep, low-resolution feature map.
- A small object may disappear when repeated downsampling reduces it to only a few cells.
- An early, high-resolution map preserves location detail but has weaker semantic information.
A feature pyramid combines these strengths. It creates feature maps at several resolutions, then gives the detector a prediction head at each level.
How a feature pyramid is built
A common design is the Feature Pyramid Network, or FPN. It uses a bottom-up path from the backbone and a top-down path that sends semantic information toward higher-resolution maps.
At each level:
- A backbone feature map is reduced in size and becomes more semantic.
- The next deeper feature map is upsampled, usually by a factor of two.
- A lateral connection projects the corresponding backbone map to the same channel count.
- The two maps are added.
- A small convolution produces the final pyramid feature.
The lateral connection matters because the backbone maps can have different channel counts. A 1 × 1 convolution changes the number of channels without changing spatial resolution.
The resulting maps are often named P3, P4, and P5. P3 has the highest spatial resolution and is useful for small objects. P5 has the lowest resolution and is useful for large objects. Some systems add P6 or P7 for even larger receptive fields.
Assigning objects to pyramid levels
A detector can run the same prediction head on every pyramid level. Each level sees objects at a different scale. In anchor-based detectors, anchors at a level have sizes suited to that level. In anchor-free detectors, the training rule can assign an object to a level based on its size.
| Pyramid level | Relative resolution | Typical target |
|---|---|---|
| P3 | High | Small objects |
| P4 | Medium | Medium objects |
| P5 | Low | Large objects |
This division reduces the burden on any single feature map. A small object gets enough cells for the model to localize it, while a large object can use a map with a wider effective receptive field.
Common errors and trade-offs
Upsampling does not recreate information that was lost during downsampling. The top-down path only combines deep semantic information with detail that still exists in the lateral map.
Feature pyramids also increase memory use and computation because several maps must be stored and processed. Poor level assignment can cause an object to be too large for one map or too small for another. The assignment thresholds should match the image sizes and object distribution in the dataset.
Exercise
Why is a high-resolution pyramid level usually preferred for detecting small objects?
Show answer
A high-resolution level has more spatial cells across the object, so the detector retains more location and shape detail while predicting its box.