Learning a Unified Sample Weighting Network for Object Detection

Qi Cai, Yingwei Pan, Yu Wang, Jingen Liu, Ting Yao, Tao Mei

Abstract

Object detection performance is heavily influenced by the quality and difficulty of training samples. Traditional methods rely on manual heuristics like Online Hard Example Mining (OHEM) or Focal Loss to manage sample importance. This paper introduces a Unified Sample Weighting Network (SWN), a data-driven auxiliary module that automatically learns task-dependent weights for each training sample based on uncertainty. By jointly optimizing classification and regression weights, SWN achieves significant performance gains—up to 1.8% AP on MS COCO—across various one-stage and two-stage detectors with negligible training overhead and zero inference cost.

Introduction

In the training of object detectors, samples are non-uniform in their contribution to the learning process. While some samples provide clear signals, others are occluded, blurry, or represent background noise. Existing strategies to address this imbalance, such as OHEM and Focal Loss, suffer from several limitations: they are often task-specific (focusing primarily on classification), rely on manual hyperparameter tuning, and assume that "hard" examples (those with high loss) are always the most informative. However, extremely hard samples may simply be outliers or mislabeled data that introduce noise into the gradients.

The authors propose a shift from manual heuristics to a learned, data-dependent weighting scheme. The goal is to develop a mechanism that balances the needs of both classification and bounding box regression dynamically during training.

Methods: The Sample Weighting Network

The core of the proposed approach is the Sample Weighting Network (SWN), a lightweight Multi-Layer Perceptron (MLP) integrated into the detector's training pipeline.

Overview of the Sample Weighting Network (SWN) integrated into a standard object detection pipeline.

Probabilistic Loss Formulation

The SWN is grounded in a probabilistic reformulation of detection loss. By modeling regression as a Gaussian likelihood and classification via a Boltzmann distribution, the network can predict a "variance" or uncertainty for every sample. This uncertainty serves as the basis for the learned weights.

Architecture and Input

For every region proposal, the SWN processes four discriminative features: classification loss, regression loss, Intersection over Union (IoU) with ground truth, and the predicted probability score. Unlike previous methods that might apply a single weight to the entire sample, the SWN predicts separate, independent weights for the classification and regression tasks simultaneously.

Training Efficiency

A key advantage of the SWN is its efficiency. It is used exclusively during the training phase to scale gradients. Once training is complete, the auxiliary network is discarded. This allows the final detector to benefit from improved training dynamics without any increase in inference latency.

Key Insights

The effectiveness of SWN stems from its ability to handle complex sample dynamics that manual heuristics miss.

Illustration of task inconsistency: different candidate boxes (A, B, C) for the same object exhibit varying classification scores and localization accuracy (IoU).

Task Inconsistency

A common issue in object detection is task inconsistency, where a sample might be easy to classify but difficult to localize, or vice versa. As shown in Figure 5, different bounding box candidates for the same object can have high classification scores but poor IoU, or high IoU but lower scores. SWN addresses this by weighting tasks independently per sample, preventing the model from compromising one task to fix errors in another on noisy samples.

Hard vs. Important Samples

The research demonstrates that "hard" samples (high loss) are not always the most "important." In fact, "easy" samples are often critical for fine-tuning the ranking of detections, which directly impacts the Mean Average Precision (mAP) metric. SWN learns to down-weight outliers and ambiguous samples that would otherwise produce noisy gradients, effectively acting as a self-correcting mechanism.

Experimental Results

The researchers evaluated SWN on the MS COCO and PASCAL VOC datasets using various backbone networks (ResNet-50, ResNeXt-101) and detector architectures.

  • Faster R-CNN: Performance increased from 36.7% to 38.5% AP (+1.8%) on MS COCO.
  • RetinaNet: Improved from 35.9% to 37.2% AP (+1.3%).
  • Mask R-CNN: Achieved a boost of +1.5% AP.
  • Training Overhead: The addition of SWN increased training time by only 1.5%, making it a highly practical addition to standard training pipelines.

Qualitative analysis further revealed that models trained with SWN were significantly better at detecting "easy" objects that baseline models occasionally missed due to an over-focus on hard examples during training.

Conclusion and Future Work

The Unified Sample Weighting Network provides a robust, automated alternative to manual sample weighting heuristics. While highly effective, the authors noted that classification weights for background samples can still exhibit instability due to high uncertainty variance. Future research may explore more stable per-sample solutions for negative samples and investigate how weighting strategies should evolve dynamically throughout the optimization process.

Summary updated

BibTeX
@inproceedings{cai2020learning,
  author = {Qi Cai and Yingwei Pan and Yu Wang and Jingen Liu and Ting Yao and Tao Mei},
  title = {{Learning a Unified Sample Weighting Network for Object Detection}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2020},
  doi = {10.1109/cvpr42600.2020.01418},
}
Figure