Introduction
Object counting—estimating the number of entities like people in a crowd or cells in a microscope image—is fundamentally a regression problem. However, a persistent paradox exists in computer vision: treating counting as a classification task often yields superior results in practice. This paper investigates this discrepancy, identifying "noisy" ground truth labels as the primary culprit, and introduces Discrete-Constrained (DC) Regression to bridge the gap between theoretical regression and practical robustness.
The Paradox of Counting: Why Regression Fails
In standard counting pipelines, ground truth labels are generated by applying Gaussian kernels to dot annotations (points indicating object centers) to create a density map. The count for a local image patch is then the integral of this map over the patch area.
As shown in the figure above, if the Gaussian kernel does not perfectly match the object size, or if the human annotator places the dot slightly off-center, the resulting "ground truth" count for a local patch becomes imprecise. Standard regression models using L1 or L2 loss are highly sensitive to these minor fluctuations, attempting to "overfit" the noise rather than learning the underlying object patterns. Classification models are more robust because they group counts into discrete buckets, effectively ignoring small errors within those buckets. However, classification fails to leverage the natural numerical ordering of counts (e.g., it does not recognize that 10 is closer to 11 than to 50).
Discrete-Constrained Regression
To resolve this, the authors propose a hybrid approach that combines the robustness of classification with the ordering logic of regression.
1. The DC Loss ($L_{dc}$)
Instead of targeting a continuous value, DC-regression partitions the count range into $N+1$ discrete intervals. The model is penalized only if its prediction falls outside the interval containing the ground truth. This creates a "buffer zone" where the loss is zero, preventing the model from chasing noise caused by imperfect annotations or blurring artifacts.
2. Global Count Loss ($L_{gc}$)
Quantization errors can accumulate when summing local patch counts to reach a global total. To mitigate this, the authors introduce a selective regularizer ($L_{bias}^\lambda$). This loss specifically targets local patches that contribute to a global error trend; for instance, if the total image count is an overestimate, the model only penalizes patches that were also overestimates, ensuring global consistency without sacrificing local robustness.
3. Log-Spaced Intervals
Counting errors typically scale with object density. The authors utilize log-spaced intervals—smaller buckets for low counts and larger buckets for high counts—to better align the model's precision with the inherent difficulty of the task.
Experimental Validation
The researchers tested DC-regression across synthetic datasets, crowd counting benchmarks (ShanghaiTech, JHU-CROWD++, UCF-QNRF), and age estimation tasks.
As illustrated in the synthetic cell counting results, DC-regression (red and purple bars) significantly outperforms both standard regression and classification when dealing with "Partial Cells"—objects that straddle patch boundaries and create the most label noise.
On the UCF-QNRF crowd benchmark, the method achieved a state-of-the-art Mean Absolute Error (MAE) of 84.8. Furthermore, in age estimation tests on the MegaAge dataset, DC-regression achieved an MAE of 5.15, proving its utility extends beyond counting to any continuous-but-noisy numerical prediction task.
Conclusion
Discrete-Constrained Regression demonstrates that the historical preference for classification in counting tasks was a workaround for label noise rather than a fundamental advantage of the classification paradigm. By introducing a discrete buffer into a regression framework, DC-regression provides a robust, order-aware solution that sets new benchmarks for local counting models. Future work may explore applying this discretization strategy to other sensitive tasks like depth estimation or human pose estimation.
Summary updated