Feature pyramid network

Also known as: FPN

On this page 7

A feature pyramid network (FPN) is a neural network architecture that builds a multi-scale set of feature maps from a single image, where every level carries strong semantic information and spatial detail suited to its resolution. In computer vision, it serves as the neck between a backbone and a detection or segmentation head, and it became a standard component of modern artificial intelligence systems for object detection after its introduction in 2017.

The core problem an FPN solves is scale variation: a pedestrian may occupy 20 pixels in one photo and 600 pixels in another. Earlier detectors either processed a costly image pyramid or predicted from one coarse feature map, so they missed small objects. FPN delivers multi-scale features at a modest extra cost, typically 10 to 20 percent more computation than the backbone alone.

How a feature pyramid network combines scales

An FPN works by merging two information flows: a bottom-up pathway, which is the ordinary forward pass of a backbone such as ResNet, and a top-down pathway joined to it by lateral connections. Deep layers know what objects are but have coarse resolution, while shallow layers know precisely where edges are but carry weak semantics. FPN gives every level both.

  1. The backbone produces stage outputs C2 to C5 at strides of 4, 8, 16 and 32 pixels.
  2. A 1×1 convolution projects each stage to a common width, usually 256 channels.
  3. Starting from the deepest level, the map is upsampled by a factor of two with nearest-neighbor interpolation and added element-wise to the next lateral projection.
  4. A 3×3 convolution smooths each merged map to reduce upsampling artifacts, producing outputs P2 to P5.
  5. Many detectors add P6 and P7 by strided convolution to cover very large objects.

The following table summarizes the standard pyramid levels and the object sizes each one typically serves. The object-to-level assignment follows these strides, so a level responds mainly to objects of matching size.

LevelStrideResolution for 800 px inputTypical object size
P24200 x 200Below 32 px
P38100 x 10032 to 64 px
P41650 x 5064 to 128 px
P53225 x 25128 to 256 px
P66413 x 13Above 256 px
Standard FPN levels with a 224-pixel canonical size

Why shared heads and level assignment matter

Because every pyramid level has the same channel width, one prediction head can be shared across all levels. A shared head sees many more training examples per parameter and treats a small object at P3 the same way as a large object at P5, which is a form of scale equivariance.

In two-stage detectors such as Faster R-CNN, region proposals are assigned to a level by the rule k = floor(4 + log2(sqrt(wh) / 224)), so a region of 224 by 224 pixels maps to P4. In one-stage detectors such as RetinaNet, anchor boxes of different sizes are attached to different levels, typically from 32 pixels at P3 to 512 pixels at P7. This assignment is what turns a feature hierarchy into an effective multi-scale detector.

FPN compared with other multi-scale strategies

FPN is one of several answers to scale variation, and its value is clearest next to the alternatives. The table compares cost, accuracy on small objects and semantic quality of each approach.

ApproachHow it handles scaleCostSmall-object accuracy
Featurized image pyramidRuns the network on several resized imagesVery highStrong
Single feature mapPredicts only from the deepest layerLowWeak
Pyramidal hierarchy (SSD style)Predicts from several backbone layers directlyLowModerate, shallow levels lack semantics
Feature pyramid networkTop-down fusion with lateral connectionsLow to moderateStrong
PANet and BiFPNAdds bottom-up or weighted bidirectional fusionModerateStronger
Multi-scale strategies in object detection

Later designs refine the idea rather than replace it. PANet adds a second bottom-up path so localization detail travels upward faster, NAS-FPN searches the fusion topology automatically, and BiFPN in EfficientDet uses learned weights to balance inputs. Even transformer-based backbones such as Swin Transformer and ViTDet feed a pyramid-style neck.

Where feature pyramid networks are used

FPN is a task-agnostic neck, so it appears wherever dense predictions must cover many scales. The table lists the main applications and what each one gains from the pyramid.

TaskRepresentative modelBenefit of the pyramid
Two-stage object detectionFaster R-CNN with FPNBetter proposals and RoI features for small objects
One-stage object detectionRetinaNet, FCOSDense anchors or points on every level
Instance segmentationMask R-CNNSharper masks from high-resolution levels
Panoptic segmentationPanoptic FPNOne neck shared by semantic and instance branches
Scene text detectionSegmentation-based text detectorsHandles text lines of very different heights
Typical applications of FPN

In practice, engineers choose the number of levels and the channel width to match their data. Datasets with many tiny objects, such as aerial imagery, benefit from keeping P2 active, while datasets with large objects can drop P2 to save memory and latency.

Limitations and common mistakes

FPN is not free, and several of its weaknesses are well documented. The most frequent problems and their usual fixes are shown below, because misconfigured pyramids cause many silent accuracy losses.

SymptomLikely causeTypical fix
Small objects still missedP2 removed or anchors too largeRestore P2 or reduce minimum anchor size
High GPU memory useLarge P2 maps at high input resolutionUse P3 to P7 or lower input size
Aliasing at object edgesMissing 3×3 smoothing after upsamplingKeep the output convolutions
Unbalanced training across levelsMost positives fall on one levelAdjust level assignment or loss weighting
Frequent FPN problems and remedies

A subtler limitation is the one-directional information flow: deep semantics reach shallow levels, but precise localization cues travel up only through the long backbone path. This motivated PANet and BiFPN. Another common misconception is that FPN alone fixes small-object detection; in reality, input resolution, anchor design and annotation quality often matter just as much.

The idea in brief

A camera picture can contain a distant bird and a nearby car at once. A feature pyramid network helps a computer look at both sizes well. It takes what the deep layers of a network understand and passes that understanding down to the detailed layers.

Think of a map service. The zoomed-out view shows which city you are in. The zoomed-in view shows single streets. FPN combines both views at every zoom level. The result is that small and large objects are found reliably, without running the network several times.

A practical scenario

A team building a traffic monitoring system must detect vehicles and pedestrians from a camera mounted on a tall pole. In each 1920 by 1080 frame, nearby trucks cover more than 400 pixels, while pedestrians at the far end of the crossing cover only 15 to 25 pixels. Their first detector, which predicted from a single stride-16 map, found the trucks but missed most distant pedestrians.

The engineers switched to a ResNet-50 backbone with an FPN neck and kept levels P2 to P6 with 256 channels. Pedestrians were now handled by the high-resolution P2 and P3 maps, while trucks fell on P5 and P6. Recall for small pedestrians rose substantially, and the added neck increased inference time by roughly 12 percent, which still met the target of 25 frames per second on the deployed GPU.