[Paper Review] CounTR: Transformer-based Generalised Visual Counting
CounTR introduces a transformer-based architecture for open-world, zero-shot to few-shot visual counting, using exemplar-guided attention and self-supervised pre-training, achieving state-of-the-art results on FSC-147.
In this paper, we consider the problem of generalised visual object counting, with the goal of developing a computational model for counting the number of objects from arbitrary semantic categories, using arbitrary number of "exemplars", i.e. zero-shot or few-shot counting. To this end, we make the following four contributions: (1) We introduce a novel transformer-based architecture for generalised visual object counting, termed as Counting Transformer (CounTR), which explicitly capture the similarity between image patches or with given "exemplars" with the attention mechanism;(2) We adopt a two-stage training regime, that first pre-trains the model with self-supervised learning, and followed by supervised fine-tuning;(3) We propose a simple, scalable pipeline for synthesizing training images with a large number of instances or that from different semantic categories, explicitly forcing the model to make use of the given "exemplars";(4) We conduct thorough ablation studies on the large-scale counting benchmark, e.g. FSC-147, and demonstrate state-of-the-art performance on both zero and few-shot settings.
Motivation & Objective
- Motivate open-world visual object counting that supports arbitrary semantic categories and variable numbers of exemplars (zero-shot to few-shot).
- Develop a transformer-basedCounting TRansformer (CounTR) that leverages self-attention to compare image regions with exemplars.
- Propose a two-stage training regime with MAE-based self-supervised pre-training followed by supervised fine-tuning.
- Introduce a scalable mosaic data synthesis pipeline to alleviate long-tail counts and improve exemplar conditioning.
- Demonstrate state-of-the-art performance on FSC-147 under zero-shot and few-shot settings.
Proposed method
- Propose CounTR, a transformer-based architecture where the image ViT encoder outputs feature tokens, and exemplar features are encoded separately for cross-attention in a feature interaction module (FIM).
- The FIM uses decoder-style transformer layers to enable cross- and self-attention between image patches and exemplar representations, producing a density map.
- A progressive decoder upsamples the FIM output to a 2D density map; the final count is the sum over this density map.
- Two-stage training: first self-supervised pre-training of the ViT encoder with Masked Autoencoders (MAE) on image reconstruction, then supervised fine-tuning for counting.
- A scalable mosaic data generation pipeline (collage and blending) to create images with many instances and diverse backgrounds, addressing long-tail distribution.
- Test-time normalization and cropping strategies to calibrate predictions and handle tiny objects or exemplar placement during inference.
Experimental results
Research questions
- RQ1Can a transformer-based model generalise counting to arbitrary object classes given zero or few exemplars?
- RQ2Does self-supervised pre-training improve counting performance in zero-shot and few-shot settings?
- RQ3Can synthetic mosaicing of training data alleviate long-tail distribution and improve counting in high-instance images?
- RQ4What are effective test-time strategies to calibrate density outputs for exemplar-guided counting?
Key findings
- CounTR achieves state-of-the-art MAE/RMSE on FSC-147 for zero-shot and few-shot settings (e.g., zero-shot MAE 18.07, RMSE 71.84 on Val; 14.71 MAE, 106.87 RMSE on Test).
- Self-supervised MAE pre-training significantly improves performance over supervised fine-tuning alone.
- Mosaic data synthesis further improves results, especially for images with many instances.
- Test-time normalization and cropping further boost counting accuracy, particularly in few-shot settings.
- CounTR with 3 exemplars remains robust, showing little difference across 1, 2, or 3 shots.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.