TL;DR
Can generic vision models count objects without ever being explicitly trained to do so? This paper reveals that frozen intermediate features of standard pre-trained models (like ResNet and ViTs) implicitly encode quantitative information. By simply training a lightweight regression layer on top of these "off-the-shelf" features using only image-level labels, the authors achieve surprisingly accurate approximate object counting that rivals specialized, end-to-end architectures.
What Problem Does This Paper Address?
Object counting—whether estimating crowd sizes, tracking traffic, or counting cells under a microscope—is a vital computer vision task. Traditionally, achieving high accuracy has required complex, task-specific architectures and expensive spatial annotations, such as point-level clicks or density maps.
The authors of this paper investigate a fundamental question: Do general-purpose vision models naturally develop an internal understanding of quantity? Instead of building a new counting network, they explore whether the representations learned by models pre-trained on standard datasets (like ImageNet) already contain a latent "counting ability" that can be unlocked without fine-tuning the underlying model.
Methods
The researchers propose a remarkably minimal setup to evaluate the counting properties of frozen backbones:
- Feature Extraction: An input image is passed through a frozen pre-trained backbone (such as an ImageNet-trained ResNet-50 or a self-supervised Vision Transformer). Intermediate feature maps are extracted from different layers.
- Spatial Aggregation: The feature maps are aggregated using either Global Average Pooling (GAP) or a localized pooling variant ($k \times k$ regions).
- Lightweight Regression: The aggregated vector is fed into a simple linear regressor or a two-layer MLP to predict the final count.
Crucially, the backbone remains completely frozen, and the model is trained using only image-level count labels, entirely bypassing the need for spatial or positional supervision.
Datasets
The approach was rigorously tested across both synthetic and real-world benchmarks:
- Synthetic Data: Custom-generated images containing identical discs of varying sizes ($r = 5, 15, 25, 50$ pixels), mixed shapes (squares and hexagons), and mixed colors to test fine-grained properties like selective counting and background robustness.
- Real-World Datasets: Nine public benchmarks spanning diverse domains:
- Crowd Counting: ShanghaiTech A and B.
- Wildlife/Ecology: IOCfish5K (underwater fish) and SP-Cattle (livestock).
- Biomedical Imaging: DCC, ADI, MBM, and VGG (cells and bacteria).
Key Insights and Ideas
- The "Sweet Spot" is Mid-Level Features: Features from the third block (Layer 3) of ResNet-50 consistently provided the most stable and accurate counting performance. Early layers lack semantic abstractness, while the final layer is too specialized for classification tasks.
- Selective Counting Emerges Naturally: When presented with images containing a mix of shapes (e.g., squares and hexagons), an MLP trained on Layer 3 features could successfully count only the squares or only the hexagons. Spatial attribution maps confirmed that the model naturally shifts its focus to the requested attribute without explicit spatial training.
- Monotonic Structure in Feature Space: Unsupervised feature-space visualizations (via UMAP) revealed that object count is embedded as a continuous, smooth gradient within the representation space. The dominant factor driving feature variance was often the object count itself, rather than background complexity.
- Robustness to Background Noise: Even when target objects were alpha-blended onto completely random natural images, the pre-trained representations maintained their counting accuracy, demonstrating strong resilience to complex backgrounds.
Key Results
Despite its extreme simplicity, this minimal regression framework achieved highly competitive results on real-world datasets:
- IOCfish5K: The proposed method achieved a Mean Absolute Error (MAE) of 33.62, outperforming classic specialized models like MCNN (72.93) and ranking competitively with more complex architectures.
- Cell Counting (DCC & MBM): On the DCC dataset, the method achieved an MAE of 1.6, approaching the performance of state-of-the-art weakly supervised methods.
- ViT Generalization: The counting property was not unique to ResNets; Vision Transformers pre-trained via self-supervised methods (like DINOv2 and MAE) or contrastive learning (CLIP) also demonstrated peak counting performance at intermediate blocks (Blocks 4 and 8).
Limitations and Future Work
While these findings expose a fascinating latent property of vision models, the authors note a few limitations:
- Approximate vs. Exact Counting: This method is suited for approximate counting in dense or overlapping scenes. It struggles with exact instance-level counting (within a strict $\pm 1$ margin) when precision is paramount.
- Performance Gap to SOTA: While highly competitive with weakly supervised methods, it still lags behind the absolute latest state-of-the-art models that leverage dense, point-level spatial supervision.
Future Directions: The authors suggest exploring how this quantitative structure dynamically emerges during pre-training and investigating ways to exploit this inherent numerosity to improve unsupervised or few-shot downstream tasks.
Summary updated