Profile

Settings

Loading…

← Papers

Help

FAQ

Which features require signing in?

You can read the commentary, paper info, Model Structure and related papers of public papers without signing in. Sign in to manage your account or contact us about your inquiries.

Can I upload a PDF file?

Upload papers with an arXiv or DOI link; the commentary is public to everyone. Papers whose source and terms of use can't be verified, so the commentary can't be made public, can't be uploaded. Uploading PDF files and keeping papers private are for subscribers only, and a paper uploaded as a file is saved as private only. Searching for official info by title runs only when you press the button.

Are the figures and AI commentary accurate?

Figures come only from the original paper, and only those whose terms of use are verified are shown. The commentary is written by AI and may be wrong. Check important claims, numbers and figure context against the evidence in the original paper.

I want to report a copyright issue.

Terms of use and the source of the original paper are on the Paper info tab. If there's a problem, choose "Paper content, figures and copyright" under Contact us and send the paper link, the part in question, and evidence that you hold the rights. Receiving your report doesn't confirm any rights or remove anything right away. You can see the result of the review under My inquiries.

I forgot my password.

If you signed up with email, use Forgot password in the sign-in window to reset it with your verified email. If you signed up with Google, Naver or Kakao, change your password with that service.

What should I include in an inquiry?

Tell us which screen you were on and what you were doing when the problem happened, along with the paper link. Don't include personal information such as passwords, API keys, verification codes or phone numbers. Inquiries and replies are stored in Refivu and you can see them under My inquiries.

How do I delete my account?

In Settings, under My account, press Delete account. Review what will be deleted and complete identity verification to delete your account. For other requests, choose "Account" under Contact us.

Paper commentary

Focal Loss for Dense Object Detection

Focal loss lets one-stage detectors match two-stage accuracy

  • Problem One-stage detectors have trailed two-stage accuracy because easy background locations overwhelm training. Most of the roughly 100k locations per image are easy negatives.
  • Method Focal loss multiplies cross entropy by a factor that shrinks as confidence in the correct class grows. So easy examples lose most of their loss while hard examples keep theirs.
  • Results Focal loss scored 36.0 AP with ResNet-101-FPN, compared to 32.8 for the best OHEM variant.

Why dense one-stage detectors fall behind

Two-stage detectors first narrow the image to a small set of candidate locations, often 1-2k, and then classify only those. Sampling rules such as a fixed 1:3 foreground-to-background ratio or online hard example mining keep the remaining imbalance manageable. A one-stage detector has no such filter, so it must score a much larger grid of locations.

In practice that grid holds about 100k locations per image, and only a few of them contain objects. Most of those locations are easy negatives that give training little useful signal. Summed over so many examples, their small losses can overwhelm the rare class and lead to degenerate models. Sampling heuristics help, but training still stays dominated by easy background examples.

The authors identify this class imbalance as the main obstacle keeping one-stage detectors from matching two-stage accuracy. So the question becomes whether a change to the loss, rather than to the network design, can remove that obstacle.

Reshaping cross entropy with a modulating factor

The key idea is to keep cross entropy but multiply it by a factor that shrinks as the model grows confident in the correct class. The authors start from binary cross entropy, which takes the negative log of the probability the model gives the true class. They write p_t for that probability, so the loss reads as \( \mathrm{CE}(p_t) = -\log(p_t) \).

Alpha balances the two classes but treats easy and hard examples alike, and that is the gap the focal loss targets.

The focal loss multiplies cross entropy by a modulating factor (1 minus p_t) raised to gamma, with gamma at least 0, giving \( \mathrm{FL}(p_t) = -(1-p_t)^{\gamma}\log(p_t) \). When p_t is small the factor stays near 1, so a misclassified example keeps almost its full loss. As p_t approaches 1 the factor goes to 0, so confident examples lose most of their loss.

With gamma equal to 2, an example at p_t = 0.9 gets a loss 100 times lower than cross entropy gives, and at about 0.968 the reduction is 1000 times. Gamma is the single knob: at gamma 0 the loss is cross entropy, and larger values discount easy examples more.

The loss layer computes the sigmoid together with the loss, which gives better numerical stability. The exact form is not treated as crucial, and the appendix introduces an alternative, FL*, that behaves similarly. On RetinaNet-50-600, FL* with gamma 2 and beta 1 scored 33.8 AP, compared to 34.0 for focal loss at gamma 2. The authors read this as evidence that any loss with similar properties should work equally well.

RetinaNet's pyramid, anchors and subnets

RetinaNet places the focal loss on a single dense detector that scores anchors in one pass. A ResNet backbone feeds a Feature Pyramid Network, and two small subnetworks sit on every pyramid level. One subnetwork classifies anchors and the other regresses box offsets, and the two do not share parameters.

