Elamur Research

Focal Loss for Dense Object Detection

Paper · 2017 · Tsung-Yi Lin, Priya Goyal, Ross Girshick et al.

Summary

Dense one-stage object detectors score a regular grid of candidate boxes in a single pass. They are simpler and faster than two-stage systems such as Faster R-CNN, which first narrow the image down to a small set of proposals, but they have been less accurate.

The authors trace this gap mainly to class imbalance during training. A dense detector evaluates on the order of 100k locations per image, and almost all of them are easy background. These easy negatives dominate the cross-entropy loss and its gradient.

Their fix is the Focal Loss. It multiplies cross entropy by a factor (1 − p_t)^γ that fades toward zero as the model becomes confident in the correct class. Training therefore concentrates on hard, misclassified cases, with no sampling heuristics or hard example mining.

To test the loss, they build RetinaNet, a plain detector with an in-network feature pyramid and anchor boxes. On COCO test-dev, RetinaNet with a ResNet-101-FPN backbone reaches 39.1 AP at 5 fps, ahead of all earlier single-model one-stage and two-stage detectors. The broader lesson is that changing the training objective, rather than the architecture, closed a long-standing accuracy gap.

Key points

  • Scale of the imbalance: foreground to background can be around 1:1000. A one-stage detector scores ~100k locations, while a two-stage proposal stage keeps only about 1–2k candidates and then samples them at a fixed 1:3 foreground-to-background ratio or uses OHEM.
  • Loss settings: γ = 2 worked best, combined with an α-balanced weight (α = .25). With γ = 2, an example at p_t = 0.9 gets 100× lower loss than under CE, and one at p_t ≈ 0.968 gets 1000× lower.
  • Form of the loss is not crucial: in Table 3 (RetinaNet-50-600), CE gives 31.1 AP, FL gives 34.0 AP, and the alternative FL* gives 33.8–33.9 AP.
  • Comparison with other detectors: RetinaNet-101-800 scores 39.1 AP versus 33.2 for DSSD, the closest one-stage rival, a 5.9-point gap. It is also 2.3 points above the best Faster R-CNN (Inception-ResNet-v2-TDM). A ResNeXt-32x8d-101-FPN backbone adds 1.7 AP, and an improved variant reaches 40.8 AP.
  • Anchor ablation and code: a single square anchor already gives 30.3 AP, and 3 scales × 3 aspect ratios raise this to 34.0. Going beyond 6–9 anchors brought no further gain. Code is released in Detectron.

Interesting ideas

  • I1. Instead of throwing away or subsampling easy examples, scale each example's loss smoothly by how confident the model already is, so trivial cases fade out without any hand-tuned sampling rule.
  • I2. The paper contrasts focal loss with robust losses such as Huber: robust losses suppress hard outliers, while focal loss suppresses easy inliers, so the right choice depends on whether hard cases are noise or signal.
  • I3. Class-frequency weighting (α) and difficulty weighting (γ) are treated as separate knobs, because balancing positives against negatives does not tell easy cases from hard ones.
  • I4. The authors back their claim by swapping in a differently shaped loss (FL*) that shares the same property and showing it performs about the same, so the effect comes from the property rather than the exact formula.
  • I5. The anchor ablation shows accuracy saturates after a modest number of candidates per location, so denser enumeration bought nothing.

For Mova

How these ideas could serve Mova, our small open language model — its files, stages and tests:

  • I1 (tree): Most arcs in a sentence (determiners, punctuation, adjectives on nouns) are trivial for gparse. A focal-style arc and label loss could push its training budget toward PP attachment, coordination and other hard decisions.
  • I2 (learn): On silver data, a hard example may be a real difficulty or a wrong label. Applying focal weighting only where the witness parsers agree, and robust down-weighting where they disagree, would keep the two cases apart.
  • I3 (frames): When assigning VerbNet roles, most candidate constituents for a predicate are "no role." Separate frequency and difficulty weights could keep a role classifier from collapsing to "none" while still learning rare roles.
  • I4 (learn): When a training trick seems to help, Mova's evaluation could include an alternative with the same property and a negative control without it, to confirm which ingredient actually matters.
  • I5 (world): When enumerating candidate antecedents or entity links for a mention, measuring where accuracy plateaus could justify a small, cheap candidate set instead of an exhaustive one.

