Skip to content

Latest commit

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Official implementation for SHOT++

Framework:

  1. train on the source domain; (Section 3.1)
  2. hypothesis transfer with information maximization and self-supervised learning; (Section 3.2 & Section 3.3) (note that SHOT here means results after step 2, which contains an additional rotation-driven self-supervised objective compared with the original SHOT in ICML 2020)

  1. labeling transfer with semi-supervised learning. (Section 3.4) (note that SHOT++ has an extra semi-supervised learning step via MixMatch)

Prerequisites:

  • python == 3.6.8
  • pytorch ==1.1.0
  • torchvision == 0.3.0
  • numpy, scipy, sklearn, PIL, argparse, tqdm

Dataset:

  • Please manually download the datasets Office, Office-Home, VisDA-C, Office-Caltech from the official websites, and modify the path of images in each '.txt' under the folder './object/data/'. [**How to generate such txt files could be found in https://github.com/tim-learn/Generate_list **]

  • Concerning the Digits dsatasets, the code will automatically download three digit datasets (i.e., MNIST, USPS, and SVHN) in './digit/data/'.

Training:

  1. Unsupervised Closed-set Domain Adaptation (UDA) on the Digits dataset
    • MNIST -> USPS (m2u)
    cddigit/pythonuda_digit.py--gpu_id0--seed2021--dsetm2u--outputckps_digits--cls_par0.1--ssl0.2pythondigit_mixmatch.py--gpu_id0--seed2021--dsetm2u--outputckps_mm--output_tarckps_digits--cls_par0.1--ssl0.2--alpha0.1
  2. Unsupervised Closed-set Domain Adaptation (UDA) on the Office/ Office-Home dataset
    • Train model on the source domain A (s = 0) [--max_epoch 50 for Office-Home]
    cduda/pythonimage_source.py--gpu_id0--seed2021--trteval--dauda--outputckps/source/--dsetoffice--max_epoch100--s0
    • Adaptation to other target domains D and W (hypothesis transfer)
    pythonimage_target.py--gpu_id0--seed2021--dauda--outputckps/target/--dsetoffice--s0--cls_par0.3--ssl0.6
    • Adaptation to other target domains D and W (following labeling transfer) [--max_epoch 50 for Office-Home]
    pythonimage_mixmatch.py--gpu_id0--seed2021--dauda--dsetoffice--max_epoch100--s0--output_tarckps/target/--outputckps/mixmatch/--cls_par0.3--ssl0.6--choiceent--ps0.0
  3. Unsupervised Closed-set Domain Adaptation (UDA) on the VISDA-C dataset
    • Train model on the Synthetic domain [--max_epoch 10 --lr 1e-3]
    cduda/pythonimage_source.py--gpu_id0--seed2021--trteval--dauda--outputckps/source/--dsetVISDA-C--netresnet101--lr1e-3--max_epoch10--s0
    • Adaptation to the real domain (hypothesis transfer)
    pythonimage_target.py--gpu_id0--seed2021--dauda--outputckps/target/--dsetVISDA-C--s0--netresnet101--cls_par0.3--ssl0.6
    • Adaptation to the real domain (following labeling transfer)
    pythonimage_mixmatch.py--gpu_id0--seed2021--dauda--dsetVISDA-C--max_epoch10--s0--output_tarckps/target/--outputckps/mixmatch/--netresnet101--cls_par0.3--ssl0.6--choiceent--ps0.0
  4. Unsupervised Partial-set Domain Adaptation (PDA) on the Office-Home dataset
    • Train model on the source domain A (s = 0)
    cdpda/pythonimage_source.py--gpu_id0--seed2021--trteval--dapda--outputckps/source/--dsetoffice-home--max_epoch50--s0
    • Adaptation to other target domains (hypothesis transfer)
    pythonimage_target.py--gpu_id0--seed2021--dapda--dsetoffice-home--s0--output_srcckps/source/--outputckps/target/--cls_par0.3--ssl0.6
    • Adaptation to the real domain (following labeling transfer)
    pythonimage_mixmatch.py--gpu_id0--seed2021--dapda--dsetoffice-home--max_epoch50--s0--output_tarckps/target/--outputckps/mixmatch/--cls_par0.3--ssl0.6--choiceent--ps0.0
  5. Unsupervised Multi-source Domain Adaptation (MSDA) on the Office-Home dataset
    • Train model on the source domains Ar (s = 0), Cl (s = 1), Pr (s = 2), respectively
    cdmsda/pythonimage_source.py--gpu_id0--seed2021--trteval--dauda--dsetoffice-home--outputckps/source/--netresnet50--max_epoch50--s0pythonimage_source.py--gpu_id0--seed2021--trteval--dauda--dsetoffice-home--outputckps/source/--netresnet50--max_epoch50--s1pythonimage_source.py--gpu_id0--seed2021--trteval--dauda--dsetoffice-home--outputckps/source/--netresnet50--max_epoch50--s2
    • Adaptation to the target domain (hypothesis transfer)
    pythonimage_target.py--gpu_id0--seed2021--cls_par0.3--ssl0.6--dauda--dsetoffice-home--output_srcckps/source/--outputckps/target/--netresnet50--s0pythonimage_target.py--gpu_id0--seed2021--cls_par0.3--ssl0.6--dauda--dsetoffice-home--output_srcckps/source/--outputckps/target/--netresnet50--s1pythonimage_target.py--gpu_id0--seed2021--cls_par0.3--ssl0.6--dauda--dsetoffice-home--output_srcckps/source/--outputckps/target/--netresnet50--s2
    • Adaptation to the target domain (labeling transfer)
    pythonimage_mixmatch.py--gpu_id0--seed2021--dauda--dsetoffice-home--max_epoch50--output_tarckps/target/--outputckps/mixmatch/--cls_par0.3--ssl0.6--choiceent--ps0.0--netresnet50--s0pythonimage_mixmatch.py--gpu_id0--seed2021--dauda--dsetoffice-home--max_epoch50--output_tarckps/target/--outputckps/mixmatch/--cls_par0.3--ssl0.6--choiceent--ps0.0--netresnet50--s1pythonimage_mixmatch.py--gpu_id0--seed2021--dauda--dsetoffice-home--max_epoch50--output_tarckps/target/--outputckps/mixmatch/--cls_par0.3--ssl0.6--choiceent--ps0.0--netresnet50--s2
    • Combine domain-spetific scores together
    pythonimage_ms.py--gpu_id0--seed2021--cls_par0.3--ssl0.6--dauda--dsetoffice-home--output_srcckps/source/--outputckps/target/--output_mmckps/mixmatch/--netresnet50--t3
  6. Semi-supervised Domain Adaptation (SSDA) on the Office-Home dataset
    • Train model on the source domain Ar (s = 0)
    cdssda/pythonimage_source.py--gpu_id0--seed2021--outputckps/source/--dsetoffice-home--max_epoch50--s0
    • Adaptation to the target domain Cl (t = 1) [hypothesis transfer]
    pythonimage_target.py--gpu_id0--seed2021--cls_par0.1--ssl0.2--output_srcckps/source--outputckps/target--dsetoffice-home--s0--t1
    • Adaptation to the target domain Cl (t = 1) [labeling transfer]
    pythonimage_mixmatch.py--gpu_id0--seed2021--ps0.0--cls_par0.1--ssl0.2--output_tarckps/target--outputckps/mixmatch--dsetoffice-home--max_epoch50--s0--t1

Please refer ./xxda/run_xxda.sh for all the settings for different methods and scenarios.

Citation

If you find this code useful for your research, please cite our papers

@article{liang2021source, title={Source Data-absent Unsupervised Domain Adaptation through Hypothesis Transfer and Labeling Transfer}, author={Liang, Jian and Hu, Dapeng and Wang, Yunbo and He, Ran and Feng, Jiashi}, journal={IEEE Transactions on Pattern Analysis and Machine Intelligence (TPAMI)},
year={2021}, note={In Press} }
@inproceedings{liang2020we, title={Do We Really Need to Access the Source Data? Source Hypothesis Transfer for Unsupervised Domain Adaptation}, author={Liang, Jian and Hu, Dapeng and Feng, Jiashi}, booktitle={International Conference on Machine Learning (ICML)}, pages={6028--6039},
year={2020}
}

Contact

About

code for our TPAMI 2021 paper "Source Data-absent Unsupervised Domain Adaptation through Hypothesis Transfer and Labeling Transfer"

Topics

Resources

Stars

128 stars

Watchers

4 watching

Forks

Releases

Packages

Contributors

Languages