Explain the concept of 'Anchor Boxes' in object detection.
Instruction: Define anchor boxes, explain how an anchor-based detector uses them, and work through the supplied offset example. State important limitations.
For a simplified unweighted box encoder, an anchor has centre (100, 80), width 40 and height 20 pixels. Its matched target has centre (104, 78), width 80 and height 10 pixels. Use tx = (x − xa)/wa, ty = (y − ya)/ha, tw = ln(w/wa), and th = ln(h/ha). All coordinates use the same image frame.
Updated
Example Answer
Anchor boxes are reference rectangles of chosen scales and aspect ratios placed at feature-map locations. An anchor-based detector predicts scores and offsets relative to them. In a Faster R-CNN region proposal network, the score indicates objectness; a later head classifies proposed regions. Training matches anchors to ground-truth boxes using a defined overlap/assignment rule and distinguishes positive, negative and ignored anchors.
For the supplied encoder, tx = 4/40 = 0.1, ty = −2/20 = −0.1, tw = ln(2) and th = ln(0.5) = −ln(2). Decoding gives x = 100 + 0.1×40 = 104, y = 80 − 0.1×20 = 78, w = 40×exp(ln2) = 80 and h = 20×exp(−ln2) = 10. These are regression targets, not confidence scores. The example requires positive widths/heights; real implementations may apply additional encoding weights.
Anchors offer multiple reference shapes at each position, but mismatched shapes, scale coverage and numerous background candidates can make training inefficient. Three scales and three aspect ratios give nine anchors per location; this is a design choice, not nine detected objects. I would evaluate proposal recall, final detection quality and runtime on relevant object sizes. Anchor-free designs also exist, so the implementation must be named; anchors do not guarantee better accuracy.