Varifocal Loss: Learning IoU-Aware Classification Scores for Detection

· 2 min read · 382 words

Authors

Varifocal Loss (VFL) trains a dense object detector to predict an IoU-aware classification score: a score that represents both the presence of an object and the localization quality of its predicted box.

For the target class, the training target qq is the IoU between the predicted box and its matched ground-truth box. For background and non-target classes, q=0q=0. If pp is the predicted class probability, the paper defines

VFL(p,q)={q(qlogp+(1q)log(1p)),q>0,αpγlog(1p),q=0.\operatorname{VFL}(p,q) = \begin{cases} -q\left(q\log p + (1-q)\log(1-p)\right), & q > 0, \\ -\alpha p^{\gamma}\log(1-p), & q = 0. \end{cases}
Loading diagram…

Why it differs from focal loss

Focal loss was designed to reduce the influence of numerous easy negatives. Varifocal Loss keeps that behavior for negatives through pγp^\gamma, but treats positives asymmetrically:

  • Positive targets are continuous IoU values rather than one-hot labels.
  • High-quality positives receive more weight through the outer factor qq.
  • Positive examples are not down-weighted with the focal factor used for negatives.

This trains the classification score itself to rank well-localized boxes above poorly localized ones. That alignment matters because detectors select top candidates and apply non-maximum suppression using their scores.

Numerical and training details

The paper uses α=0.75\alpha=0.75 and γ=2.0\gamma=2.0 in its main experiments. Those values belong to its detector and training recipe rather than to the mathematical definition, so a different detector or assignment strategy may need different settings.

Scope

Varifocal Loss was proposed as one part of VarifocalNet, alongside a star-shaped feature representation and box-refinement branch. Do not attribute the detector's complete reported improvement to the loss alone: the paper's ablation separates these components.

Primary source