Balance-Oriented Focal Loss with Linear Scheduling for Anchor Free Object Detection

Hopyong Gil, Sangwoo Park, Yusang Park, Wongoo Han, Juyean Hong, June-Young Jung · DOI

Abstract

Most existing object detectors suffer from class imbalance problems that hinder balanced performance. In particular, anchor free object detectors have to solve the background imbalance problem due to detection in a per-pixel prediction fashion as well as foreground imbalance problem simultaneously. In this work, we propose Balance-oriented focal loss that can induce balanced learning by considering both background and foreground balance comprehensively. This work aims to address imbalance problem in the situation of using a general unbalanced data of non-extreme distribution not including few shot and the focal loss for anchor free object detector. We use a batch-wise alpha-balanced variant of the focal loss to deal with this imbalance problem elaborately. It is a simple and practical solution using only re-weighting for general unbalanced data. It does require neither additional learning cost nor structural change during inference and grouping classes is also unnecessary. Through extensive experiments, we show the performance improvement for each component and analyze the effect of linear scheduling when using re-weighting for the loss. By improving the focal loss in terms of balancing foreground classes, our method achieves AP gains of +1.2 in MS-COCO for the anchor free real-time detector.

Introduction

Anchor-free object detectors, such as CenterNet and FCOS, have gained popularity due to their speed and architectural simplicity. However, these models face a dual challenge of class imbalance. First, the background vs. foreground imbalance is exacerbated because anchor-free models predict objects per-pixel, leading to a vast majority of background samples. Second, foreground vs. foreground imbalance arises from the natural distribution of object classes in datasets like MS-COCO, where common classes like "person" significantly outnumber rare ones like "toaster."

While the original Focal Loss effectively handles background imbalance, it often falls short in addressing foreground class imbalance in anchor-free architectures. Existing solutions typically target two-stage detectors or extreme long-tail scenarios, often requiring complex class grouping or increased inference time. This paper introduces Balance-Oriented Focal Loss (BOFL), a plug-and-play solution designed for general imbalance in standard datasets without adding computational overhead.

Methodology: Balance-Oriented Focal Loss

BOFL addresses imbalance through three integrated components:

  1. Class-Wise Re-weighting: The authors adapt the $\alpha$-balanced variant of Focal Loss by calculating a weighting factor ($\alpha_i$) for each class based on its inverse frequency in the dataset. This ensures that rare classes contribute more significantly to the total loss.
  2. Linear Scheduling (LS): A core insight of this work is that immediate application of heavy weights to rare classes can destabilize the optimizer. To mitigate this, a linear scheduler gradually transitions class weights from 1.0 to their calculated $\alpha$ values over the course of training. This allows the model to first learn general features before specializing on rare classes.
  3. Batch-Wise Balancing (BB): To handle local imbalances within training batches, a term is added to adjust weights based on the specific distribution of objects in the current batch, smoothing the optimization process.
Comparison of different weighting factor scheduling strategies.

The "Linear Scheduling" approach (shown above) acts as a fine-tuning phase, preventing the "shock" to the optimizer that occurs with immediate re-weighting. This strategy is simpler than "Deferred Re-weighting" and requires no structural changes to the network.

Experimental Results

The effectiveness of BOFL was primarily evaluated using the CenterNet detector on the MS-COCO benchmark.

Performance Gains

The proposed method achieved an overall AP gain of +1.2 on MS-COCO, moving from a baseline of 26.4 to 27.6. These gains were particularly pronounced on efficient backbones; for instance, using MobileNet v3, the AP improved from 26.2 to 27.3. The method also demonstrated generalization across different anchor-free architectures, showing AP gains of +0.4 to +0.7 on FCOS.

Ablation Study

A detailed ablation study highlights the critical role of Linear Scheduling. Interestingly, applying the weighting factor (WF) alone actually decreased performance by 0.5 AP compared to the baseline. However, combining WF with Linear Scheduling (LS) resulted in a significant gain, proving that the scheduling mechanism is essential for stable and effective training.

Ablation study of the components in Balance-Oriented Focal Loss (BOFL).

Limitations

While effective for general imbalance, the method showed limitations in extreme long-tail scenarios (COCO-LT), where aggressive inverse-frequency weighting could still destabilize training unless the weighting intensity was significantly reduced. Additionally, the batch-wise balancing hyper-parameter $\eta$ may require tuning for specific datasets.

Conclusion

Balance-Oriented Focal Loss provides a simple, effective, and inference-efficient way to handle class imbalance in anchor-free object detectors. By combining class-wise re-weighting with a novel linear scheduling strategy, BOFL achieves state-of-the-art performance gains on standard benchmarks like MS-COCO without the need for complex architectural modifications.

Summary updated

BibTeX
@misc{gil2020balance,
  author = {Hopyong Gil and Sangwoo Park and Yusang Park and Wongoo Han and Juyean Hong and June-Young Jung},
  title = {{Balance-Oriented Focal Loss with Linear Scheduling for Anchor Free Object Detection}},
  year = {2020},
  eprint = {2012.13763},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2012.13763},
}
Figure