Sub topic 12
Anchor-Free Detection: FCOS and CenterNet
This chapter assumes you know convolutional neural networks, feature maps, gradient-based training, and basic box coordinates. Familiarity with anchors, IoU, and non-maximum suppression helps, but the goal here is to see how detectors can avoid anchors.
Anchor-based detectors place many reference boxes, called anchors, on feature maps. The model classifies each anchor and predicts an offset from it. Anchor-free detectors remove this reference-box step. They use locations in a feature map, usually pixels or grid cells, as the basic prediction units.
Why remove anchors?
Anchors add design choices:
- Which sizes and aspect ratios should be used?
- How many anchors should cover each feature-map location?
- Which anchors count as positive examples?
- What happens when an object shape does not match any anchor well?
Anchor-free methods replace these boxes with simpler geometric rules. They still need to decide which feature-map locations belong to an object, so they do not remove label assignment entirely.
Feature pyramids are especially useful here. A pyramid provides high-resolution maps for small objects and lower-resolution maps for large objects. Each object is assigned to an appropriate pyramid level.
FCOS: predicting from locations
FCOS, or Fully Convolutional One-Stage detector, treats every feature-map location as a possible object location. At a location inside a ground-truth object, the network predicts:
- A class label.
- Four distances from the location to the box edges: left, top, right, and bottom.
- A centerness score.
Suppose a location has image coordinates (x, y) and the object box has edges (x1, y1, x2, y2). The target distances are:
- left:
x - x1 - top:
y - y1 - right:
x2 - x - bottom:
y2 - y
These four values define the box without an anchor. At inference, the detector converts the distances back into box corners.
Centerness estimates how close the location is to the box center. A location near an edge can predict a valid box, but it is less reliable because small coordinate errors cause larger changes in the box. FCOS uses centerness to reduce the scores of such predictions before final filtering.
CenterNet: detecting object centers
CenterNet uses a different representation. It predicts a heatmap in which each object produces a peak at its center. A heatmap is a grid of scores, with one score for each possible location and class.
The model also predicts:
- The object width and height.
- A small offset that corrects quantization caused by placing centers on a coarse grid.
At inference, CenterNet selects local peaks in the heatmap. For each peak, it reads the width, height, and offset, then constructs a box around the center.
The main distinction is that FCOS assigns many interior locations to an object, while CenterNet focuses on one center point per object.
| Method | Main prediction | Box representation | Duplicate handling |
|---|---|---|---|
| FCOS | Object locations and edge distances | Left, top, right, bottom distances | Usually NMS |
| CenterNet | Object-center heatmap peaks | Center, width, height | Peak selection and often NMS |
| Anchor-based detector | Anchors and offsets | Offset from reference boxes | Usually NMS |
Strengths and failure modes
Anchor-free detectors reduce hyperparameters and can simplify matching. They also avoid forcing the model to choose among many preset aspect ratios.
Their challenges include crowded objects, overlapping centers, and small objects that occupy only a few feature-map cells. FCOS must prevent multiple pyramid levels from claiming the same object. CenterNet can miss an object when its center is hidden, poorly localized, or merged with another object's center.
The choice depends on the data. FCOS is useful when dense interior evidence helps localization. CenterNet is attractive when each object has a clear, separable center.
Exercise
An FCOS location is at (30, 40), and the target box is (10, 20, 50, 80). What are the four edge distances in left, top, right, bottom order?
Show answer
(20, 20, 20, 40). The location is 20 pixels from the left and top edges, 20 pixels from the right edge, and 40 pixels from the bottom edge.