Computer Vision Lab Models RetinaNet ResNet-50 FPN
RetinaNet ResNet-50 FPN
One-stage detector, FPN P3–P7, focal loss
Knowledge card: the first one-stage detector to match the accuracy of two-stage detectors, thanks to the Focal Loss, which addresses the huge imbalance between background and foreground anchors. The published value is for the first torchvision weights (V1).
| Architecture | One-stage detector, FPN P3–P7, focal loss |
|---|---|
| Task | Object detection |
| Training data | COCO 2017 |
| the number of parameters | 34,014,999 |
| Framework | PyTorch (torchvision) |
| File size | ≈130 MB |
| Licence | BSD-3-Clause (torchvision code); weights trained on COCO 2017 |
| Where it runs | Knowledge card only |
| Official source | pytorch.org |
| Official weights | download.pytorch.org |
Published metrics (from the official source, not measured by this site)
| Metric | Value | Evaluation data | Source |
|---|---|---|---|
| box mAP | 36.4 | COCO val2017 | Source |
Architecture diagram
- Input / output
- Convolutional layer
- Composite block
- Memory / intermediate features
- Output head
- Loss / training only
Detailed model explanation
Idea and intuition
Lin and colleagues observed that one-stage detectors were less accurate than two-stage ones, and attributed the main cause to the severe imbalance between examples: each image has tens of thousands of anchors, most of them easy background. These many easy examples dominate the total loss even if each one's loss is small. So they proposed the «Focal Loss», which automatically down-weights well-classified examples, and built RetinaNet to prove that a one-stage detector can match a two-stage one.
Architecture
- A ResNet backbone with an FPN pyramid at levels P3–P7.
- Nine anchors per location (3 scales × 3 ratios).
- Two small subnetworks shared across levels: a classification branch (four 3×3 convolutions then
KAoutputs with sigmoid) and an independent box regression branch with the same structure. - Initialising the bias of the last classification layer so that probabilities start small (
\pi=0.01), so the loss does not explode at the start of training.
Mathematical formulation
\mathrm{FL}(p_t) = -\alpha_t\,(1-p_t)^{\gamma}\,\log(p_t),\qquad p_t=\begin{cases}p & y=1\\ 1-p & y=0\end{cases}When \gamma=0 The loss reduces to weighted cross-entropy. With \gamma=2 (the value chosen in the paper with \alpha=0.25) the weight of an example whose correct probability is 0.9 drops by a factor of (0.1)^2=0.01, so learning focuses on hard examples.
Performance
The torchvision release RetinaNet ResNet-50 FPN (v1): about 34 million parameters and box mAP = 36.4 on COCO val2017.
Strengths and limitations
- Strength: the focal loss is a general idea that spread to detection, medical segmentation and imbalanced classification problems.
- Strength: a simple one-stage architecture.
- Limitation: still relies on anchors and NMS.
- Limitation: the two prediction heads are relatively heavy on high-resolution levels.
Uses
General detection, the basis for many later detectors, detection in medical images.
Runtime requirements
—
How to load
Not loaded in the lab (knowledge card).
References
- T.-Y. Lin, P. Goyal, R. Girshick, K. He, P. Dollár (2017).Focal Loss for Dense Object Detection. arXiv:1708.02002 (ICCV 2017). doi:10.48550/arXiv.1708.02002
- T.-Y. Lin, P. Dollár, R. Girshick, K. He, B. Hariharan, S. Belongie (2016).Feature Pyramid Networks for Object Detection. arXiv:1612.03144 (CVPR 2017). doi:10.48550/arXiv.1612.03144
- T.-Y. Lin et al. (2014).Microsoft COCO: Common Objects in Context. ECCV 2014 (LNCS 8693). doi:10.1007/978-3-319-10602-1_48
