DL0183 Anchor-Free vs Anchor-Based Detection

How do anchor-free object detectors such as FCOS, CenterNet, and CornerNet differ from anchor-based detectors such as Faster R-CNN and YOLOv3 in box parameterization, label assignment, and training stability?

Answer

The whole difference is what the regression head is measured against. An anchor-based head attaches k prior boxes to every feature-map location and predicts four normalized deltas per prior, so a predicted box only exists relative to a tiled prior whose scales and aspect ratios were chosen in advance from dataset statistics. An anchor-free head has no prior: FCOS predicts the four positive distances from a location to the sides of the object it belongs to, while CornerNet and CenterNet predict heatmap peaks (two corners, or one center) plus a small size and offset regression read off at the peak. Because the reference disappears, the matching rule must change too, so IoU thresholds against priors are replaced by spatial containment plus a per-level size range, and modern detectors replace both with prediction-aware dynamic assignment. Training stability shifts rather than simply improving: anchor-free heads drop the unbounded log-space targets and the anchor hyperparameters, but they need centerness or IoU-aware quality weighting, per-level normalization of the distance targets, and an explicit tie-break for locations that fall inside two objects.

(1) Reference Frame: Anchor-based regresses log-space deltas against a discrete prior set, while anchor-free regresses geometry directly in stride units from a location or a keypoint.
(2) Matching Rule: IoU thresholds are replaced by point-in-box containment, and object scale is routed by FPN level size ranges instead of by anchor size.
(3) Candidate Count: Removing k=9 priors per location cuts predictions per level by 9x, which changes the positive/negative ratio the loss has to survive.
(4) Hyperparameter Surface: Scales, aspect ratios, and two IoU thresholds collapse into one set of level ranges plus a center-sampling radius.
(5) Stability Mechanics: Bounded positive distances with a GIoU-style box loss are better conditioned than log deltas, but need per-level scaling or a learnable exponential to keep early gradients sane.
(6) Ambiguity Handling: Two overlapping objects can claim different anchors at the same location, whereas an anchor-free point must be broken by minimum-area assignment, and CenterNet simply collides when two centers land in the same output cell.

Three panels showing the same ground-truth box parameterized three ways: an anchor-based panel with a dashed prior box and an offset arrow to the ground-truth center plus log width and height deltas, an anchor-free panel with a single interior point and four arrows labeled l, t, r, b reaching the four sides, and a keypoint panel with Gaussian peaks at the top-left and bottom-right corners and at the box center with a width-height regression head

Figure 1: The same object, three parameterizations. The anchor head needs a matched prior before its four numbers mean anything, the dense point head predicts four positive distances that are meaningful on their own, and the keypoint head turns detection into peak localization plus a size read-out, so its only remaining prior is the output stride.

Mathematical Formulation:
t_x = (x - x_a) / w_a
t_y = (y - y_a) / h_a
t_w = \log(w / w_a)
t_h = \log(h / h_a)

Anchor-Free Distances And Centerness:
l = (p_x - x_1) / s
t = (p_y - y_1) / s
r = (x_2 - p_x) / s
b = (y_2 - p_y) / s
c_x = \min(l,r) / \max(l,r)
c_y = \min(t,b) / \max(t,b)
c = \sqrt{c_x c_y}

Where:

  • (x,y,w,h) is the predicted box and (x_a,y_a,w_a,h_a) the matched anchor, so the four deltas are undefined without an assignment step.
  • (t_x,t_y,t_w,t_h) are the anchor-based targets; the logarithm makes size ratios additive and keeps targets near zero when the prior already fits, but it is unbounded on both sides for a badly matched prior.
  • p = (p_x, p_y) is the image-space center of a feature location and s its level stride, typically 8 up to 128 across P3 to P7.
  • (x_1,y_1,x_2,y_2) are the ground-truth corners; requiring all four of l, t, r, b > 0 is exactly the point-in-box positive test that replaces the IoU threshold.
  • c \in (0,1] is centerness, multiplied into the classification score at inference so boxes regressed from near an object border are down-ranked before NMS.
  • A point is routed to level j only if \max(l,t,r,b) falls inside that level’s size interval (m_{j-1}, m_j), which is the anchor-free replacement for choosing anchor scales.

