Unleashing the Potential of All Test Samples: Mean-Shift Guided Test-Time Adaptation

Jizhou Han, Chenhao Ding, Songlin Dong, Xinyuan Gao, Qiang Wang, Yuhang He, Yihong Gong

TL;DR

MS-TTA introduces a training-free test-time adaptation (TTA) method for vision-language models that refines all test samples—including low-confidence ones—using a single-step k-nearest neighbors Mean-Shift. By optimizing feature representations beyond CLIP's original space, it significantly boosts classification accuracy under distribution shifts while maintaining real-time inference speeds.

What Problem Does This Paper Address?

Vision-language models (VLMs) like CLIP boast incredible zero-shot capabilities, but they frequently stumble when encountering "distribution shifts" at test time—such as changes in image style, lighting, or entirely new domains. Test-Time Adaptation (TTA) aims to fix this by adapting the model on the fly using unlabeled test data.

However, existing training-free TTA methods suffer from two main flaws:

  1. They operate strictly within CLIP's original feature space, assuming it is already optimal.
  2. They rely exclusively on "high-confidence" samples to build a dynamic cache, completely discarding low-confidence samples.

The authors argue that low-confidence samples—which often lie near decision boundaries or represent rare target-domain patterns—contain vital structural information. Ignoring them limits the model's adaptation performance and leaves it highly vulnerable to noisy pseudo-labels.

Illustration of how MS-TTA utilizes both high- and low-confidence samples compared to previous methods.

Methods

The authors propose MS-TTA (Mean-Shift Guided Test-Time Adaptation), a completely training-free framework that refines feature embeddings using a lightweight, single-step k-nearest neighbors (kNN) Mean-Shift algorithm.

The pipeline works as follows:

  1. Feature Extraction: A test image is passed through a frozen CLIP visual encoder to extract its raw embedding.
  2. Mean-Shift Refinement: Instead of using the raw embedding directly, MS-TTA identifies its $k$-nearest neighbors from a history of previously seen test samples. It then shifts the embedding toward the local density mode of these neighbors. A kernel weighting strategy balances the influence of the original feature versus its neighbors.
  3. Dynamic Caching: High-confidence, mean-shifted embeddings are saved into a key-value cache using an entropy minimization threshold.
  4. Logit Fusion: During inference, the final prediction is a linear combination of the original zero-shot CLIP prediction and the mean-shift-enhanced cache prediction.

Because it avoids backpropagation and prompt tuning, MS-TTA requires no parameter updates and is computationally lightweight.

Overview of the MS-TTA architecture and feature refinement pipeline.

Datasets

The method was extensively evaluated across two major TTA benchmarks:

  • Out-of-Distribution (OOD) Benchmark: Built on ImageNet, it includes four challenging variants: ImageNet-A (adversarial), ImageNet-R (renditions), ImageNet-V2 (robustness test), and ImageNet-S (sketch).
  • Cross-Dataset Benchmark: Consists of 10 diverse datasets spanning various visual categories: Aircraft, Caltech101, Stanford Cars, DTD (textures), EuroSAT (satellite imagery), Flowers102, Food101, Oxford Pets, SUN397 (scenes), and UCF101 (action videos).

Key Insights and Ideas

  • Low-Confidence Samples are Assets, Not Liabilities: Rather than filtering out ambiguous samples, MS-TTA demonstrates that smoothing them toward local neighbor clusters helps shape more accurate decision boundaries under domain shifts.
  • Breaking the Feature Space Ceiling: Prior training-free methods treated CLIP's feature space as a hard ceiling. MS-TTA proves that unsupervised clustering techniques can dynamically optimize and restructure embeddings during test time without modifying model weights.
  • The Power of a Single Step: Classical Mean-Shift is an iterative algorithm that is too slow for online deployment. The authors found that a single-step kNN variant provides the perfect sweet spot—delivering strong feature refinement while keeping processing speeds fast enough for real-time applications.

Key Results

MS-TTA consistently outperformed state-of-the-art training-free TTA methods (such as TDA and BoostAdapter) across both ResNet50 and ViT-B/16 backbones:

  • Cross-Dataset Performance: Using a ViT-B/16 backbone, MS-TTA surpassed all training-free competitors on 7 out of 10 datasets, achieving an average accuracy improvement of +0.80% over BoostAdapter. Notably, it saw a massive +3.99% boost on the challenging EuroSAT dataset.
  • OOD Robustness: On the OOD benchmark, MS-TTA achieved the highest average accuracy, notably boosting performance on the heavily shifted ImageNet-S dataset by +1.66% over the baseline.
  • Efficiency: MS-TTA runs at 10.05 FPS on a single NVIDIA RTX 3090 GPU with a minimal memory footprint of just 1.4 GB, proving its readiness for real-time deployment.
  • Plug-and-Play Capability: When integrated as a module into existing TTA frameworks like TDA and BoostAdapter, it consistently improved their baseline accuracies by +1.24% and +0.75%, respectively.

Limitations and Future Work

The authors note a couple of limitations and areas for future exploration:

  • Fixed Hyperparameters: The neighborhood size ($k$) and the scaling factor ($\alpha$) are currently fixed. Performance could be further optimized by developing adaptive neighborhood selection strategies tailored to specific dataset characteristics.
  • VLM Scope: The current work focuses primarily on CLIP-based single-image classification. Future work will explore expanding this Mean-Shift refinement technique to other vision-language architectures and broader downstream tasks.

Summary updated

BibTeX
@article{han2026unleashing,
  author = {Jizhou Han and Chenhao Ding and Songlin Dong and Xinyuan Gao and Qiang Wang and Yuhang He and Yihong Gong},
  title = {{Unleashing the Potential of All Test Samples: Mean-Shift Guided Test-Time Adaptation}},
  journal = {IEEE Trans. Circuits Syst. Video Technol.},
  year = {2026},
  doi = {10.1109/tcsvt.2026.3676383},
}
Figure