Few-Shot Object Counting and Detection

Thanh Nguyen, Chau Pham, Khoi Nguyen, Minh Hoai

Abstract

We tackle a new task of few-shot object counting and detection. Given a few exemplar bounding boxes of a target object class, we seek to count and detect all objects of the target class. This task shares the same supervision as the few-shot object counting but additionally outputs the object bounding boxes along with the total object count. To address this challenging problem, we introduce a novel two-stage training strategy and a novel uncertainty-aware few-shot object detector: Counting-DETR. The former is aimed at generating pseudo ground-truth bounding boxes to train the latter. The latter leverages the pseudo ground-truth provided by the former but takes the necessary steps to account for the imperfection of pseudo ground-truth. To validate the performance of our method on the new task, we introduce two new datasets named FSCD-147 and FSCD-LVIS. Both datasets contain images with complex scenes, multiple object classes per image, and a huge variation in object shapes, sizes, and appearance. Our proposed approach outperforms very strong baselines adapted from few-shot object counting and few-shot object detection with a large margin in both counting and detection metrics.

Introduction

In computer vision, handling numerous objects typically follows two distinct paradigms. Few-Shot Counting (FSC) estimates the quantity of a target class (e.g., "lemons") based on a few exemplars, usually via density maps that lack precise object boundaries. Conversely, Few-Shot Object Detection (FSOD) provides bounding boxes but requires extensive pre-training on thousands of full annotations for base classes.

In crowded scenes, such as a crate of fruit or a flock of birds, annotating every instance with a bounding box is prohibitively expensive. Dot annotations—clicking the center of each object—are significantly faster but lack shape and size information. This paper introduces Few-Shot Object Counting and Detection (FSCD), a task that bridges this gap by outputting full bounding boxes for every object using only dots and a handful of example boxes for supervision.

Methodology: Counting-DETR

The proposed model, Counting-DETR, is built upon the Anchor DETR architecture and specifically designed to handle imperfect training data.

Feature Aggregation

The system extracts features from a query image and a few exemplar boxes using a ResNet-50 backbone. A correlation mechanism then highlights regions in the query image that match the exemplars, producing an exemplar-integrated feature map.

Two-Stage Training Strategy

To overcome the lack of full bounding box annotations during training, the authors employ a two-stage approach:

  1. Pseudo-GT Generation: The model is initially trained on the provided exemplar boxes. It then predicts bounding boxes for every dot annotation in the training set, creating "pseudo-ground-truth" (pseudo-GT) boxes.
  2. Fine-tuning: The model is re-trained on the entire dataset using these pseudo-GT boxes.
Figure 4: Training phase utilizing dot annotations and a few exemplar boxes to supervise the model.

Uncertainty-Aware Learning

Since pseudo-GT boxes are inherently noisy, the authors introduce an uncertainty estimation branch. The model predicts its confidence in each box's dimensions using a Laplace distribution-based loss. This allows the model to down-weight the loss for boxes where it is highly uncertain about the boundaries, making it more robust to noisy labels.

Datasets

Two new benchmarks were introduced to evaluate FSCD:

  • FSCD-147: An extension of the FSC-147 dataset, adding full bounding box annotations for validation and testing (6,135 images, 147 categories).
  • FSCD-LVIS: A more complex dataset derived from LVIS (6,195 images, 377 classes), often containing multiple distractor classes to test the model's discriminative power.

Experimental Results

Counting-DETR demonstrates significant improvements over baselines adapted from existing counting and detection methods.

Figure 3: Testing phase demonstrating the transition from a few exemplar boxes to full detection and counting of 20 apples.
  • Counting Accuracy: On FSCD-147, the model achieved a Mean Absolute Error (MAE) of 16.79, outperforming the state-of-the-art counting model FamNet (MAE 22.09).
  • Detection Quality: It achieved an AP50 of 50.57 on FSCD-147, nearly doubling the performance of a detection-adapted FamNet baseline (AP50 29.73).
  • Generalization: The model maintained superior performance on unseen classes in FSCD-LVIS, indicating it learns a general "matching" concept rather than memorizing specific object types.

Conclusion

The research demonstrates that dot annotations, when combined with a few exemplars, provide sufficient spatial signals to bootstrap a robust object detector. By employing a two-stage training strategy and uncertainty-aware loss, Counting-DETR effectively handles the noise inherent in pseudo-labels. Future work will focus on improving robustness against extreme perspective shifts and scale variations within single images.

Summary updated

BibTeX
@inproceedings{nguyen2022few,
  author = {Thanh Nguyen and Chau Pham and Khoi Nguyen and Minh Hoai},
  title = {{Few-Shot Object Counting and Detection}},
  booktitle = {European Conference on Computer Vision},
  year = {2022},
  url = {https://openreview.net/forum?id=wzEVL6cpSs},
}
Figure