Cap2Aug: Caption guided Image to Image data Augmentation

Aniket Roy, Anshul Shah, Ketul Shah, Anirban Roy, Rama Chellappa

TL;DR

Cap2Aug is a novel data augmentation framework designed for low-data regimes that leverages image captioning and image-to-image diffusion models to generate semantically diverse training samples. By mixing images and captions within the same class and applying a Maximum Mean Discrepancy (MMD) loss, it successfully injects rich semantic variations while minimizing the domain gap between real and synthetic data. The method yields consistent performance gains across multiple few-shot and long-tail classification benchmarks.

What Problem Does This Paper Address?

Deep learning models are notoriously data-hungry. In low-data regimes—such as few-shot learning (where only 1 to 5 examples per class are available) or long-tail classification (where a few classes dominate and many have very few samples)—models easily overfit.

Traditional data augmentation techniques like rotating, flipping, or cropping help, but they offer very limited semantic variety. While modern generative models (like Stable Diffusion) can create realistic images from scratch, simply generating images from class labels often fails to capture the specific contextual distributions of the training dataset. Furthermore, introducing purely synthetic images creates a "domain gap" (differences in style, background, and color distributions) that can actually degrade classifier performance. Cap2Aug addresses these challenges by using the existing training images as structural anchors and editing them using text prompts derived from the dataset itself.

Methods

The Cap2Aug framework consists of four main components:

  1. Caption Generation: For each image $I_i$ in a given class, the authors use an off-the-shelf BLIP model to generate a descriptive caption $C_i$.
  2. Caption-Guided Image-to-Image Translation: Instead of just pairing an image with its own caption, Cap2Aug performs cross-image-caption pairing. It takes an image $I_i$ and pairs it with a caption $C_j$ from a different image within the same class. This pair is fed into an image-to-image Stable Diffusion model (via SDEdit). This process forces the model to translate the style or context of one image onto the structure of another, creating highly diverse yet class-consistent variations.
  3. Cache-Based Adapter: Built on top of a frozen CLIP visual encoder, a two-layer MLP key-value cache model (inspired by Tip-Adapter) is trained using cross-entropy loss to integrate the features of both real and synthetic images.
  4. Domain Alignment via MMD: To combat the domain shift between real and synthetic images, the authors introduce a multi-kernel Maximum Mean Discrepancy (MMD) loss. This loss minimizes the distance between the mean feature embeddings of the real and synthetic image distributions, ensuring the classifier learns features that generalize well to real-world data.
Figure 1: Idea of Cap2Aug: real images I1 (guitar) and I2 (person playing guitar) are fed to a captioning model to gen- erate “a red electric guitar with a white background” (C1) and “a man with a guitar” (C2) as captions, respectively. Im- age I1 and caption C1 when fed to an image-to-image dif- fusion model generates a synthetic image I1C1 - the image of a guitar similar to I1 with minor changes (fine changes in guitar head, body). On the other hand, when image I1 and caption C2 are fed to the image-to-image diffusion model, it generates a man with a guitar in his hand (I1C2). This is replicated using image I2 for generating synthetic images I2C1 and I2C2 respectively using captions C1 and C2.

Datasets

The authors comprehensively evaluated Cap2Aug across two distinct tasks:

  • Few-Shot Classification: Evaluated on 11 diverse benchmark datasets, including ImageNet, Stanford-Cars, UCF101, Caltech101, Flowers102, SUN397, DTD, EuroSAT, FGVCAircraft, OxfordPets, and Food101.
  • Long-Tail Classification: Evaluated on the large-scale ImageNet-LT benchmark, which contains a highly unbalanced distribution of classes.

Key Insights and Ideas

  • The Power of Cross-Captioning: Generating synthetic images using an image's own caption yields minor stylistic changes. However, cross-captioning (applying Caption B to Image A) acts as a powerful semantic blender. For example, applying the caption "a man with a guitar" to a standalone image of a guitar generates a completely new composition of a person playing a guitar, significantly expanding intra-class diversity.
  • The Synthetic Domain Trap: Purely relying on high-quality generative models isn't enough. The authors show that synthetic images exhibit distinct color and intensity histograms compared to real images. Without explicit feature-level alignment (like the proposed MMD loss), this domain gap limits the utility of synthetic augmentations.
  • Label-Free Guidance: Cap2Aug does not explicitly use class labels to prompt the diffusion model. This prevents the generative model from falling back on generic, pre-trained concepts of a class, anchoring the augmentations to the actual visual nuances present in the training subset.

Key Results

Cap2Aug consistently outperformed state-of-the-art few-shot methods like Tip-Adapter and CoOp:

  • ImageNet Few-Shot: Cap2Aug achieved 66.32% accuracy in the 16-shot setting, outperforming Tip-F (65.51%) and CoOp (62.95%).
  • ImageNet-LT (Long-Tail): The method achieved an overall accuracy of 70.9%, outperforming the previous best method, VL-LTR (70.1%). Crucially, the highest performance jump was observed in the few-shot categories (moving from 50.8% to 51.9%), proving the efficacy of the augmentation where data was scarcest.

Limitations and Future Work

The authors noted that Cap2Aug struggles with fine-grained classification tasks (e.g., FGVCAircraft, OxfordPets, and Food101).

This limitation stems from the captioning model's granularity. For instance, an aircraft model might be captioned generically as "a white and blue jet," losing the specific wing or fuselage details essential for fine-grained aircraft recognition. Similarly, errors in the captioning model (such as miscaptioning a "samosa" as a "plate of chicken wings") lead to semantically incorrect synthetic images that confuse the classifier. The authors plan to address these fine-grained detail extractions in future work.

Summary updated

BibTeX
@misc{roy2022cap,
  author = {Aniket Roy and Anshul Shah and Ketul Shah and Anirban Roy and Rama Chellappa},
  title = {{Cap2Aug: Caption guided Image to Image data Augmentation}},
  year = {2022},
  eprint = {2212.05404},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2212.05404},
}
Figure