TL;DR
This paper introduces SQLNet, a novel localization-based approach for Class-Agnostic Counting (CAC) that accurately counts objects of any class using just a few examples. Unlike previous methods relying on density maps, SQLNet directly predicts object locations and sizes, offering a more practical solution for downstream tasks and achieving state-of-the-art performance.
What Problem Does This Paper Address?
The core challenge addressed is Class-Agnostic Counting (CAC). Traditional object counting methods are "class-specific," meaning they are trained to count only one type of object (e.g., cars, people). This inflexibility is problematic because it requires retraining a model for every new object class, which is costly and time-consuming, especially in real-world scenarios where new object types appear frequently.
Existing CAC methods primarily use density map regression. While these methods can count objects of arbitrary classes using a few exemplars, they have two main drawbacks:
- Impractical for downstream tasks: Density maps only provide a count, not the precise location or size of individual objects, making them unsuitable for tasks like object detection or tracking.
- Limited use of exemplar information: They often process exemplars one by one, failing to fully leverage their collective information, especially regarding scale.
This paper aims to overcome these limitations by proposing a localization-based CAC approach that can accurately locate and estimate the size of each object, while still being class-agnostic and efficient.
Methods
SQLNet is a novel framework composed of three main modules:
- Hierarchical Exemplars Collaborative Enhancement (HECE): This module focuses on extracting rich, discriminative representations from the few provided exemplars. It achieves this through:
- Hierarchical Exemplar Extraction: Using a backbone network (like ResNet) to extract features at multiple scales.
- Cross-Scale Feature Alignment: Ensuring features from different scales have consistent dimensions.
- Equifrequent Size Prompt (ESP): A key innovation that encodes exemplar size information into learnable embeddings. This helps the model understand the scale variations among exemplars, which is crucial for accurate counting.
- Exemplars Collaborative Enhancement: A Transformer-like mechanism that allows all exemplar representations (across scales and enhanced with size prompts) to interact and mutually reinforce their discriminative features.
- Exemplars-Unified Query Correlation (EUQC): This module integrates the enhanced exemplar representations with the query image features. It performs interactions in an "exemplars-unified" manner, meaning all exemplars contribute to the correlation process simultaneously, rather than individually. This is achieved through:
- Spatial Correlation: Using a modified self-attention mechanism to correlate image features with the enhanced exemplar features across spatial locations.
- Channel-wise Correlation: Adaptively recalibrating the importance of different channels in the correlation map to focus on the most relevant information.
- Scale-aware Multi-head Localization (SAML): This module takes the correlated query tensor from EUQC and predicts object instances. It has three heads:
- Confidence Head: Predicts the likelihood of a proposal being an object.
- Location Head: Predicts the precise coordinates of the object.
- Size Head: Predicts the width and height of the object. Crucially, SQLNet introduces a scale-aware localization loss that leverages flexible matching between ground truth points and predicted proposals, and uses exemplar sizes for supervision, enabling accurate size prediction.
Datasets
The paper evaluates SQLNet on the following datasets:
- FSC-147: A benchmark dataset for CAC, containing diverse object classes and varying object counts. It's used for training, validation, and testing, with a focus on unseen classes during testing.
- Val-COCO and Test-COCO: Subsets of the COCO dataset, used for evaluating performance on object detection-like tasks and for comparison with detection-based methods.
- CARPK: A car counting benchmark used to assess the model's generalization capabilities.
Key Insights and Ideas
- Localization is key for CAC: Moving beyond density maps to direct object localization and size prediction is crucial for making CAC practical for downstream applications.
- Size matters: Explicitly incorporating exemplar size information (via Equifrequent Size Prompt) significantly improves performance, highlighting the importance of scale awareness in CAC.
- Unified exemplar interaction: Processing exemplars collectively (exemplars-unified) in the query stage is more effective than traditional exemplar-by-exemplar approaches, leading to richer correlation information.
- Scale-aware loss for better supervision: The proposed scale-aware localization loss, which uses exemplar sizes, enables more accurate object size prediction and improves overall model robustness.
- Transformer-inspired modules: Leveraging self-attention mechanisms (similar to Transformers) for both exemplar enhancement and query correlation proves effective in capturing complex relationships.
Key Results
SQLNet achieves state-of-the-art performance on the FSC-147 benchmark, outperforming previous leading methods in both MAE (Mean Absolute Error) and RMSE (Root Mean Square Error). For instance, it shows a significant drop in MAE compared to the second-best method SPDCN and SAFECount.
- FSC-147: SQLNet achieves the best MAE and RMSE on both validation and test sets.
- Val-COCO and Test-COCO: SQLNet demonstrates superior localization capability (measured by nAP) compared to object detectors and regression-based CAC methods.
- CARPK: SQLNet shows excellent generalization, outperforming methods trained and fine-tuned on CARPK, even when SQLNet is only trained on FSC-147.
- Efficiency: SQLNet offers competitive inference speed (26.38 ms per image on FSC-147) and efficient training compared to some other methods.
- Qualitative results: Visualizations show SQLNet accurately locating and bounding objects, often outperforming density-map-based methods like SAFECount, which struggle with blurriness and precise localization.
Limitations and Future Work
- Multi-class images: While the paper shows some results on multi-class images, performance is noted as "not good enough." The authors attribute this to the lack of sufficient quantity and diversity of multi-class images in the training data. Future work could involve collecting and annotating more such data.
- Bad Cases: The paper acknowledges some failure cases, particularly with significant occlusion (dust from running horses) or extremely small, densely crowded objects (birds), where the method misses targets.
- Backbone choice: While ResNet50 is used as a practical choice, unsupervised pre-trained ViT-large backbones showed slightly better performance but at a significantly higher computational cost.
- Future work: The authors suggest exploring more theoretical analyses and further improving performance on multi-class scenarios. They also highlight the potential of their localization-based approach for various downstream tasks.
Summary updated