(CVPR 2024) Pytorch implementation of “SURE: SUrvey REcipes for building reliable and robust deep networks”
Pytorch implementation of paper "SURE: SUrvey REcipes for building reliable and robust deep networks"
[Project Page] [arXiv] [Google Drive] [Poster]
If our project is helpful for your research, please consider citing :
@inproceedings{li2024sure,
title={SURE: SUrvey REcipes for building reliable and robust deep networks},
author={Li, Yuting and Chen, Yingyi and Yu, Xuanlong and Chen, Dexiong and Shen, Xi},
booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
year={2024}}
Our model can be learnt in a single GPU RTX-4090 24G
conda env create -f environment.yml
conda activate u
The code was tested on Python 3.9 and PyTorch 1.13.0.
cd data
bash download_cifar.sh
The structure of the file should be:
./data/CIFAR10/
├── train
├── val
└── test
./data/Animal10N/
├── train
└── test
./data/Food-101N/
├── train
└── test
./data/CIFAR10_LT/
├── train
└── test
./data/CIFAR-10-C/
├── brightness.npy
├── contrast.npy
├── defocus_blur.npy
...
./data/CARS/
├── train
└── test
...
python3 main.py \
--batch-size 128 \
--gpu 0 \
--epochs 200 \
--nb-run 3 \
--model-name wrn \
--optim-name baseline \
--crl-weight 0 \
--mixup-weight 0 \
--mixup-beta 10 \
--save-dir ./CIFAR10_out/wrn_out \
Cifar10
python3 test.py \
--batch-size 128 \
--gpu 0 \
--nb-run 3 \
--model-name wrn \
--optim-name baseline \
--crl-weight 0 \
--mixup-weight 0 \
--save-dir ./CIFAR10_out/wrn_out \
Cifar10
python3 main.py \
--batch-size 128 \
--gpu 0 \
--epochs 200 \
--nb-run 3 \
--model-name wrn \
--optim-name baseline \
--crl-weight 0 \
--mixup-weight 0.5 \
--mixup-beta 10 \
--save-dir ./CIFAR10_out/wrn_out \
Cifar10
python3 test.py \
--batch-size 128 \
--gpu 0 \
--nb-run 3 \
--model-name wrn \
--optim-name baseline \
--crl-weight 0 \
--mixup-weight 0.5 \
--save-dir ./CIFAR10_out/wrn_out \
Cifar10
python3 main.py \
--batch-size 128 \
--gpu 0 \
--epochs 200 \
--nb-run 3 \
--model-name wrn \
--optim-name baseline \
--crl-weight 0.5 \
--mixup-weight 0 \
--mixup-beta 10 \
--save-dir ./CIFAR10_out/wrn_out \
Cifar10
python3 test.py \
--batch-size 128 \
--gpu 0 \
--nb-run 3 \
--model-name wrn \
--optim-name baseline \
--crl-weight 0.5 \
--mixup-weight 0 \
--save-dir ./CIFAR10_out/wrn_out \
Cifar10
python3 main.py \
--batch-size 128 \
--gpu 0 \
--epochs 200 \
--nb-run 3 \
--model-name wrn \
--optim-name sam \
--crl-weight 0 \
--mixup-weight 0 \
--mixup-beta 10 \
--save-dir ./CIFAR10_out/wrn_out \
Cifar10
python3 test.py \
--batch-size 128 \
--gpu 0 \
--nb-run 3 \
--model-name wrn \
--optim-name sam \
--crl-weight 0 \
--mixup-weight 0 \
--save-dir ./CIFAR10_out/wrn_out \
Cifar10
python3 main.py \
--batch-size 128 \
--gpu 0 \
--epochs 200 \
--nb-run 3 \
--model-name wrn \
--optim-name swa \
--crl-weight 0 \
--mixup-weight 0 \
--mixup-beta 10 \
--save-dir ./CIFAR10_out/wrn_out \
Cifar10
python3 test.py \
--batch-size 128 \
--gpu 0 \
--nb-run 3 \
--model-name wrn \
--optim-name swa \
--crl-weight 0 \
--mixup-weight 0 \
--save-dir ./CIFAR10_out/wrn_out \
Cifar10
python3 main.py \
--batch-size 128 \
--gpu 0 \
--epochs 200 \
--nb-run 3 \
--model-name wrn \
--optim-name fmfp \
--crl-weight 0 \
--mixup-weight 0 \
--mixup-beta 10 \
--save-dir ./CIFAR10_out/wrn_out \
Cifar10
python3 test.py \
--batch-size 128 \
--gpu 0 \
--nb-run 3 \
--model-name wrn \
--optim-name fmfp \
--crl-weight 0 \
--mixup-weight 0 \
--save-dir ./CIFAR10_out/wrn_out \
Cifar10
python3 main.py \
--batch-size 128 \
--gpu 0 \
--epochs 200 \
--nb-run 3 \
--model-name wrn \
--optim-name fmfp \
--crl-weight 0.5 \
--mixup-weight 0.5 \
--mixup-beta 10 \
--use-cosine \
--save-dir ./CIFAR10_out/wrn_out \
Cifar10
python3 test.py \
--batch-size 128 \
--gpu 0 \
--nb-run 3 \
--model-name wrn \
--optim-name fmfp \
--crl-weight 0.5 \
--mixup-weight 0.5 \
--use-cosine \
--save-dir ./CIFAR10_out/wrn_out \
Cifar10
Note that :
Official DeiT-B can be downloaded from here
Official DeiT-B-Distilled can be downloaded from here
Then one should set --deit-path
argument.
python3 main.py \
--batch-size 64 \
--gpu 5 \
--epochs 50 \
--lr 0.01 \
--weight-decay 5e-5 \
--nb-run 3 \
--model-name deit \
--optim-name baseline \
--crl-weight 0 \
--mixup-weight 0 \
--mixup-beta 10 \
--save-dir ./CIFAR10_out/deit_out \
Cifar10
python3 test.py \
--batch-size 64 \
--gpu 5 \
--nb-run 3 \
--model-name deit \
--optim-name baseline \
--crl-weight 0 \
--mixup-weight 0 \
--save-dir ./CIFAR10_out/deit_out \
Cifar10
python3 main.py \
--batch-size 64 \
--gpu 5 \
--epochs 50 \
--lr 0.01 \
--weight-decay 5e-5 \
--nb-run 3 \
--model-name deit \
--optim-name baseline \
--crl-weight 0 \
--mixup-weight 0.2 \
--mixup-beta 10 \
--save-dir ./CIFAR10_out/deit_out \
Cifar10
python3 test.py \
--batch-size 64 \
--gpu 5 \
--nb-run 3 \
--model-name deit \
--optim-name baseline \
--crl-weight 0 \
--mixup-weight 0.2 \
--save-dir ./CIFAR10_out/deit_out \
Cifar10
python3 main.py \
--batch-size 64 \
--gpu 5 \
--epochs 50 \
--lr 0.01 \
--weight-decay 5e-5 \
--nb-run 3 \
--model-name deit \
--optim-name baseline \
--crl-weight 0.2 \
--mixup-weight 0 \
--mixup-beta 10 \
--save-dir ./CIFAR10_out/deit_out \
Cifar10
python3 test.py \
--batch-size 64 \
--gpu 5 \
--nb-run 3 \
--model-name deit \
--optim-name baseline \
--crl-weight 0.2 \
--mixup-weight 0 \
--save-dir ./CIFAR10_out/deit_out \
Cifar10
python3 main.py \
--batch-size 64 \
--gpu 5 \
--epochs 50 \
--lr 0.01 \
--weight-decay 5e-5 \
--nb-run 3 \
--model-name deit \
--optim-name sam \
--crl-weight 0 \
--mixup-weight 0 \
--mixup-beta 10 \
--save-dir ./CIFAR10_out/deit_out \
Cifar10
python3 test.py \
--batch-size 64 \
--gpu 5 \
--nb-run 3 \
--model-name deit \
--optim-name sam \
--crl-weight 0 \
--mixup-weight 0 \
--save-dir ./CIFAR10_out/deit_out \
Cifar10
python3 main.py \
--batch-size 64 \
--gpu 5 \
--epochs 50 \
--lr 0.01 \
--weight-decay 5e-5 \
--swa-epoch-start 0 \
--swa-lr 0.004 \
--nb-run 3 \
--model-name deit \
--optim-name swa \
--crl-weight 0 \
--mixup-weight 0 \
--mixup-beta 10 \
--save-dir ./CIFAR10_out/deit_out \
Cifar10
python3 test.py \
--batch-size 64 \
--gpu 5 \
--nb-run 3 \
--model-name deit \
--optim-name swa \
--crl-weight 0 \
--mixup-weight 0 \
--save-dir ./CIFAR10_out/deit_out \
Cifar10
python3 main.py \
--batch-size 64 \
--gpu 5 \
--epochs 50 \
--lr 0.01 \
--weight-decay 5e-5 \
--swa-epoch-start 0 \
--swa-lr 0.004 \
--nb-run 3 \
--model-name deit \
--optim-name fmfp \
--crl-weight 0 \
--mixup-weight 0 \
--mixup-beta 10 \
--save-dir ./CIFAR10_out/deit_out \
Cifar10
python3 test.py \
--batch-size 64 \
--gpu 5 \
--nb-run 3 \
--model-name deit \
--optim-name fmfp \
--crl-weight 0 \
--mixup-weight 0 \
--save-dir ./CIFAR10_out/deit_out \
Cifar10
python3 main.py \
--batch-size 64 \
--gpu 5 \
--epochs 50 \
--lr 0.01 \
--weight-decay 5e-5 \
--swa-epoch-start 0 \
--swa-lr 0.004 \
--nb-run 3 \
--model-name deit \
--optim-name fmfp \
--crl-weight 0 \
--mixup-weight 0.2 \
--mixup-beta 10 \
--save-dir ./CIFAR10_out/deit_out \
Cifar10
python3 test.py \
--batch-size 64 \
--gpu 5 \
--nb-run 3 \
--model-name deit \
--optim-name fmfp \
--crl-weight 0 \
--mixup-weight 0.2 \
--save-dir ./CIFAR10_out/deit_out \
Cifar10
python3 main.py \
--batch-size 128 \
--gpu 0 \
--epochs 200 \
--nb-run 3 \
--model-name resnet32 \
--optim-name fmfp \
--crl-weight 0 \
--mixup-weight 1 \
--mixup-beta 10 \
--use-cosine \
--save-dir ./CIFAR10_LT/res32_out \
Cifar10_LT
python3 test.py \
--batch-size 128 \
--gpu 0 \
--nb-run 3 \
--model-name resnet32 \
--optim-name fmfp \
--crl-weight 0 \
--mixup-weight 1 \
--use-cosine \
--save-dir ./CIFAR10_LT/res32_out \
Cifar10_LT
python3 main.py \
--batch-size 128 \
--gpu 0 \
--epochs 200 \
--nb-run 3 \
--model-name resnet32 \
--optim-name fmfp \
--crl-weight 0 \
--mixup-weight 1 \
--mixup-beta 10 \
--use-cosine \
--save-dir ./CIFAR10_LT_50/res32_out \
Cifar10_LT_50
python3 test.py \
--batch-size 128 \
--gpu 0 \
--nb-run 3 \
--model-name resnet32 \
--optim-name fmfp \
--crl-weight 0 \
--mixup-weight 1 \
--use-cosine \
--save-dir ./CIFAR10_LT_50/res32_out \
Cifar10_LT_50
python3 main.py \
--batch-size 128 \
--gpu 0 \
--epochs 200 \
--nb-run 3 \
--model-name resnet32 \
--optim-name fmfp \
--crl-weight 0 \
--mixup-weight 1 \
--mixup-beta 10 \
--use-cosine \
--save-dir ./CIFAR10_LT_100/res32_out \
Cifar10_LT_100
python3 test.py \
--batch-size 128 \
--gpu 0 \
--nb-run 3 \
--model-name resnet32 \
--optim-name fmfp \
--crl-weight 0 \
--mixup-weight 1 \
--use-cosine \
--save-dir ./CIFAR10_LT_100/res32_out \
Cifar10_LT_100
You can conduct second stage uncertainty-aware re-weighting by :
python3 finetune.py \
--batch-size 128 \
--gpu 5 \
--nb-run 1 \
--model-name resnet32 \
--optim-name fmfp \
--fine-tune-lr 0.005 \
--reweighting-type exp \
--t 1 \
--crl-weight 0 \
--mixup-weight 1 \
--mixup-beta 10 \
--fine-tune-epochs 50 \
--use-cosine \
--save-dir ./CIFAR100LT_100_out/51.60 \
Cifar100_LT_100
python3 main.py \
--batch-size 128 \
--gpu 0 \
--epochs 200 \
--nb-run 1 \
--model-name vgg19bn \
--optim-name fmfp \
--crl-weight 0.2 \
--mixup-weight 1 \
--mixup-beta 10 \
--use-cosine \
--save-dir ./Animal10N_out/vgg19bn_out \
Animal10N
python3 test.py \
--batch-size 128 \
--gpu 0 \
--nb-run 1 \
--model-name vgg19bn \
--optim-name baseline \
--crl-weight 0.2 \
--mixup-weight 1 \
--use-cosine \
--save-dir ./Animal10N_out/vgg19bn_out \
Animal10N
python3 main.py \
--batch-size 64 \
--gpu 0 \
--epochs 30 \
--nb-run 1 \
--model-name resnet50 \
--optim-name fmfp \
--crl-weight 0.2 \
--mixup-weight 1 \
--mixup-beta 10 \
--lr 0.01 \
--swa-lr 0.005 \
--swa-epoch-start 22 \
--use-cosine True \
--save-dir ./Food101N_out/resnet50_out \
Food101N
python3 test.py \
--batch-size 64 \
--gpu 0 \
--nb-run 1 \
--model-name resnet50 \
--optim-name fmfp \
--crl-weight 0.2 \
--mixup-weight 1 \
--use-cosine True \
--save-dir ./Food101N_out/resnet50_out \
Food101N
if args.data_name == 'cifar10':
cor_results_storage = test_cifar10c_corruptions(net, args.corruption_dir, transform_test,
args.batch_size, metrics, logger)
cor_results = {corruption: {
severity: {
metric: cor_results_storage[corruption][severity][metric][0] for metric in metrics} for severity
in range(1, 6)} for corruption in data.CIFAR10C.CIFAR10C.cifarc_subsets}
cor_results_all_models[f"model_{r + 1}"] = cor_results