TL;DR
Few-shot Test-Time Domain Adaptation (FSTT-DA) aims to adapt models to unseen target domains using only a few unlabeled samples at test time. While foundation models like CLIP offer strong out-of-distribution capabilities, relying solely on their frozen feature space limits adaptation on novel downstream datasets, especially for smaller backbones like ViT-B/16. This paper introduces Learning to Complement (L2C), a framework that trains a lightweight parallel network directly on the input space to capture dataset-specific visual knowledge, while simultaneously optimizing text feature discrimination for robust domain-aware fusion.
What Problem Does This Paper Address?
Deep learning models often fail when deployed in real-world scenarios with domain shifts (e.g., changes in lighting, camera types, or geographic locations). Few-shot Test-Time Domain Adaptation (FSTT-DA) tackles this by adapting a source-trained model to an unseen target domain using just a few unlabeled examples at test time.
State-of-the-art methods leverage vision-language models like CLIP by keeping them frozen and generating domain-specific prompts in the feature space (e.g., VDPG). However, because CLIP hasn't explicitly seen these downstream datasets, its feature space knowledge is inherently constrained by its prior training. As a result, performance plummets on challenging real-world benchmarks when using smaller, less robust backbones like ViT-B/16.
Methods
The authors propose Learning to Complement (L2C), which adapts both visual and text features without modifying the internal weights of CLIP:
- Parallel CPNet & Revert Attention: A lightweight side network (CPNet) runs in parallel with the CLIP image encoder, taking raw input space tokens. To ensure it only learns new dataset-specific knowledge missing from CLIP, a parameter-free Revert Attention mechanism calculates the complement of the attention between CLIP and CPNet outputs, forcing CPNet to focus on CLIP's blind spots.
- Greedy Text Ensemble & Refinement: To improve downstream adaptation, the authors enhance the discrimination (inter-dispersion) of text features. They use a greedy text ensemble strategy as a pre-processing step to select optimal prompt templates, followed by a lightweight refinement module trained with a uniformity loss to maximize class differentiation.
- Domain-Aware Fusion (DAF): At test time, a few unlabeled images are reshaped to compute inter-instance relations, capturing domain-specific cues. This information queries a learnable Key-Value domain cache to generate a domain prompt. This prompt guides the cross-attention-based fusion of the complemented visual features and enhanced text features.
Datasets
The method is evaluated on five large-scale benchmarks:
- DomainNet: A massive dataset containing 569K images across 345 classes and 6 distinct domains (Clip, Info, Paint, Quick, Real, Sketch).
- WILDS Benchmarks: Real-world datasets with severe domain shifts and data imbalances, including:
- iWildCam: Wildlife camera trap classification.
- Camelyon17: Tumor detection in medical imaging.
- FMoW: Functional Map of the World satellite imagery classification.
- PovertyMap: A satellite imagery regression task for wealth index estimation.
Key Insights and Ideas
- Input Space vs. Feature Space: Relying purely on prompting a frozen feature space limits what a model can adapt to. Learning directly from the input space via a parallel branch allows the system to capture dataset-specific nuances that CLIP's generalized pre-training completely missed.
- Revert Attention as a Filter: Instead of letting the side network learn redundant features, Revert Attention explicitly forces it to focus on the "blind spots" of the foundation model.
- Text Features Matter in Vision Adaptation: Domain shift doesn't just affect images; it affects how well text prototypes separate classes. Maximizing text feature inter-dispersion (making class text embeddings more distinct) acts as a powerful regularizer that prevents domain bias from muddying classification boundaries.
Key Results
L2C significantly outperforms prior state-of-the-art methods, particularly when using the smaller ViT-B/16 backbone:
- On iWildCam, L2C achieves a +5.1 gain in Macro F1 score over VDPG using ViT-B/16.
- On FMoW, it improves Worst-Case Accuracy (WC Acc) by +3.1% for ViT-B/16 and +0.3% for ViT-L/14.
- On DomainNet, L2C achieves top accuracy in 5 out of 6 domains with a ViT-L/14 backbone, yielding an average accuracy improvement of +2.2%.
- Efficiency: Crucially, during inference, the text encoder, text refinement module, and K-V cache can be discarded, making the framework highly computationally efficient.
Limitations and Future Work
The authors note that if a downstream dataset diverges drastically from CLIP's pre-training data, the burden on the parallel CPNet increases significantly. This scenario might necessitate a larger, more parameter-heavy side network. Future work could explore more adaptive scaling of the side network depending on the severity of the domain/dataset gap.
Summary updated