Skip to content

tntek/source-free-domain-adaptation

Repository files navigation

source-free-domain-adaptation

This is an source-free domain adaptation repository based on PyTorch. It was developed by Wenxin Su. If you encounter any issues or have questions, please don't hesitate to contact Wenxin at suwenxin43@gmail.com. It is also the official repository for the following works:

This repository is also supports the following methods:

We encourage contributions! Pull requests to add methods are very welcome and appreciated.

Our Publications

Preliminary

To use the repository, we provide a conda environment.

conda update conda
conda env create -f environment.yml
conda activate sfa

You need to download the above dataset,modify the path of images in each '.txt' under the folder './data/'.In addition, class name files for each dataset also under the folder './data/'.The prepared directory would look like:

├── data
    ├── office-home
        ├── amazon_list.txt
        ├── classname.txt
        ├── dslr_list.txt
        ├── webcam_list.txt
    ├── office-home
        ├── Art_list.txt
        ├── classname.txt
        ├── Clipart_list.txt
        ├── Product_list.txt
        ├── RealWorld_list.txt
    ...  ...

For the ImageNet variations, modify the ${DATA_DIR} in the conf.py to your data directory where stores the ImageNet variations datasets.

Training

We provide config files for experiments.

Source

  • For office-31, office-home and VISDA-C, there is an example to training a source model :
CUDA_VISIBLE_DEVICES=0 python image_target_of_oh_vs.py --cfg "cfgs/office-home/source.yaml" SETTING.S 0
  • For domainnet126, we follow AdaContrast to train the source model.

  • For adapting to ImageNet variations, all pre-trained models available in Torchvision or timm can be used.

  • We also provide the pre-trained source models which can be downloaded from here.

Target

After obtaining the source models, modify the ${CKPT_DIR} in the conf.py to your source model directory. For office-31, office-home and VISDA-C, simply run the following Python file with the corresponding config file to execute source-free domain adaptation.

CUDA_VISIBLE_DEVICES=0 python image_target_of_oh_vs.py --cfg "cfgs/office-home/difo.yaml" SETTING.S 0 SETTING.T 1

For domainnet126 and ImageNet variations.

CUDA_VISIBLE_DEVICES=0 python image_target_in_126.py --cfg "cfgs/domainnet126/difo.yaml" SETTING.S 0 SETTING.T 1

Acknowledgements

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages