Diverse Data Augmentation with Diffusions for Effective Test-time Prompt Tuning

Chun-Mei Feng, Kai Yu, Yong Liu, Salman H. Khan, Wangmeng Zuo

Abstract

Vision-language models (VLMs) like CLIP demonstrate remarkable zero-shot capabilities but often struggle with distribution shifts in real-world scenarios. Test-time Prompt Tuning (TPT) has emerged as a solution to adapt models to unseen domains on the fly. However, existing TPT methods are limited by simplistic data augmentations and unreliable selection criteria. This paper introduces DiffTPT, a novel framework that leverages pre-trained diffusion models to generate diverse, high-fidelity augmentations from a single test image. By combining these synthetic views with a cosine similarity-based filtration system, DiffTPT significantly enhances the robustness of VLMs, outperforming previous state-of-the-art methods by over 5% on average across various benchmarks.

Introduction

Large-scale vision-language models (VLMs) have set new benchmarks in zero-shot learning. Despite their success, these models remain sensitive to "distribution shifts"—variations in style, lighting, or perspective that differ from the training data, such as sketches, cartoons, or adversarial examples. To address this, researchers developed Test-time Prompt Tuning (TPT), which learns an adaptive text prompt for each test sample without requiring labeled training data.

While promising, current TPT approaches face two primary hurdles. First, they rely on basic augmentations like random cropping, which lack the visual diversity needed for true domain generalization. Second, they often use entropy-based selection to identify the best augmented views, which can lead the model to favor high-confidence but incorrect predictions. DiffTPT addresses these challenges by integrating generative diffusion models into the test-time adaptation pipeline.

The DiffTPT Framework

DiffTPT introduces a generative approach to data augmentation, moving beyond simple geometric transformations to create a rich "neighborhood" of data around a single test point.

1. Diffusion-based Augmentation

Instead of relying solely on traditional crops, DiffTPT utilizes the generative power of Stable Diffusion (SD-V2). The process begins by extracting the CLIP image features of the test sample. These features are then used to guide the diffusion model to generate new images that maintain the core semantics of the original while introducing significant variations in style and perspective. This provides the model with a much broader view of the possible domain space.

2. Cosine Similarity Filtration

Generative models can occasionally produce images that lose the identity of the original object (hallucinations). To ensure prediction fidelity, DiffTPT implements a filtration mechanism. It calculates the cosine similarity between the original image's features and the generated images' features. Only those synthetic images that exceed a specific similarity threshold are retained for the tuning process, ensuring that the diverse views remain semantically grounded.

3. Hybrid Optimization

The final prompt is optimized by minimizing the entropy of the average prediction across a combined pool of views. This pool includes both traditional local crops and the diverse global variations generated by the diffusion model. This hybrid strategy allows the model to benefit from both the local consistency of crops and the domain robustness provided by diffusion.

Experimental Evaluation

The authors evaluated DiffTPT across two primary scenarios to test its versatility and robustness:

  • Natural Distribution Shifts: Benchmarks included the ImageNet family (ImageNet-V2, ImageNet-A for adversarial samples, ImageNet-R for renditions, and ImageNet-Sketch).
  • Cross-Dataset Generalization: The method was tested on 10 diverse downstream datasets, ranging from specialized categories like OxfordPets and StanfordCars to satellite imagery (EuroSAT) and action recognition (UCF101).

Key Results and Insights

DiffTPT demonstrated a substantial performance leap over existing methods:

  • Accuracy Gains: The framework improved zero-shot accuracy by an average of 5.13% compared to the previous state-of-the-art TPT methods.
  • Adversarial Robustness: On the challenging ImageNet-A dataset, DiffTPT increased performance from 27.34% to 31.06% using a ResNet-50 backbone.
  • Zero-Shot vs. Few-Shot: Remarkably, DiffTPT—which uses no training labels—frequently outperformed established few-shot methods like CoOp and CoCoOp, even though those models are trained on 16 samples per class.

One of the most significant insights from this research is the Diversity-Fidelity Trade-off. While diffusion provides the necessary diversity, the cosine similarity filter acts as a crucial gatekeeper, ensuring the model does not adapt to spurious generative artifacts.

Limitations and Future Directions

The primary challenge for DiffTPT is the computational cost associated with inference. Running a diffusion model for every test sample is significantly slower than traditional cropping. While optimizations (such as reducing diffusion steps or using TensorRT) can lower generation time to approximately 0.5 seconds for 10 images, this remains a bottleneck for real-time applications.

Future research may focus on:

  • Integrating faster generative architectures, such as Consistency Models, to reduce latency.
  • Developing more advanced filtration techniques to further improve fidelity.
  • Expanding the generative augmentation strategy to other modalities, including video and 3D data.

Conclusion

DiffTPT represents a significant step forward in test-time adaptation. By bridging the gap between generative modeling and prompt tuning, it provides a robust framework for adapting VLMs to the complexities of the real world, proving that diverse, high-fidelity synthetic data is a powerful tool for zero-shot generalization.

Summary updated

BibTeX
@inproceedings{feng2023diverse,
  author = {Chun-Mei Feng and Kai Yu and Yong Liu and Salman H. Khan and Wangmeng Zuo},
  title = {{Diverse Data Augmentation with Diffusions for Effective Test-time Prompt Tuning}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2023},
}
Figure