This is the official project repository for Beyond Entropy: Region Confidence Proxy for Wild Test-Time Adaptation and 中文博客 🔗 by Zixuan Hu, Yichun Hu, Xiaotong Li, Shixiang Tang and Ling-Yu Duan (ICML 2025).
Wild Test-Time Adaptation (WTTA) is proposed to adapt a source model to unseen domains under extreme data scarcity and multiple shifts. Previous approaches mainly focused on sample selection strategies, while overlooking the fundamental problem on underlying optimization. Initially, we critically analyze the widely-adopted entropy minimization framework in WTTA and uncover its significant limitations in noisy optimization dynamics that substantially hinder adaptation efficiency. Through our analysis, we identify region confidence as a superior alternative to traditional entropy, however, its direct optimization remains computationally prohibitive for real-time applications. In this paper, we introduce a novel region-integrated method ReCAP that bypasses the lengthy process. Specifically, we propose a probabilistic region modeling scheme that flexibly captures semantic changes in embedding space. Subsequently, we develop a finite-to-infinite asymptotic approximation that transforms the intractable region confidence into a tractable and upper-bounded proxy. These innovations significantly unlock the overlooked potential dynamics in local region in a concise solution. Our extensive experiments demonstrate the consistent superiority of ReCAP over existing methods across various datasets and wild scenarios.
Method: Region Confidence Adaptive Proxy (ReCAP)
- Clone the repo:
git clone https://github.com/hzcar/ReCAP.git
-
ReCAP depends on:
- CUDA 11.8
- Python 3.9
- Pytorch = 2.3.1 + cu118
- Pillow = 11.0.0
-
Create a new environment:
conda create -n recap python=3.9 -y pip install torch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cu118 pip install pycm matplotlib einops timm
This repository contains code for evaluation on ImageNet-C 🔗 with ResNet-50 and VitBase. But feel free to use your own data and models!
-
Step 1: Download ImageNet-C 🔗 dataset from here 🔗.
-
Step 2: Put IamgeNet-C at "--data_corruption".
python main.py --data_corruption /path/to/imagenet-c --exp_type [bs1/mix_shifts/label_shifts] --method [no_adapt/tent/eata/sar/deyo/recap_plpd] --model [resnet50_gn_timm/vitbase_timm] --output /output/dir
'--exp_type' is choosen from:
-
'bs1' means single sample adaptation, only one sample comes each time-step
-
'mix_shifts' conducts exps over the mixture of 15 corruption types in ImageNet-C
-
'label_shifts' means exps under online imbalanced label distribution shifts. Moreover, imbalance_ratio indicates the imbalance extent
While the basic ReCAP implementation offers fast test-time adaptation, it does not include a specially designed multi-round selection mechanism, which can lead to higher variance across runs.
We recommend using recap_plpd for more stable performance with lower standard deviation in wild TTA settings:
python main.py --exp_type mix_shifts --method recap_plpd --model resnet50_gn_timm
python main.py --exp_type mix_shifts --method recap_plpd --model vitbase_timm
python main.py --exp_type label_shifts --method recap_plpd --model resnet50_gn_timm
python main.py --exp_type label_shifts --method recap_plpd --model vitbase_timm
python main.py --exp_type bs1 --method recap_plpd --model resnet50_gn_timm
python main.py --exp_type bs1 --method recap_plpd --model vitbase_timm
To facilitate adaptation of ReCAP to broader task types, we provide a modular and easily pluggable implementation in [recap.py].
The core loss function is implemented to directly replace traditional entropy loss, making it simple to integrate into existing adaptation pipelines.
Please contact Zixuan Hu by [hzxuan at pku.edu.cn] if you have any questions.
This repository is built using the SAR and DeYO repository. Thanks for their excellent projects!
If our ReCAP method are helpful in your research, please consider citing our paper:
@inproceedings{
hu2025beyond,
title={Beyond Entropy: Region Confidence Proxy for Wild Test-Time Adaptation},
author={Zixuan Hu and Yichun Hu and Xiaotong Li and SHIXIANG TANG and LINGYU DUAN},
booktitle={Forty-second International Conference on Machine Learning},
year={2025},
url={https://openreview.net/forum?id=QwxjjaGBUo}
}