Revisiting Foreground-Background Imbalance in Object Detectors

Joya Chen, Dong Liu, Tong Xu, Enhong Chen

Abstract

In training deep object detectors, the problem of foreground-background imbalance has traditionally been addressed by heuristic methods like online hard example mining (OHEM) or Focal Loss. This paper challenges the necessity of these sampling heuristics. We propose a "Sampling-Free" mechanism consisting of three components: decoupling objectness from classification, biased initialization for loss stability, and adaptive inference thresholding. Our approach achieves state-of-the-art accuracy across various detector architectures on COCO and PASCAL VOC without the need for laborious hyper-parameter tuning associated with traditional sampling methods.

The Challenge of Foreground-Background Imbalance

Object detection requires evaluating a vast number of candidate locations, the majority of which are background. This extreme imbalance often leads to "easy negatives" (obvious background) dominating the training loss, preventing the model from learning to distinguish actual objects. Conventional solutions fall into two categories: Hard Sampling (e.g., undersampling background examples in Faster R-CNN) and Soft Sampling (e.g., Focal Loss reweighting in RetinaNet). While effective, these methods introduce complex hyperparameters and create a discrepancy between the training and inference data distributions.

The Sampling-Free Mechanism

The authors propose that the imbalance problem can be solved by addressing the stability and scale of the classification loss rather than warping the data distribution through sampling.

1. Decoupling Objectness from Classification

Instead of a single classifier handling $C$ categories plus a background class, the task is split. An objectness branch identifies foreground regions, while a separate classification branch categorizes those regions. This prevents the massive number of background samples from overwhelming the specific category learning.

Architecture for decoupling objectness from classification, showing the separate objectness logits branch.

2. Biased Initialization

To prevent initial loss spikes caused by the abundance of background, the final layers are initialized with a bias such that the initial prior probability of being foreground is low (e.g., $\pi = 0.01$). This ensures the model starts with low confidence, keeping the initial loss manageable and stable.

3. Adaptive Thresholding

Because the sampling-free model is not aggressively suppressed during training, it may produce lower-confidence scores for valid detections. By lowering the inference threshold (e.g., from 0.05 to 0.001), the model can recover high-quality detections that traditional heuristics might have discarded.

Experimental Results

The Sampling-Free mechanism was evaluated on the MS COCO dataset across several architectures, including RetinaNet (one-stage), Faster R-CNN (two-stage), and FCOS (anchor-free).

Performance comparison of RetinaNet variants (left) and the effect of different prior initialization values (right).

As shown in the results, RetinaNet-Obj (the sampling-free version) achieves 36.5 AP, surpassing the standard RetinaNet-FL (Focal Loss) at 36.4 AP. Furthermore, the right table in the figure demonstrates that the model is robust to the specific choice of the prior $\pi$, provided it is sufficiently small to stabilize the initial training phase.

In the case of Faster R-CNN, removing undersampling in both the RPN and RoI-subnet stages led to an improvement of 0.4 AP, reaching 37.2 AP. This suggests that even two-stage detectors, which have traditionally relied on hard sampling, benefit from seeing the full data distribution during training.

Conclusion

This work demonstrates that complex sampling and reweighting heuristics are not strictly necessary for training high-performance object detectors. By simply decoupling the detection tasks and ensuring numerical stability through proper initialization and inference thresholds, models can learn more effectively from the natural data distribution. This "Sampling-Free" approach simplifies the training pipeline and removes the need for expensive hyperparameter searches.

Summary updated

Abstract

In training deep object detectors, the problem of foreground-background imbalance has been addressed by several heuristic methods, such as online hard example mining (OHEM), Focal Loss, and gradient harmonizing mechanism (GHM). These methods either re-sample the training examples (i.e. hard sampling), or re-weight them discriminatively (i.e. soft sampling). In this paper, we challenge the necessity of such hard/soft sampling heuristics in training deep object detectors. First, without hard/soft sampling, we reveal that the scale and the stability of the classification loss greatly influence the final accuracy. Thus, we propose a guided loss scaling technique to control the classification loss during training, without using any hyper-parameter. We also propose to optimally initialize the model to ensure the stability of the classification loss. Moreover, we propose an adaptive thresholding technique to refine predictions during inference. These three ingredients constitute our Sampling-Free mechanism, which is fully data diagnostic and avoids the laborious hyper-parameter search for hard/soft sampling. We verify the effectiveness of our Sampling-Free mechanism in training one-stage, two-stage, multi-stage, and anchor-free object detectors, where our method always achieves higher accuracy on COCO and PASCAL VOC datasets. We also use the Sampling-Free mechanism for instance segmentation to demonstrate its generalization ability. Code is released at: this https URL.
BibTeX
@article{chen2021revisiting,
  author = {Joya Chen and Dong Liu and Tong Xu and Enhong Chen},
  title = {{Revisiting Foreground-Background Imbalance in Object Detectors}},
  journal = {IEEE Trans. Image Process.},
  year = {2021},
  doi = {10.1109/tip.2021.3106802},
}
Figure