Abstract
Large vision-language models (VLMs) like CLIP have demonstrated remarkable zero-shot capabilities, yet they often require test-time adaptation to handle complex real-world domain shifts. Current approaches, such as Test-Time Prompt Tuning (TPT), focus on optimizing text prompts through backpropagation, which is computationally expensive and requires access to model gradients. This paper introduces MTA (Robust MeanShift for Test-time Augmentation), a training-free, plug-and-play method that refines visual representations in the embedding space. By treating test-time augmentation as a robust density mode-seeking problem, MTA identifies the most representative "mode" of multiple augmented views while filtering out noisy outliers. Experimental results across 15 datasets show that MTA outperforms TPT in accuracy while being three times faster and compatible with black-box APIs.
Introduction
Vision-language models have revolutionized zero-shot classification by aligning visual and textual representations. However, their performance can degrade when encountering out-of-distribution data. To mitigate this, researchers have turned to test-time adaptation, specifically Test-Time Prompt Tuning (TPT). TPT attempts to optimize the text prompt (e.g., "a photo of a [class]") to better align with a specific test image.
Despite its success, TPT suffers from three critical limitations: it is computationally heavy due to the need for backpropagation, it requires internal access to model weights (precluding its use with proprietary APIs like GPT-4V), and it relies on heuristic filtering to manage poor-quality image augmentations. This research challenges the necessity of prompt learning, proposing instead that refining the visual representation itself is a more efficient and effective path to generalization.
Methodology: Robust MeanShift for Test-Time Augmentation (MTA)
MTA shifts the focus from the text prompt to the image embedding. It treats the collection of augmented views of a single test image as a distribution and seeks the most representative "mode" within that distribution. The process follows five key steps:
- Augmentation: For a given test image, $N$ different views are generated using techniques such as random cropping or diffusion models.
- Embedding: These views are processed through the model's visual encoder to generate a set of feature vectors.
- Robust MeanShift: Rather than simple averaging, which is vulnerable to "garbage" views (e.g., a crop that misses the subject), MTA employs a modified MeanShift algorithm to find the central density of the embeddings.
- Inlierness Scoring: MTA jointly optimizes for a central mode and an "inlierness score" for each view. Consistent views receive high scores, while noisy or degenerate views are automatically down-weighted.
- Efficient Optimization: The method uses block coordinate descent, an iterative approach that requires no training, no hyperparameter tuning, and automatically adapts its search radius (bandwidth) based on local data density.
Because MTA operates solely on the final embeddings, it functions as a modular component that can be applied to any VLM, including black-box models.
Experimental Setup
The authors evaluated MTA across an extensive benchmark of 15 datasets to test its robustness and fine-grained classification capabilities:
- Generalization and Robustness: ImageNet and its variants (ImageNet-A, -V2, -R, and -Sketch) were used to measure performance under natural domain shifts.
- Fine-Grained Classification: 10 specialized datasets were included, covering domains such as scenes (SUN397), pets (OxfordPets), flowers (Flowers102), cars (StanfordCars), and satellite imagery (EuroSAT).
Results and Discussion
Superior Accuracy and Robustness
MTA consistently outperformed TPT across the benchmark. On ImageNet variants, MTA achieved an average accuracy of 63.16%, compared to TPT's 62.40%. The method proved particularly effective in fine-grained tasks, showing systematic improvements in categories like Aircraft and EuroSAT. By focusing on the "mode" of the distribution, MTA naturally ignores the outliers that often confuse standard averaging or heuristic-based filtering.
Efficiency and Speed
One of the most significant advantages of MTA is its computational efficiency. By avoiding backpropagation and the need for a second forward pass through the text encoder, MTA is approximately 3x faster than TPT per image. This makes it far more suitable for real-time applications where latency is a primary concern.
Black-Box Compatibility and Synergy
Unlike prompt-tuning methods, MTA does not require access to the model's internal gradients. This allows it to be used with proprietary models served via API. Furthermore, MTA exhibits strong synergy with existing few-shot learning methods like CoOp. While TPT can sometimes degrade performance when applied on top of few-shot methods, MTA provides a consistent performance boost.
Conclusion
MTA demonstrates that sophisticated prompt learning is not always necessary for effective test-time adaptation. By refining visual representations through robust mode-seeking, MTA provides a faster, more accurate, and more flexible alternative to gradient-based methods. Future work may explore extending this robust density estimation to other modalities or integrating more advanced augmentation strategies, such as diffusion-based generation, to further push the boundaries of zero-shot generalization.
Summary updated