본문 바로가기

실험결과 재현

[실험결과 재현 # 12] Feature Alignment and Uniformity for Test Time Adaptation, CVPR 2023

※ 본 포스팅에서는 Feature Alignment and Uniformity for Test Time Adaptation(CVPR 2023) 논문의 실험결과 재현 내용을 다뤘습니다.

 

논문 링크 : https://arxiv.org/abs/2303.10902

 

Feature Alignment and Uniformity for Test Time Adaptation

Test time adaptation (TTA) aims to adapt deep neural networks when receiving out of distribution test domain samples. In this setting, the model can only access online unlabeled test samples and pre-trained models on the training domains. We first address

arxiv.org


본 포스팅에서는 실험결과 재현을 위해서 RTX 3090을 사용하였다. 

TSD 방법 구조

1) Installation

# 가상환경 생성
conda create –n name python==3.8.13 

# 가상환경 활성화
conda activate name

# 파이토치 설치
pip install torch==1.12.0+cu113 torchvision==0.13.0+cu113 torchaudio==0.12.0 --extra-index-url https://download.pytorch.org/whl/cu113

# 라이브러리 설치
pip install numpy==0.13.0
pip install tqdm=4.65.0
pip install timm==0.6.12
pip install scikit-learn==1.2.2
pip install pillow==9.0.1

 

2) Data Preparation

 본 포스팅에서는 TSD 깃허브에서 제시한 PACS 데이터셋을 다운로드하였다.

PACS 데이터셋 구조


3) Train source model, Test-Time adaptation

# Train (오류 발생)
cd code/
python train.py --dataset PACS \
                --data_dir your_data_dir \
                --opt_type Adam \
                --lr 5e-5 \
                --max_epoch 50

mlp_mixer_b16_path가 정의되지 않았다는 오류가 발생하였다.

해당 오류가 발생하는 부분에서 실제로 사용하지 않아 주석처리하였다.

 

해당 부분을 주석처리 후 잘 실행되는 것을 확인할 수 있다. 

 

실행한 결과 다음과 같이 나왔다.

total cost time:1434.41938662529, valid acc:0.9769, target acc:0.8281

# Test-time adaptation
python unsupervise_adapt.py --dataset PACS \
                            --data_dir your_data_dir \
                            --adapt_alg TSD \ 
                            --pretrain_dir your_pretrain_model_dir \
                            --lr 1e-4

 

4) Reproduction result

Method Table 2 재현결과
T3A 86.04 85.21
BN 85.03 86.87
TSD 89.41 91.41

 

 윗 표는 PACS 데이터셋에 대한 논문 결과 및 재현 결광 대한 정량적 결과를 보여주며, Metod에서 T3A, BN, TSD는 논문의 제시된 Table 2에서 가져온 결과이다.

TSD의 논문 결과와 재현 결과는 0.2정도 차이나다. 그러나 BN, T3A에서 유사성을 확인할 수 있었다. 즉, 본 포스팅에서 재현한 정량적 결과가 신뢰성이 있다고 판단된다. 

 

5) 참고 문헌

[1] Wang, Shuai, et al. "Feature alignment and uniformity for test time adaptation." Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. 2023.