Semantic Generative Augmentations for Few-Shot Counting

Perla Doubinsky, Nicolas Audebert, Michel Crucianu, Hervé Le Borgne

TL;DR

This paper tackles the challenge of few-shot object counting, where models need to count objects without prior category-specific training. They propose a novel method using Stable Diffusion, conditioned on both text prompts and object density maps, to generate diverse synthetic training data. This approach significantly improves counting accuracy by creating more varied and realistic training examples than traditional augmentation methods.

What Problem Does This Paper Address?

Few-shot object counting (FSC) aims to train models that can count objects from categories they haven't seen during training. This is crucial for real-world applications where new object types emerge frequently. However, FSC datasets are often small, leading to overfitting and poor generalization. Traditional data augmentation techniques (like cropping or color jittering) are insufficient to create the diversity needed for robust FSC models. Furthermore, existing text-to-image models struggle to accurately generate images with a specific number of objects, making them unreliable for generating counting-specific training data. The core problem is generating high-quality, diverse synthetic data that accurately reflects object counts and spatial arrangements to improve FSC model performance.

Methods

The authors leverage Stable Diffusion, a powerful text-to-image diffusion model, for synthetic data generation. Their key innovation lies in a dual conditioning strategy:

  • Text Prompt Conditioning: They use descriptive captions generated by BLIP-2 to guide the semantic content of the generated images.
  • Density Map Conditioning: Crucially, they introduce conditioning on the ground-truth density map of the objects. This is implemented using ControlNet, which allows for precise control over the spatial layout and number of objects in the generated images, directly addressing the limitations of text-only prompts.

To further enhance diversity, they propose a "Diverse Generation" strategy:

  • Caption Swapping: They swap captions between compatible training images. Compatibility is determined by a similarity threshold between caption embeddings, ensuring that swapped captions still semantically align with the original object's context (e.g., swapping "bread rolls" with "macarons" rather than something entirely unrelated). This creates novel combinations of object types and backgrounds.

The generated synthetic images, along with their original exemplar bounding boxes and density maps, are then used to train FSC models. They also introduce a "Baseline Generation" strategy, which relies solely on the inherent randomness of the diffusion process to generate variations of the original image content.

Datasets

  • FSC147: This is the primary dataset used for training and evaluation. It's a class-agnostic counting dataset with 147 object categories, split into training, validation, and disjoint test sets. The authors use the training set for generating augmentations and then evaluate their approach on both the validation and test sets.
  • CARPK: This dataset is used to evaluate the generalization ability of their class-agnostic models to a new, class-specific domain (counting cars in parking lots).

Key Insights and Ideas

  • Density Map Conditioning is Key: The most significant insight is that conditioning diffusion models on density maps, in addition to text prompts, is essential for accurate few-shot counting augmentation. This directly enforces the correct number and spatial distribution of objects, which text prompts alone cannot reliably achieve.
  • Caption Similarity for Meaningful Diversity: Simply swapping captions randomly leads to poor results. The authors demonstrate that using a caption similarity threshold to swap captions between semantically related images is crucial for generating diverse yet plausible augmentations that improve performance.
  • Balancing Baseline and Diverse Augmentations: A mix of baseline (semantically similar) and diverse (semantically different) augmentations yields the best results, suggesting that both types of variations are beneficial for robust training.
  • Synthetic Data Outperforms Traditional Augmentations: The proposed synthetic augmentation strategies consistently outperform traditional methods and even other recent augmentation techniques like "Real Guidance" on FSC147.

Key Results

  • Improved Accuracy on FSC147: Their "Diverse Generation" strategy significantly improves counting accuracy (reduces MAE) for both SAFECount and CounTR models on FSC147 compared to baseline augmentations and traditional methods. For example, on the validation set, they achieve a reduction in MAE of up to 10% for SAFECount and 11% for CounTR compared to traditional augmentations.
  • State-of-the-Art Generalization on CARPK: When fine-tuned on CARPK, their model trained with diverse augmentations achieves state-of-the-art counting accuracy (4.87 MAE / 6.17 RMSE) among class-agnostic models.
  • Impact of Hyperparameters: Ablation studies show that a caption similarity threshold of $t_c = 0.7$ offers a good balance between diversity and quality. They also found that a probability of $p_c = 0.5$ for diverse samples and a synthetic data ratio ($p_0$) of 0.5 provide optimal performance.

Limitations and Future Work

  • Exemplar Box Mismatch: A key limitation is that changing captions can alter object semantics, potentially leading to exemplar bounding boxes that no longer perfectly fit the generated objects. While they explored using SAM for segmentation to refine boxes, it did not yield improvements, possibly due to inaccurate segmentation.
  • Ground Truth Dependency: The method still relies on having ground truth density maps and exemplar bounding boxes for the original training data.
  • Future Work: The authors suggest extending the approach by swapping both captions and density maps, developing a suitable similarity metric for density maps, and adapting the strategy to other tasks like object detection and semantic segmentation. They also mention that the exemplar boxes might need refinement for more accurate results in certain cases.

Summary updated

BibTeX
@inproceedings{doubinsky2024semantic,
  author = {Perla Doubinsky and Nicolas Audebert and Michel Crucianu and Hervé Le Borgne},
  title = {{Semantic Generative Augmentations for Few-Shot Counting}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2024},
}
Figure