Abstract
Object counting is a fundamental computer vision task typically requiring extensive manual annotation. This paper introduces UnCounTR, the first reference-based counting model trained entirely without human labels. By leveraging "Self-Collages"—synthetic images generated from unlabeled data—and self-supervised feature representations from DINO, the model learns to generalize numerosity across diverse object categories. Experimental results on benchmarks like FSC-147 demonstrate that UnCounTR achieves performance competitive with, and in some cases superior to, supervised object detectors, proving the viability of unsupervised learning for complex counting tasks.
Introduction
Object counting is a tedious yet essential task in computer vision, with applications ranging from medical imaging to environmental monitoring. Traditionally, training a model to count requires humans to manually click on every single object in thousands of images—a process known as the "annotation tax." This paper proposes a way to bypass this bottleneck entirely by teaching models "how to count" using only unlabeled images.
Counting models generally fall into two categories: class-specific (e.g., counting cars) and class-agnostic (counting any object based on a few "exemplar" crops). While class-agnostic models are more flexible, they typically rely on datasets like FSC-147, which contain over 6,000 painstakingly labeled images. UnCounTR seeks to achieve similar flexibility without any manual supervision.
Methodology
The core innovation of this work is a self-supervised training pipeline centered around the generation of Self-Collages and a transformer-based architecture.
Self-Collage Generation
To create training data with known counts without human intervention, the researchers utilized a background dataset (SUN397) and an object dataset (ImageNet). Using unsupervised segmentation, they "cut out" objects and pasted them onto background scenes. Since the pasting process is automated, the exact count and location of objects are known, providing a "free" ground truth label for training.
Architecture and Categorization
To ensure the model distinguishes between different object types, the authors used a pretrained DINO (Self-distillation with no labels) model and k-means clustering to group ImageNet objects into 10,000 unsupervised categories.
The UnCounTR architecture is transformer-based, utilizing a frozen DINO backbone as a feature extractor. It processes a target image alongside a few "exemplar" crops, using a transformer decoder to identify similarities and output a density map. The sum of this map represents the final predicted count. An upgraded version, UnCounTRv2, incorporates the more powerful DINOv2 backbone and a "hard negative" strategy—pasting objects that visually resemble the target to force the model to learn finer semantic distinctions.
Key Results and Insights
UnCounTR was evaluated on several benchmarks, including FSC-147, CARPK (car counting), and MSO (multi-salient objects).
Performance Comparison
One of the most significant findings is that UnCounTR can outperform supervised baselines in specific scenarios. On the FSC-147 "low" split (8-16 objects), UnCounTR achieved a Mean Absolute Error (MAE) of 5.60, outperforming supervised detectors like FasterRCNN (7.06) and DETR (6.92). While it does not yet surpass state-of-the-art supervised counting models across all metrics, it remains highly competitive without ever seeing a human-made label.
Emergent Numerosity
Surprisingly, the model generalizes from training on a maximum of 19 objects to counting hundreds of objects during testing. This suggests that the model is not merely memorizing patterns but is learning a robust mathematical concept of numerosity as a latent property. Furthermore, the authors found that keeping the DINO backbone frozen yielded better results than fine-tuning, implying that modern self-supervised representations already capture sufficient object boundary and semantic information.
Limitations and Future Work
Despite its success, UnCounTR faces challenges in extremely high-density scenes where objects overlap significantly (e.g., dense crowds or piles of small items). Additionally, real-world ambiguity—where it is difficult even for humans to define a distinct object—can lead to missed detections. Future research may extend this self-supervised approach to more complex tasks, such as unsupervised semantic instance segmentation or the generation of scene graphs.
By demonstrating that counting is solvable through self-supervision, this work removes a major barrier to deploying computer vision in specialized fields where labeled data is scarce.
Summary updated