Entropy is not Enough for Test-Time Adaptation: From the Perspective of Disentangled Factors
May 21, 2024 ยท View on GitHub
This is the official implementation of Entropy is not Enough for Test-Time Adaptation: From the Perspective of Disentangled Factors ๐
by Jonghyun Lee, Dahuin Jung, Saehyung Lee, Junsung Park, Juhyeon Shin, Uiwon Hwang and Sungroh Yoon (ICLR 2024 Spotlight, Top-5% of the submissions).
This implementation is based on SAR implementation ๐.
Environments
You should modify [username] and [env_name] in environment.yaml, then
$ conda env create --file environment.yaml
Baselines
TENT ๐ (ICLR 2021)
EATA ๐ (ICML 2022)
SAR ๐ (ICLR 2023)
Dataset
You can download ImageNet-C from a link ImageNet-C ๐.
After downloading the dataset, move to the root directory ([data_root]) of datasets.
If you run on ColoredMNIST ๐ or Waterbirds ๐, run
$ python pretrain_[dataset_name].py --root_dir [data_root] --dset [dataset_name]
Then datasets are automatically downloaded in your [data_root] directory.
(ColoredMNIST from torchvision ๐ and ./dataset/ColoredMNIST_dataset.py, Waterbirds from wilds ๐ package)
Your [data_root] will be as follows:
data_root
โโโ ImageNet-C
โ โโโ brightness
โ โโโ contrast
โ โโโ ...
โโโ ColoredMNIST
โ โโโ ColoredMNIST_model.pickle
โ โโโ MNIST
โ โโโ train1.pt
โ โโโ train2.pt
โ โโโ test.pt
โโโ Waterbirds
โ โโโ metadata.csv
โ โโโ waterbirds_dataset.h5py
โ โโโ waterbirds_pretrained_model.pickle
โ โโโ 001. Black_footed_Albatross
โ โโโ 002. Laysan_Albatross
โโโ โโโ ...
If you don't want to pre-train, you can just copy and paste the [dataset_name]_model.pickle from './pretrained/' directory.
Experiment
You can run most of the experiments in our paper by
./exp_deyo.sh
If you want to run on the ImageNet-R or VISDA-2021, you should use main_da.py
You should modify ROOT variable as [data_root] in exp_deyo.sh.
Citation
If our DeYO method or biased test-time adaptation settings are helpful in your research, please consider citing our paper:
@inproceedings{
lee2024entropy,
title={Entropy is not Enough for Test-Time Adaptation: From the Perspective of Disentangled Factors},
author={Jonghyun Lee and Dahuin Jung and Saehyung Lee and Junsung Park and Juhyeon Shin and Uiwon Hwang and Sungroh Yoon},
booktitle={The Twelfth International Conference on Learning Representations},
year={2024},
url={https://openreview.net/forum?id=9w3iw8wDuE}
}
Acknowledgment
The code is inspired by the Tent ๐, EATA ๐, and SAR ๐.