Abstract
Automated object counting typically relies on class-specific models or few-shot approaches requiring reference exemplars. Furthermore, these systems often necessitate expensive point-level annotations for training. We introduce the Reference-less Class-agnostic Counter (RCC), a novel framework that treats counting as a fundamental problem of repetition recognition. By utilizing the global context of Vision Transformers (ViT) and weak supervision in the form of total image counts, RCC learns to identify and enumerate salient repeating objects without reference examples at test time. Our results demonstrate that RCC outperforms existing reference-less methods and remains competitive with state-of-the-art few-shot models.
Introduction
The task of counting objects in images is a cornerstone of computer vision with applications ranging from ecological surveys to crowd management. Current methodologies generally fall into two paradigms: class-specific counters, which are limited to predefined categories, and class-agnostic (few-shot) counters, which require users to provide "exemplars" of the target object at inference. Both approaches typically rely on point-level supervision—human-annotated dots on every object—which is labor-intensive and difficult to scale.
This research addresses these limitations by proposing a reference-less, class-agnostic approach. We ask whether a model can learn to count the most salient repeating objects in an image without being told what they are and without requiring localized training dots. By framing counting as a task of identifying repetitions, we move toward a more general and less supervised form of visual understanding.
Methodology
The RCC architecture leverages a Vision Transformer (ViT-Small) backbone, initialized with self-supervised weights from DINO. Unlike Convolutional Neural Networks (CNNs), the self-attention mechanism in ViTs provides a global receptive field, allowing the model to compare distant patches across the entire image—a critical capability for identifying repetitions.
The model employs a remarkably simple regression head: a linear projection that maps ViT features directly to a scalar count. Training is conducted using weak supervision, where the only label provided is the total count of the most salient object class. The objective function is the Absolute Percentage Error (APE) between the ground truth and the prediction. To enhance robustness in high-density scenarios, we utilize tiling augmentation, where resized versions of the input are arranged in a 2x2 grid during training.
Experimental Evaluation
We evaluated RCC on the standard FSC-147 dataset and a refined version, FSC-133, which addresses data quality issues such as duplicates and class overlaps. Additionally, we tested zero-shot generalization on the CARPK dataset, which features overhead drone imagery of vehicles—a domain not represented in the training set.
RCC significantly outperformed RepRPN, the primary baseline for reference-less counting. On the FSC-147 test set, RCC achieved a Mean Absolute Error (MAE) of 17.12, surpassing several models that utilize stronger supervision. In zero-shot tests on CARPK, RCC outperformed the popular FamNet model, indicating that it learns a generalizable concept of "objectness" and repetition rather than simply memorizing specific classes.
Discussion: Emergent Localization and Global Context
A key finding of this work is that global context is more vital for reference-less counting than high-resolution local features. The ViT's ability to relate distant image regions allows it to recognize patterns of repetition that CNNs might miss.
Furthermore, we observed a phenomenon of "emergent localization." Despite never receiving spatial supervision (dots), visualizations of the model's internal features reveal that it implicitly learns to localize the objects it counts. This suggests that count-only supervision allows the model to develop its own conceptual representation of an object, which may be more robust for class-agnostic tasks than human-defined center points.
Conclusion
RCC represents a significant step toward flexible, low-supervision counting systems. By combining self-supervised ViT features with image-level count labels, we achieve high performance across diverse object categories without the need for test-time exemplars. Future work will focus on multi-class counting in complex scenes and improving resolution to handle extremely high-density images where objects may be smaller than the model's patch size.
Summary updated