https://github.com/zhengzangw/doprompt
Official implementation of PCS in essay "Prompt Vision Transformer for Domain Generalization"
https://github.com/zhengzangw/doprompt
deep-learning domain-adaptation domain-generalization prompt-tuning vision-transformer
Last synced: over 1 year ago
JSON representation
Official implementation of PCS in essay "Prompt Vision Transformer for Domain Generalization"
- Host: GitHub
- URL: https://github.com/zhengzangw/doprompt
- Owner: zhengzangw
- License: mit
- Created: 2022-04-23T14:22:28.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-01-29T12:32:58.000Z (over 3 years ago)
- Last Synced: 2024-04-23T00:12:59.164Z (about 2 years ago)
- Topics: deep-learning, domain-adaptation, domain-generalization, prompt-tuning, vision-transformer
- Language: Python
- Homepage:
- Size: 1.39 MB
- Stars: 46
- Watchers: 3
- Forks: 4
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Prompt Vision Transformer for Domain Generalization (DoPrompt)
Pytorch implementation of **DoPrompt** ([Prompt Vision Transformer for Domain Generalization](https://arxiv.org/abs/2208.08914))
## Overview
Architecture of Network:

## Training
Refer to [DomainBed Readme](README_domainbed.md) for more details on commands running jobs. The training setting sweeps across multiple hyperparameters. Here we select some hyperparameters that can reach a good result. (Update 17/11/22: as many queries about the ERM baseline hyper-parameter, we present them below.)
```sh
# OfficeHome ERM
python -m domainbed.scripts.train --data_dir=./domainbed/data/ --steps 5001 --dataset OfficeHome --test_env 0/1/2/3 --algorithm ERM --output_dir results/exp \
--hparams '{"lr": 1e-5, "lr_classifier": 1e-4}'
# OfficeHome
python -m domainbed.scripts.train --data_dir=./domainbed/data/ --steps 5001 --dataset OfficeHome --test_env 0/1/2/3 --algorithm DoPrompt --output_dir results/exp \
--hparams '{"lr": 1e-5, "lr_classifier": 1e-3}'
# PACS ERM
python -m domainbed.scripts.train --data_dir=./domainbed/data/ --steps 5001 --dataset PACS --test_env 0/2/3 --algorithm ERM --output_dir results/exp \
--hparams '{"lr": 5e-6, "lr_classifier": 5e-5}'
# PACS
python -m domainbed.scripts.train --data_dir=./domainbed/data/ --steps 5001 --dataset PACS --test_env 0/2/3 --algorithm DoPrompt --output_dir results/exp \
--hparams '{"lr": 5e-6, "lr_classifier": 5e-5, "wd_classifier": 1e-5}'
# VLCS ERM
python -m domainbed.scripts.train --data_dir=./domainbed/data/ --steps 5001 --dataset VLCS --test_env 0/1/2/3 --algorithm ERM --output_dir results/exp \
--hparams '{"lr": 5e-6, "lr_classifier": 5e-5}'
# VLCS
python -m domainbed.scripts.train --data_dir=./domainbed/data/ --steps 5001 --dataset VLCS --test_env 0/1/2/3 --algorithm DoPrompt --output_dir results/exp \
--hparams '{"lr": 5e-6, "lr_classifier": 5e-6}'
```
## Collect Results
```sh
python -m domainbed.scripts.collect_results --input_dir=results
```
## Requirements
```sh
pip install -r domainbed/requirements.txt
```
## Citation
```bibtex
@article{zheng2022prompt,
title={Prompt Vision Transformer for Domain Generalization},
author={Zheng, Zangwei and Yue, Xiangyu and Wang, Kai and You, Yang},
journal={arXiv preprint arXiv:2208.08914},
year={2022}
}
```
## Acknowlegdement
This code is built on [DomainBed](https://github.com/facebookresearch/DomainBed). We thank the authors for sharing their codes.