Assignment is where the two families really diverge. Faster R-CNN and YOLOv3 label a prediction by measuring IoU between a fixed prior and the ground truth, which needs a positive threshold, a negative threshold, an ignore band in between, and a rescue rule so every object keeps at least its best anchor. FCOS labels by geometry alone, then narrows the positive set with center sampling (only points within a radius of a few strides from the object center), which raises average positive quality without touching IoU at all. Keypoint methods go further and effectively skip matching: CenterNet splats a Gaussian at the object center on a stride-4 heatmap and treats the single peak cell as the only positive, which is why it needs no NMS but breaks when two centers quantize to the same cell. The lineage since then is a steady handover of the assignment decision from hand-set priors to the model itself: fixed anchors → dense point containment → adaptive statistics in ATSS → prediction-aware costs in SimOTA and TOOD.

Three 12 by 8 feature grids with the same ground-truth box overlaid. The first grid shows dashed anchor boxes of three aspect ratios at one cell and twelve shaded positive cells selected by an IoU threshold. The second grid shades all twenty cells whose centers fall inside the box in light gray and highlights the central three by three block kept by center sampling. The third grid highlights six irregularly placed cells chosen by a prediction-aware cost.

Figure 2: One box, three positive sets. IoU matching scores 9 anchors per cell and keeps a handful, so the imbalance is roughly 1:71 here; center sampling keeps 9 of 96 points with no IoU computation at all; dynamic top-k chooses a variable number of positives from the model’s own cost, which removes thresholds but makes the label set change as training proceeds.

Candidate Count On A RetinaNet-Style FPN (800 x 1024 Input):
12800 + 3200 + 800 + 208 + 56 = 17064
A_{\mathrm{anchor}} = 9 \times 17064 = 153576
A_{\mathrm{free}} = 17064

The count explains most of the practical differences. With about 154k anchors and a few dozen positives per image, an anchor-based one-stage head lives or dies on focal loss or a mined 1:3 negative ratio, and it pays memory and time for an IoU matrix between every anchor and every ground-truth box. Dropping to 17k points removes that matrix, cuts head parameters by the same factor, and makes the box branch predict bounded, strictly positive quantities that pair naturally with an IoU or GIoU loss instead of a smooth-L1 on log deltas. The cost is that scale and ambiguity handling become explicit design choices: level size ranges decide which stride sees an object, and a point inside two boxes is assigned to the smaller-area ground truth, a rule that still degrades on heavily nested or crowded scenes.

PropertyAnchor-based (Faster R-CNN, YOLOv3)Anchor-free dense point (FCOS, ATSS)Keypoint (CenterNet, CornerNet)
Box parameterizationFour deltas per prior, width and height in log spaceFour positive distances to the sides, in stride unitsHeatmap peak plus regressed size and sub-pixel offset
Positive assignmentIoU above 0.5 to 0.7, ignore band, best-anchor rescuePoint inside the box, narrowed by center samplingExactly one peak cell per object, Gaussian-weighted focal loss
Scale handlingAnchor scales and aspect ratios per level, tuned on the datasetFPN level size ranges on max(l, t, r, b)Single high-resolution stride-4 map, no level routing
Candidates per imageAbout 154k for 9 anchors on P3 to P7About 17k, one prediction per locationOne 200 x 256 heatmap per class
Quality calibrationObjectness or class score, optionally IoU predictionCenterness or IoU branch multiplied into the scorePeak value itself acts as the confidence
Duplicate removalNMS, mandatory because many priors fire per objectNMS, since several nearby points stay positive3 x 3 max-pool peak extraction, no IoU-based NMS
Dominant failure modeUnusual aspect ratios or tiny objects match no prior, so recall drops silentlyAmbiguous points in overlapping boxes, resolved only by min-areaTwo centers colliding in one stride-4 cell, or wrong corner grouping

Login to view more content


Log in to track your progress

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *