Skip to content

toshi2k2/CompnetDA

Repository files navigation

"A Bayesian Approach to OOD Robustness in Image Classification" [CVPR-2024] (Official Implementation)

PWC

Installation

The code has been tested on Python 3.9 and PyTorch GPU version 1.10.1, with CUDA-11.3.

Quick Start

cd CompDA

Put data in data/Robin folder and create a 'models' folder-

mkdir data && mkdir models && mkdir results && mkdir baseline_models

First train/finetune a VGG16(BN) model on OOD-CV(called ROBIN earlier) training data (to be used as backbone) and save it as

baseline_models/Robin-train-vgg_bn.pth

To run and evaluate experiment for VGG16 on OOD-CV dataset, run the following-

python Initialization_Code/vmf_cluster.py --da True --robin_cat None<0,1,2,3,4 for OOD-CV subcategories> && python Initialization_Code/simmat.py --da True --mode 'mixed' && python Initialization_Code/Learn_mix_model_vMF_view.py --da True --mode 'mixed' && python Code/test.py --da True --bbone 'vgg_tr' --sveimglst True --load False && python Da/pseudo_data_creation.py

Change dataset variable in Code/config.py and Initialization_Code/config_initialization.py from 'robin' to 'pseudorobin' and run-

python Initialization_Code/simmat.py --da True --mode '' --dataset pseudorobin && python Initialization_Code/Learn_mix_model_vMF_view.py --da True --mode '' --dataset pseudorobin && python Code/train.py --gce True --dataset pseudorobin

A folder with the format models/vcvgg_tr_final/vc_{epoch-number}.pth will be created after running the train.py file. Change lines 179-181 in Code/test.py according to the model name created, and run evaluation (for Combined nuisance)-

python Code/test.py

TODO

  • Direct Transitional vMF Dictionary Learning (No source domain data needed)
  • Regularized MLE (source domain data needed)
  • Other Backbones

About

Domain Adaptation with Compostional Networks

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published