Home

Awesome

🌄 Efficient Test-Time Model Adaptation without Forgetting

This is the official project repository for Efficient Test-Time Model Adaptation without Forgetting 🔗 by Shuaicheng Niu, Jiaxiang Wu, Yifan Zhang, Yaofo Chen, Shijian Zheng, Peilin Zhao and Mingkui Tan (ICML 2022).

🌄 EATA conducts model learning at test time to adapt a pre-trained model to test data that has distributional shifts ☀️ 🌧 ❄️, such as corruptions, simulation-to-real discrepancies, and other differences between training and testing data.

Installation:

EATA depends on

Data preparation:

This repository contains code for evaluation on ImageNet and ImageNet-C 🔗 with ResNet models. But feel free to use your own data and models!

Usage:

import eata

model = TODO_model()

model = eata.configure_model(model)
params, param_names = eata.collect_params(model)
optimizer = TODO_optimizer(params, lr=2.5e-4)
adapt_model = eata.EATA(model, optimizer, fishers, e_margin, d_margin) 

outputs = adapt_model(inputs)  # now it infers and adapts!

Notes:

Example: Adapting a pre-trained ResNet-50 model on ImageNet-C (Corruption).

Usage:

python3 main.py --data /path/to/imagenet --data_corruption /path/to/imagenet-c --exp_type 'continual' or 'each_shift_reset' --algorithm 'eata' or 'eta' or 'tent' --output /output/dir

'--exp_type' is choosen from:

'--algorithm' is chosen from:

Results:

Here, we report the results on ImageNet-C, severity level = 5, with ResNet-50.

MethodGauss.ShotImpul.Defoc.GlassMotionZoomSnowFrostFogBrit.Contr.ElasticPixelJPEGAvg. #ForwardsAvg. #Backwards
R-50 (GN)+JT94.995.194.288.991.786.781.682.581.880.649.287.476.979.268.550,0000
+TTT 🔗69.066.466.671.992.266.863.259.181.049.038.261.150.648.352.050,000✖️2150,000✖️20
R-50 (BN)97.897.198.282.190.285.277.583.176.775.641.194.683.179.468.450,0000
+Tent 🔗71.669.869.971.872.758.650.552.958.742.532.674.945.241.547.750,00050,000
+ETA (ours)64.962.163.466.167.152.247.448.154.239.932.155.042.139.145.150,00026,031
+EATA (ours)65.063.164.366.366.652.947.248.654.340.132.055.742.439.345.050,00025,150
+EATA (lifelong)65.061.963.266.265.852.746.848.954.440.332.055.842.839.645.350,00028,243
<!-- | +TTA | 95.9 | 95.1 | 95.5 | 87.5 | 91.8 | 87.1 | 74.2 | 86.0 | 80.9 | 78.7 | 47.0 | 87.6 | 85.4 | 75.4 | 66.4 | 50,000✖️64 | 0 | --> <!-- | +BN | 84.5 | 83.9 | 83.7 | 80.0 | 80.0 | 71.5 | 60.0 | 65.2 | 65.0 | 51.5 | 34.1 | 75.9 | 54.2 | 49.3 | 58.9 | 50,000 | 0 | --> <!-- | +MEMO | 92.5 | 91.3 | 91.0 | 80.3 | 87.0 | 79.3 | 72.4 | 74.7 | 71.2 | 67.9 | 39.0 | 89.0 | 76.2 | 67.0 | 62.5 | 50,000✖️65 | 50,000✖️64 | --> <p align="center"> <img src="figures/forgetting_results.png" alt="forgetting_results" width="100%" align=center /> </p>

Please see our PAPER 🔗 for detailed results.

Correspondence

Please contact Shuaicheng Niu by niushuaicheng [at] gmail.com 📬.

Citation

If the EATA method or fully test-time adaptation without forgetting are helpful in your research, please consider citing our paper:

@InProceedings{niu2022efficient,
  title={Efficient Test-Time Model Adaptation without Forgetting},
  author={Niu, Shuaicheng and Wu, Jiaxiang and Zhang, Yifan and Chen, Yaofo and Zheng, Shijian and Zhao, Peilin and Tan, Mingkui},
  booktitle = {The Internetional Conference on Machine Learning},
  year = {2022}
}

Acknowledgment

The code is greatly inspired by (heavily from) the Tent 🔗 and TTT 🔗.