Abstract
We present a method for training CNN-based object class detectors directly using mean average precision (mAP) as the training loss, in a truly end-to-end fashion that includes non-maximum suppression (NMS) at training time. This contrasts with the traditional approach of training a CNN for a window classification loss, then applying NMS only at test time, when mAP is used as the evaluation metric in place of classification accuracy. However, mAP following NMS forms a piecewise-constant structured loss over thousands of windows, with gradients that do not convey useful information for gradient descent. Hence, we define new, general gradient-like quantities for piecewise constant functions, which have wide applicability. We describe how to calculate these efficiently for mAP following NMS, enabling to train a detector based on Fast R-CNN directly for mAP. This model achieves equivalent performance to the standard Fast R-CNN on the PASCAL VOC 2007 and 2012 datasets, while being conceptually more appealing as the very same model and loss are used at both training and test time.
The "Dishonesty" of Object Detection
Traditionally, object detectors suffer from a fundamental discrepancy between training and evaluation. While we evaluate detectors using Mean Average Precision (mAP), we train them using simple window classification losses. In a standard pipeline like Fast R-CNN, the model learns to classify individual image windows as "object" or "background." However, at test time, it scores thousands of windows, applies Non-Maximum Suppression (NMS) to remove redundant overlaps, and is then evaluated on mAP, which depends on the relative ranking of all detections.
This creates a "surrogate task" problem: the training objective is only a proxy for the actual goal. Henderson and Ferrari propose a way to make training "honest" by optimizing for mAP directly, including the NMS step in the training loop.
The Challenge: Piecewise-Constant Losses
The primary obstacle to direct mAP optimization is that mAP and NMS are mathematically "nasty" for deep learning. They are piecewise-constant functions—meaning if you change a detection score slightly, the mAP usually doesn't change at all (gradient is zero). If you change it enough to swap the rank of two detections, the mAP jumps suddenly, making the gradient undefined.
Methods: Pseudogradients (PPD) and Implementation
To overcome the zero-gradient problem, the authors introduce Pseudogradients (PPD) for piecewise-constant functions. They propose two estimators to "smooth" the loss surface: the Symmetric Difference Estimator (SDE) and the Mean Envelope Estimator (MEE). The MEE generally outperformed SDE by providing a more stable, less "jittery" gradient signal.
Integrating NMS is also complex due to its "cascading" effects. The authors use "transitivity approximations" to model these interactions efficiently, allowing them to compute the Jacobian of the NMS process in linear time. Additionally, several training tweaks were necessary:
- Log-space loss: Optimizing $\log(mAP + \epsilon)$ to provide a stronger signal early in training.
- Minibatch Composition: Using a lower foreground fraction (5%) to mimic test-time imbalance.
- L4 Regularization: Applying a strong penalty to scores to prevent them from exploding.
Key Insights and Results
- Rank-based Gradients: mAP only changes when a True Positive (TP) swaps rank with a False Positive (FP). By identifying these specific "critical points," the system ignores thousands of windows that don't affect the final score.
- Sparsity: Only about 20% of windows provide a non-zero gradient signal, yet this is sufficient for effective training.
- Performance: The model achieves performance essentially equal to the standard Fast R-CNN (~62.5% mAP on VOC 2007+2012).
While this approach didn't significantly outperform the state-of-the-art in raw numbers, it proved that NMS and mAP—long considered "black box" post-processing steps—could be integrated directly into a differentiable neural network, fulfilling the "machine learning dictum" that training loss should match the evaluation metric.
Summary updated