Our summary of the paper, in our own words — not its text. The work belongs to its authors; read it at the links above.

 Institutions

 Fields, topics and concepts

Cite

Cite as Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He and Piotr Dollár. 2017. Focal Loss for Dense Object Detection. arXiv:1708.02002.

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.48550/arxiv.1708.02002 · arXiv 1708.02002

@misc{lin2017focal,
  title = {{Focal Loss for Dense Object Detection}},
  author = {Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He and Piotr Dollár},
  year = {2017},
  doi = {10.48550/arxiv.1708.02002},
  eprint = {1708.02002},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.48550/arxiv.1708.02002}
}

References

39 references, from the paper's own bibliography.

  1. S. Bell, C. L. Zitnick, K. Bala, and R. Girshick. Inside-outside net: Detecting objects in context with skip pooling and recurrent neural networks. In CVPR, 2016. our card
  2. S. R. Bulo, G. Neuhold, and P. Kontschieder. Loss max-pooling for semantic image segmentation. In CVPR, 2017. OpenAlex ↗ · Scholar ↗
  3. J. Dai, Y. Li, K. He, and J. Sun. R-FCN: Object detection via region-based fully convolutional networks. In NIPS, 2016. OpenAlex ↗ · Scholar ↗
  4. N. Dalal and B. Triggs. Histograms of oriented gradients for human detection. In CVPR, 2005. OpenAlex ↗ · Scholar ↗
  5. P. Dollár, Z. Tu, P. Perona, and S. Belongie. Integral channel features. In BMVC, 2009. OpenAlex ↗ · Scholar ↗
  6. D. Erhan, C. Szegedy, A. Toshev, and D. Anguelov. Scalable object detection using deep neural networks. In CVPR, 2014. OpenAlex ↗ · Scholar ↗
  7. M. Everingham, L. Van Gool, C. K. Williams, J. Winn, and A. Zisserman. The PASCAL Visual Object Classes (VOC) Challenge. IJCV, 2010. OpenAlex ↗ · Scholar ↗
  8. P. F. Felzenszwalb, R. B. Girshick, and D. McAllester. Cascade object detection with deformable part models. In CVPR, 2010. OpenAlex ↗ · Scholar ↗
  9. C.-Y. Fu, W. Liu, A. Ranga, A. Tyagi, and A. C. Berg. DSSD: Deconvolutional single shot detector. arXiv:1701.06659, 2016. OpenAlex ↗ · Scholar ↗
  10. R. Girshick. Fast R-CNN. In ICCV, 2015. OpenAlex ↗ · Scholar ↗
  11. R. Girshick, J. Donahue, T. Darrell, and J. Malik. Rich feature hierarchies for accurate object detection and semantic segmentation. In CVPR, 2014. our card
  12. R. Girshick, I. Radosavovic, G. Gkioxari, P. Dollár, and K. He. Detectron. https://github.com/facebookresearch/detectron, 2018. OpenAlex ↗ · Scholar ↗
  13. T. Hastie, R. Tibshirani, and J. Friedman. The elements of statistical learning. Springer series in statistics Springer, Berlin, 2008. OpenAlex ↗ · Scholar ↗
  14. K. He, G. Gkioxari, P. Dollár, and R. Girshick. Mask R-CNN. In ICCV, 2017. OpenAlex ↗ · Scholar ↗
  15. K. He, X. Zhang, S. Ren, and J. Sun. Spatial pyramid pooling in deep convolutional networks for visual recognition. In ECCV. 2014. OpenAlex ↗ · Scholar ↗
  16. K. He, X. Zhang, S. Ren, and J. Sun. Deep residual learning for image recognition. In CVPR, 2016. our card
  17. J. Huang, V. Rathod, C. Sun, M. Zhu, A. Korattikara, A. Fathi, I. Fischer, Z. Wojna, Y. Song, S. Guadarrama, and K. Murphy. Speed/accuracy trade-offs for modern convolutional object detectors. In CVPR, 2017. OpenAlex ↗ · Scholar ↗
  18. A. Krizhevsky, I. Sutskever, and G. Hinton. ImageNet classification with deep convolutional neural networks. In NIPS, 2012. our card
  19. Y. LeCun, B. Boser, J. S. Denker, D. Henderson, R. E. Howard, W. Hubbard, and L. D. Jackel. Backpropagation applied to handwritten zip code recognition. Neural computation, 1989. OpenAlex ↗ · Scholar ↗
  20. T.-Y. Lin, P. Dollár, R. Girshick, K. He, B. Hariharan, and S. Belongie. Feature pyramid networks for object detection. In CVPR, 2017. our card
  21. T.-Y. Lin, M. Maire, S. Belongie, J. Hays, P. Perona, D. Ramanan, P. Dollár, and C. L. Zitnick. Microsoft COCO: Common objects in context. In ECCV, 2014. our card
  22. W. Liu, D. Anguelov, D. Erhan, C. Szegedy, and S. Reed. SSD: Single shot multibox detector. In ECCV, 2016. OpenAlex ↗ · Scholar ↗
  23. J. Long, E. Shelhamer, and T. Darrell. Fully convolutional networks for semantic segmentation. In CVPR, 2015. our card
  24. P. O. Pinheiro, R. Collobert, and P. Dollar. Learning to segment object candidates. In NIPS, 2015. OpenAlex ↗ · Scholar ↗
  25. P. O. Pinheiro, T.-Y. Lin, R. Collobert, and P. Dollár. Learning to refine object segments. In ECCV, 2016. OpenAlex ↗ · Scholar ↗
  26. J. Redmon, S. Divvala, R. Girshick, and A. Farhadi. You only look once: Unified, real-time object detection. In CVPR, 2016. OpenAlex ↗ · Scholar ↗
  27. J. Redmon and A. Farhadi. YOLO9000: Better, faster, stronger. In CVPR, 2017. our card
  28. S. Ren, K. He, R. Girshick, and J. Sun. Faster R-CNN: Towards real-time object detection with region proposal networks. In NIPS, 2015. our card
  29. H. Rowley, S. Baluja, and T. Kanade. Human face detection in visual scenes. Technical Report CMU-CS-95-158R, Carnegie Mellon University, 1995. OpenAlex ↗ · Scholar ↗
  30. P. Sermanet, D. Eigen, X. Zhang, M. Mathieu, R. Fergus, and Y. LeCun. Overfeat: Integrated recognition, localization and detection using convolutional networks. In ICLR, 2014. our card
  31. A. Shrivastava, A. Gupta, and R. Girshick. Training region-based object detectors with online hard example mining. In CVPR, 2016. our card
  32. A. Shrivastava, R. Sukthankar, J. Malik, and A. Gupta. Beyond skip connections: Top-down modulation for object detection. arXiv:1612.06851, 2016. OpenAlex ↗ · Scholar ↗
  33. K.-K. Sung and T. Poggio. Learning and Example Selection for Object and Pattern Detection. In MIT A.I. Memo No. 1521, 1994. OpenAlex ↗ · Scholar ↗
  34. C. Szegedy, S. Ioffe, V. Vanhoucke, and A. A. Alemi. Inception-v4, inception-resnet and the impact of residual connections on learning. In AAAI Conference on Artificial Intelligence, 2017. OpenAlex ↗ · Scholar ↗
  35. J. R. Uijlings, K. E. van de Sande, T. Gevers, and A. W. Smeulders. Selective search for object recognition. IJCV, 2013. OpenAlex ↗ · Scholar ↗
  36. R. Vaillant, C. Monrocq, and Y. LeCun. Original approach for the localisation of objects in images. IEE Proc. on Vision, Image, and Signal Processing, 1994. OpenAlex ↗ · Scholar ↗
  37. P. Viola and M. Jones. Rapid object detection using a boosted cascade of simple features. In CVPR, 2001. OpenAlex ↗ · Scholar ↗
  38. S. Xie, R. Girshick, P. Dollár, Z. Tu, and K. He. Aggregated residual transformations for deep neural networks. In CVPR, 2017. OpenAlex ↗ · Scholar ↗
  39. C. L. Zitnick and P. Dollár. Edge boxes: Locating object proposals from edges. In ECCV, 2014. OpenAlex ↗ · Scholar ↗

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/lin-2017-focal-loss-dense-object-detection/