This repository provides the official PyTorch implementation of our AAAI 2024 paper:
Robust Test-Time Adaptation for Zero-Shot Prompt Tuning Authors: Ding-Chu Zhang*, Zhi Zhou*, Yu-Feng Li
For more details, please check out our paper.
Install pip environment
pip install -r requirements.txt
Install conda environment
conda install --yes --file requirements.txt
Download the datasets CIFAR10-C, CIFAR100-C,ImageNet-R and TinyImageNet-C.
Download cross-validation datasets by TPT.
-
Place the dataset in the
./MyDATA
folder -
Run Adaprompt
python ./test.py ./MyDATA --test_sets CIFAR10_C -a ViT-B/16 -b 64 --gpu 0 --tpt --ctx_init a_photo_of_a --result-dir ./results/ours --method-config ./configs/methods/ours.yaml
-
Run TPT
python ./test.py ./MyDATA --test_sets CIFAR10_C -a ViT-B/16 -b 64 --gpu 0 --tpt --ctx_init a_photo_of_a --result-dir ./results/tpt --method-config ./configs/methods/tpt.yaml
-
Run Source
python ./test.py ./MyDATA --test_sets CIFAR10_C -a ViT-B/16 -b 64 --gpu 0 --tpt --ctx_init a_photo_of_a --result-dir ./results/source --method-config ./configs/methods/source.yaml
-
The results will be printed and stored in
./results/.
We thank the authors for the following repositories for code reference: TPT.