An anchor box is a preset reference bounding box, defined by a size and aspect ratio, used to turn object localization into several simpler detection tasks. Rather than asking one detector to handle every possible object shape, a region proposal network (RPN) places multiple anchors at every sliding-window location and lets each specialize in similarly shaped objects. section 11.4.2
Feature-map locations correspond to positions in the input image after downsampling. With a VGG backbone, an input of size (h, w) becomes (h/16, w/16), so each feature-map point is aligned with a 16 × 16 input patch while carrying information from a much larger receptive field. At each such point, anchors span chosen scales and aspect ratios. section 11.4.2
Figure 11.13 The left column shows the various grid-point locations on the output convolution feature original implementation) anchors across multiple sizes and aspect ratios. The right column shows the various anchors at a particular grid point.
Compare the feature-map grid with the differently shaped anchor templates centered at one grid point. section 11.4.2
For an anchor centered at (xa, ya) with width wa and height ha, the RPN predicts four offsets to a target box centered at (x, y) with width w and height h: tx = (x − xa)/wa, ty = (y − ya)/ha, tw = log(w/wa), and th = log(h/ha). Center displacement is normalized by anchor size; width and height are expressed as logarithmic scale changes. Applying predicted offsets reverses this transform to produce a proposal box. section 11.4.2
Generating templates at one grid point
Given a grid-point center, a subsampling factor, scales, and aspect ratios, generate one anchor for every scale–ratio pair. For ratio r, compute w = subsample × scale × sqrt(r) and h = subsample × scale × sqrt(1/r), then convert the centered box into (xtl, ytl, xbr, ybr). Repeating this at every grid point creates anchors for the whole image. section 11.4.2
The RPN predicts an objectness classification and four regression values for every anchor. During training, anchors are compared with ground-truth boxes using intersection over union (IoU), and positive anchors receive regression targets. At inference, decoded anchors are filtered by size and objectness score, then non-maximal suppression removes highly overlapping proposals. section 11.4.2 section 11.5
Anchor boxes make the proposal stage work by separating four linked decisions:
- Cover candidate object geometries with several scales and aspect ratios at each feature-map location. section 11.4.2
- Classify each anchor for objectness and regress an anchor-relative bounding-box correction. section 11.4.2
- Use IoU with ground-truth boxes to assign labels and regression targets during training. section 11.4.2
- Decode corrected anchors into region proposals and de-duplicate them with non-maximal suppression. section 11.4.2
