Home

Awesome

Entropy is not Enough for Test-Time Adaptation: From the Perspective of Disentangled Factors

PWC MIT License

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

$ chmod +x exp_deyo.sh
$ ./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 šŸ”—.