| # ReWeighting_Adv_Robust_VLMs | |
| ## README | |
| **Adv. Fine-tuning** | |
| ``` | |
| # TeCoA | |
| CUDA_VISIBLE_DEVICES=6 torchrun --nproc_per_node=1 --master_port=29510 new_finetuning_ddp.py --epochs 10 --train_eps 2 --train_numsteps 10 --optim adamw --method TeCoA --exp_name FT_TeCoA_VITB_epoch10_eps2_10steps_adamw | |
| # PMG | |
| CUDA_VISIBLE_DEVICES=7 torchrun --nproc_per_node=1 --master_port=28849 new_finetuning_ddp.py --epochs 10 --train_eps 2 --train_numsteps 10 --optim adamw --method PMG --W_Pred_Align_Ori 1.0 --W_Pred_Align 1.0 --exp_name FT_PMG_VITB_epoch10_eps2_10steps_adamw | |
| # FARE | |
| CUDA_VISIBLE_DEVICES=0 torchrun --nproc_per_node=1 --master_port=29520 new_finetuning_ddp.py --epochs 10 --train_eps 2 --train_numsteps 10 --optim adamw --weight_decay 1e-4 --method FARE --exp_name FT_FARE_VITB_epoch10_eps2_10steps | |
| # TRADES --- W_Pred_Align_Ori is an hyper-parameter for TRADE-off | |
| CUDA_VISIBLE_DEVICES=0 torchrun --nproc_per_node=1 --master_port=29019 new_finetuning_ddp.py --epochs 10 --train_eps 2 --train_numsteps 10 --optim adamw --method TRADES --W_Pred_Align_Ori 9.0 --exp_name FT_TRADES90_VITB_epoch10_eps2_10steps_adamw | |
| ``` | |
| **Evaluation** | |
| ``` | |
| # test_eps --- the perturbation radius (attack strenght) | |
| # XXX is replaced by folder name, e.g., FT_TeCoA_VITB_epoch10_eps2_10steps_adamw | |
| CUDA_VISIBLE_DEVICES=0,1 python new_finetuning.py --evaluate --eval_type full --test_eps 1 --resume XXXX/model_best.pth.tar | |
| ``` | |
| **训练部分** | |
| 核心的adv fine-tuning方法 (--method) 在adv_clip_loss文件内,我们在new_finetuning_ddp.py的Lines 290-304调用 | |
| **测试部分** | |
| 从new_finetuning_ddp.py的Line 616开始到Line780,可以参考validate这个函数,同时对常规样本和对抗样本进行测试 |