changdaeoh/BlackVIP

★ 107⑂ 9

Official implementation for CVPR'23 paper "BlackVIP: Black-Box Visual Prompting for Robust Transfer Learning"

About changdaeoh/BlackVIP

changdaeoh/BlackVIP is an open-source project on GitHub, mainly written in Python. Official implementation for CVPR'23 paper "BlackVIP: Black-Box Visual Prompting for Robust Transfer Learning" It currently holds 107 stars and 9 forks with 0 open issues, and was last pushed on an unknown date (repository created unknown).

Project Overview

AI Homed tracks it on the AI Prompt Engineering board.

GitHub Repository Details

Repository changdaeoh/BlackVIP · default branch - · size 0 KB · watchers 0 · source: GitHub REST API and repository README

README

BlackVIP: Black-Box Visual Prompting for Robust Transfer Learning

We provide the official PyTorch Implementation of 'BlackVIP: Black-Box Visual Prompting for Robust Transfer Learning' (CVPR 2023)
>Changdae Oh, Hyeji Hwang, Hee-young Lee, YongTaek Lim, Geunyoung Jung, Jiyoung Jung, Hosik Choi, and Kyungwoo Song


Abstract

https://github.com/changdaeoh/BlackVIP/blob/HEAD/

With the surge of large-scale pre-trained models (PTMs), fine-tuning these models to numerous downstream tasks becomes a crucial problem. Consequently, parameter efficient transfer learning (PETL) of large models has grasped huge attention. While recent PETL methods showcase impressive performance, they rely on optimistic assumptions: 1) the entire parameter set of a PTM is available, and 2) a sufficiently large memory capacity for the fine-tuning is equipped. However, in most real-world applications, PTMs are served as a black-box API or proprietary software without explicit parameter accessibility. Besides, it is hard to meet a large memory requirement for modern PTMs. In this work, we propose black-box visual prompting (BlackVIP), which efficiently adapts the PTMs without knowledge about model architectures and parameters. BlackVIP has two components; 1) Coordinator and 2) simultaneous perturbation stochastic approximation with gradient correction (SPSA-GC). The Coordinator designs input-dependent image-shaped visual prompts, which improves few-shot adaptation and robustness on distribution/location shift. SPSA-GC efficiently estimates the gradient of a target model to update Coordinator. Extensive experiments on 16 datasets demonstrate that BlackVIP enables robust adaptation to diverse domains without accessing PTMs' parameters, with minimal memory requirements.


Research Highlights

https://github.com/changdaeoh/BlackVIP/blob/HEAD/



Coverage of this repository

_Methods_

_Experiments_


Setup

# Clone this repo
git clone https://github.com/changdaeoh/BlackVIP.git
cd BlackVIP

Create a conda environment

conda create -y -n blackvip python=3.8

Activate the environment

conda activate blackvip

Install torch and torchvision

Please refer to https://pytorch.org/ if you need a different cuda version

conda install pytorch==1.12.1 torchvision==0.13.1 cudatoolkit=11.6 -c pytorch -c conda-forge

Install dependencies

cd my_dassl pip install -r requirements.txt

Install additional requirements

cd .. pip install -r requirements.txt


Data preparation


Run

transfer learning benchmarks

# for BlackVIP, specify {1:dataset, 2:epoch, 3:moms, 4:spsa_gamma, 5:spsa_c, 6:p_eps}
sh tl_bench.sh svhn 5000 0.9 0.2 0.005 1.0

for BAR, specify {1:dataset, 2:epoch, 3:init_lr, 4:min_lr}

sh tl_bench.sh svhn 5000 5.0 0.1

for VP w/ SPSA-GC, specify {1:dataset, 2:epoch, 3:moms, 4:spsa_a, 5:spsa_c}

sh tl_bench.sh svhn 5000 0.9 10.0 0.01

for VP (white-box), specify {1:dataset, 2:epoch, 3:lr}

sh tl_bench.sh svhn 1000 40.0

for Zero-shot CLIP inference, move to 'BlackVIP/scripts/coop' and run:

sh zeroshot_all.sh

synthetic datasets

# for BlackVIP on Loc-MNIST, specify {1:fake-digit-size, 2:moms, 3:spsa_alpha, 4:spsa_a, 5:spsa_c}
sh synthetic_lm.sh 1 0.9 0.5 0.01 0.005  # 1:1 setting
sh synthetic_lm.sh 4 0.95 0.5 0.02 0.01  # 1:4 seeting

for BlackVIP on Biased MNIST, specify {1:moms, 2:spsa_alpha, 3:spsa_a, 4:spsa_c}

sh synthetic_bm_easy.sh 0.9 0.4 0.01 0.01 # spurious correlation = 0.8 sh synthetic_bm_hard.sh 0.9 0.4 0.01 0.01 # spurious correlation = 0.9

other methods can be runned similarly to the above.

ablation study

# for BlackVIP, specify {1:target_backbone, 2:spsa_alpha, 3:moms, 4:spsa_gamma, 5:spsa_c, 6:p_eps}
sh ablation_arch_rn.sh rn50 0.5 0.9 0.2 0.01 0.3



Contact

For any questions, discussions, and proposals, please contact to changdae.oh@uos.ac.kr or kyungwoo.song@gmail.com


Citation

If you use our code in your research, please kindly consider citing:
@InProceedings{Oh_2023_CVPR,
    author    = {Oh, Changdae and Hwang, Hyeji and Lee, Hee-young and Lim, YongTaek and Jung, Geunyoung and Jung, Jiyoung and Choi, Hosik and Song, Kyungwoo},
    title     = {BlackVIP: Black-Box Visual Prompting for Robust Transfer Learning},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    month     = {June},
    year      = {2023},
    pages     = {24224-24235}
}


Acknowledgements

Our overall experimental pipeline is based on CoOp, CoCoOp repository. For baseline construction, we bollowed/refered the code from repositories of VP, BAR, and AR. We appreciate the authors (Zhou et al., Bahng et al., Tsai et al.) and Savan for sharing their code.

GitHub Stars & Activity

107Stars
9Forks
0Open issues
PythonLanguage

GitHub Popularity

GitHub stars107
Forks9
Open issues0
Primary languagePython
License-
Stars gained today0
Created-
Last pushed-

Trending History

Trending statusnot on today's boards

Related AI Projects

1

microsoft / promptflow

Python★ 11,244⑂ 1,123
2

promptslab / Promptify

Python★ 4,635⑂ 364
3
4

hegelai / prompttools

Python★ 3,055⑂ 256
5

Eladlev / AutoPrompt

Python★ 3,019⑂ 264
6

microsoftarchive / promptbench

Python★ 2,821⑂ 222
7

yaojingang / yao-open-prompts

Python★ 2,817⑂ 461
8

YiVal / YiVal

Python★ 2,134⑂ 328

More AI Rankings