AD-CLIP: Adapting Domains in Prompt Space Using CLIP

Mainak Singha, Harsh Pal, Ankit Jha, Biplab Banerjee

TL;DR

AD-CLIP is a novel framework for unsupervised domain adaptation (UDA) that leverages the rich semantic space of the CLIP foundation model by learning domain-agnostic, image-conditioned prompts. By extracting multi-scale style and content features from a frozen vision backbone, it effectively bridges the gap between disparate data distributions, setting new performance benchmarks on standard UDA datasets.

What Problem Does This Paper Address?

Deep learning models are notoriously brittle when faced with domain shift—the phenomenon where a model trained on one dataset (the source) performs poorly on a different, albeit related, dataset (the target). For example, a classifier trained on studio photos of office supplies might struggle to recognize the same objects in hand-drawn sketches.

Unsupervised Domain Adaptation (UDA) aims to solve this by using labeled source data and unlabeled target data to align their feature distributions. However, traditional UDA methods typically rely on visual-only backbones (like ResNet) that lack semantic depth. While vision-language models like CLIP offer a semantically rich joint embedding space, their potential for UDA hasn't been fully tapped. Existing prompt-learning techniques often fail in UDA because they don't explicitly account for domain independence, leading to prompts that are biased toward the source domain.

Methods

The authors introduce AD-CLIP, which adapts domains in the prompt space rather than fine-tuning the entire model. The core idea is to keep the CLIP vision ($f_v$) and text ($f_t$) backbones frozen and learn a small set of projector networks.

Key components include:

  • Domain-Agnostic Prompting: Instead of static prompts, AD-CLIP generates prompts dynamically. The prompt structure includes Domain tokens ($D_t, D_s$) and Image-specific tokens ($V_1, \dots, V_L$).
  • Multi-Scale Feature Extraction: The model leverages features from multiple layers of CLIP’s vision encoder. A Style Projector ($P_v$) processes batch-wise feature statistics ($\mu, \sigma$) to capture domain style, while Content Projectors ($C_v$) process feature responses to capture class-specific visual concepts.
  • Style Mapping Network ($P_{smn}$): In many real-world scenarios, source data is unavailable during inference. AD-CLIP solves this by training a network to "hallucinate" source domain characteristics based on target domain properties, ensuring the prompt remains domain-agnostic even at test time.
  • Alignment Strategy: The model is trained using a combination of supervised contrastive loss on the source domain, entropy minimization on the target domain to ensure confident predictions, and a KL-divergence loss to align the prompt embedding distributions of both domains.
Figure 3: The architecture of AD-CLIP is based on the frozen CLIP backbones fv and ft. For prompt token learning, we introduce the new vision and text projectors Pv and Cv, respectively, which encoder the style and content information from the different layers of fv. The style mapping network, Psmn, approximates the source domain style information from the target domain features. Best viewed in color.

Datasets

The authors evaluated AD-CLIP on three widely recognized UDA benchmarks:

  1. Office-Home: 15,500 images across 65 categories and 4 domains (Art, Clipart, Product, Real World).
  2. VisDA-2017: A large-scale synthetic-to-real challenge featuring 12 categories.
  3. Mini-DomainNet: A subset of the massive DomainNet dataset, featuring 126 categories across 4 domains (Clipart, Painting, Real, Sketch).

Key Insights and Ideas

  • Prompts as Bridges: By conditioning prompts on both style (domain) and content (class), the model learns to "describe" images in a way that is invariant to their source.
  • The Power of Multi-Scale: The authors found that incorporating visual information from multiple layers of the vision encoder—rather than just the final layer—significantly improves performance. This allows the model to capture both low-level textures (style) and high-level semantics (content) more effectively.
  • Semantic Richness Overcomes Visual Gaps: AD-CLIP significantly outperforms traditional CNN and Transformer-based UDA methods. This suggests that the pre-existing semantic knowledge in CLIP provides a much stronger foundation for domain alignment than visual features alone.
AD-CLIP shows a significant accuracy boost over traditional methods like DANN and recent prompt-based methods like DAPL.

Key Results

AD-CLIP established new state-of-the-art results across all tested benchmarks:

  • Office-Home: Achieved 90.5% average accuracy (with ViT-L/14), surpassing the previous best (DAPL) by 1.8%.
  • VisDA-2017: Reached 92.7% accuracy, a 2.2% improvement over DAPL.
  • Mini-DomainNet: Achieved 91.4% accuracy, outperforming the baseline by 1.6%.
  • Efficiency: Despite the performance gains, AD-CLIP is computationally efficient, requiring only ~0.18% more GFLOPs than the nearest competitor, DAPL.

Limitations and Future Work

While AD-CLIP is highly effective, the authors noted that on the VisDA-2017 dataset, it did not outperform specialized Transformer-based methods (like SSRT or CDTrans) on specific classes like car, knife, person, and plant when using a ResNet-101 backbone.

Future research directions include extending the AD-CLIP framework to more specialized tasks, such as person re-identification and medical imaging, where domain shift is a critical barrier to deployment.

Summary updated

BibTeX
@inproceedings{singha2024ad,
  author = {Mainak Singha and Harsh Pal and Ankit Jha and Biplab Banerjee},
  title = {{AD-CLIP: Adapting Domains in Prompt Space Using CLIP}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2024},
  url = {https://openreview.net/forum?id=TDd4B3C7Mc},
}
Figure