Each location gets nine anchors, made of three aspect ratios at three scales. An anchor is positive when its IoU with a ground-truth box meets the 0.5 threshold, background when its IoU is below 0.4, and ignored in between.

The classification subnet applies four 3x3 convolutions with 256 filters and ReLU, then a 3x3 convolution with K times A filters and sigmoid outputs. The box subnet has the same structure but ends in 4A linear outputs, one set of offsets per anchor. Its regressor is class-agnostic, which the authors found uses fewer parameters with equal effect.

The authors say these higher-level choices mattered more than the exact values of individual hyperparameters.

Training applies the focal loss to every anchor in the image, around 100k of them, instead of a sampled subset of 256. The summed loss is divided by the number of anchors assigned to ground-truth boxes, not by the total anchor count, because most anchors are easy negatives with negligible loss. The bias of the final classification layer is set so that each anchor starts at foreground probability pi = 0.01, using \( b = -\log((1-\pi)/\pi) \).

The training loss adds the focal loss to the smooth L1 box loss, and synchronized SGD runs over 8 GPUs with 16 images per minibatch. The default schedule runs 90k iterations from learning rate 0.01, dividing by 10 at 60k and again at 80k.

At inference the image passes through the network once. Each pyramid level keeps at most 1k top predictions above confidence 0.05, and non-maximum suppression at 0.5 produces the final detections.

Does focal loss beat cross entropy and OHEM?

Plain cross entropy with no changes to initialization made training diverge. Setting the prior foreground probability to 0.01 in the last layer made learning work, and ResNet-50 then got 30.2 AP. So initialization alone can rescue cross entropy, which makes the later gap to focal loss the more telling comparison.

The authors note that changing gamma matters more than the choice of alpha. Pushing gamma to 5 dropped AP to 32.2, so the gain has a range.

Online hard example mining keeps only the highest-loss examples, so it discards easy ones entirely. Focal loss scored 36.0 AP with ResNet-101-FPN, a 3.2-point gap that suggests down-weighting easy examples works better than discarding them. The 1:3 OHEM variant did worse, and its best row scored 31.1 AP.

For positives, the normalized loss curves look much alike across gamma values, so the focusing has little effect there. For negatives, a larger gamma concentrates the loss on a small fraction of hard samples. This is one converged model, so the result describes that model only.

Anchor density and the speed-accuracy trade-off

The authors varied anchors per location, from one square anchor up to 12 spanning scales and aspect ratios. A single square anchor already scored 30.3 AP with ResNet-50, while 3 scales and 3 aspect ratios raised it to 34.0 AP. Beyond about 6 to 9 anchors the authors saw no further gain, so coverage saturates.

Larger backbones and larger image scales raise accuracy and also slow inference. With ResNet-50-FPN, AP rose from 30.5 at a 400-pixel scale to 35.7 at 800 pixels, and time rose from 64 ms to 153 ms. RetinaNet-101-600 ran in 122 ms per image, compared to 172 ms for the ResNet-101-FPN Faster R-CNN, both measured on an Nvidia M40 GPU. The authors say this matches the Faster R-CNN accuracy at that point, while larger scales surpass it and remain faster.

Test-dev results against other detectors

Table 2 lists single-model test-dev results, and the comparisons use public numbers from other work. The ResNet-101-FPN RetinaNet, trained with scale jitter for 1.5× longer, scored 39.1 AP.

Compared to Faster R-CNN with Inception-ResNet-v2-TDM at 36.8 AP, the top two-stage row, RetinaNet is 2.3 points higher. Swapping in a ResNeXt-101-FPN backbone raised the score to 40.8 AP. The authors credit the loss rather than the network design, since the detector itself is deliberately simple.

Limits of the evidence

An early attempt with a hinge loss on pt was unstable and gave no meaningful results. The authors call the multi-class extension straightforward but keep the study to the binary loss. Ablations use an image scale of 600 pixels, while the headline test-dev numbers come from larger scales and longer training. Anchor gains saturate beyond 6 to 9 anchors, and no operating point is given for the high frame-rate regime, which the authors leave to future work.

The speed comparisons use public numbers from other papers, so they are not controlled experiments.

Paper info

Authors
Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, Piotr Dollár
Venue
arXiv · Preprint
First published
2017-8-7
Added
2026-11-6
Updated
2018-2-7
Version
v2
arXiv
1708.02002
Category
cs.CV
Original paper terms
arXiv non-exclusive 1.0
What we show
Paper info and commentary

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

Quote from the paper

Tsung-Yi Lin, Priya Goyal, Ross Girshick, Kaiming He, Piotr Dollár (2017). Focal Loss for Dense Object Detection. arXiv:1708.02002v2. https://arxiv.org/abs/1708.02002v2

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

See related papersBrowse other papers

Paper preview
Account security

Connect Google account

If you connect a Google account, you can sign in with it too.

Refivu

Delete account

Refivu
Refivu

Sign up