Skip to content

gengxuli/ACT

Repository files navigation

Asymmetric Co-Training for Source-Free Few-Shot Domain Adaptation

The official GitHub page for paper "Asymmetric Co-Training for Source-Free Few-Shot Domain Adaptation". This paper explores the utilization of Asymmetric Co-Training for Source-Free Few-Shot domain adaptation, and designs special loss functions. The result demonstrate the effectiveness of our method compared to traditional unsupervised domain adaptation(UDA) and source-free unsupervised domain adaptation(SFUDA) approaches.

Ⅰ.Prerequisites:

  • PyTorch >= 1.13.0 (with suitable CUDA and CuDNN version)
  • torchvision >= 0.14.0
  • python3
  • Numpy, argparse, scipy, PIL
  • sklearn, opencv-python, tqdm

Ⅱ.Results:

This is a comparison of our method with SFUDA and transfer learning methods on OfficeHome dataset under 3-shot setting. More results can be found in our paper.

Ⅲ.Framework:

This is the framework of our method. More details of the framework of our model are shown in our paper.

Ⅳ.Dataset:

We use four datasets:[Office], [Office-Home], [VisDA-C], [terra_incognita]; they can be downloaded from the official websites, and modify the path of images in each '.txt' under the folder './data/'. And how to generate such txt files could be found in https://github.com/tim-learn/Generate_list

1.Office-31

Original Office-31 dataset can be found here

2.Office-Home

Office-Home dataset can be found here.

3.VisDA-C

Office-Home dataset can be found here.

⚠️ Note: If some resource of the datesets above can not be downloaded using the original website, you can download it in here.

4.terra_incognita

terra_incognita dataset can be found here.

The dataset we used can be downloaded by running download.py.

python download.py --data_dir=./

⚠️ Note: The website of terra_incognita is not authorization now. We use recent download file. Details can be found in download.py.

If some URLs do not work due to various factors, you can copy the URLs and download them manually.

Ⅴ.Training:

  1. few-shot source-free Domain Adaptation (few-shot SFDA) on the Office dataset

  • Train model on the source domain A (s = 0)
python image_source.py --trte val --da uda --gpu_id 0 --dset office --max_epoch 100 --s 0 --seed 2019
  • Adaptation to other target domains D and W, respectively
python image_target.py --da uda --gpu_id 0 --dset office --s 0 --few_shot 3 --seed 0 --SAM --lr 0.00003 --src_seed 2019
  1. few-shot source-free Domain Adaptation (few-shot SFDA) on the Office-Home dataset

  • Train model on the source domain A (s = 0)
python image_source.py --trte val --da uda --gpu_id 0 --dset office-home --max_epoch 50 --s 0 --seed 2021
  • Adaptation to other target domains C and P and R, respectively
python image_target.py --da uda --gpu_id 0 --dset office-home --s 0 --few_shot 1 --seed 0 --SAM --lr 0.00001 --src_seed 2019
  1. few-shot source-free Domain Adaptation (few-shot SFDA) on the VisDA-C dataset

  • Train model on the source domain Synthetic (s = 0)
python image_source.py --trte val --da uda --gpu_id 0--dset office-home --max_epoch 50 --s 0 --seed 2019
  • Adaptation to other target domains real
python image_target.py --da uda --gpu_id 0 --dset VISDA-C --s 0 --few_shot 10 --seed 0 --SAM --lr 0.00003 --src_seed 2019 --net resnet101
  1. few-shot source-free Domain Adaptation (few-shot SFDA) on the terra_incognita dataset

  • Train model on the source domain L38 (s = 0)
python image_source.py --trte val --da uda --gpu_id 0 --dset terra_incognita --max_epoch 50 --s 0 --seed 2019
  • Adaptation to other target domains L43 and L46 and L100, respectively
python image_target.py --da uda --gpu_id 0 --dset terra_incognita --s 0 --few_shot 1 --seed 0 --SAM --lr 0.00003 --src_seed 2019
  1. few-shot source-free Partial-set Domain Adaptation (few-shot SFPDA) on the Office-Home dataset

  • Train model on the source domain A (s = 0)
python image_source.py --trte val --da pda --gpu_id 0 --dset office-home --max_epoch 50 --s 0 --seed 2019
  • Adaptation to other target domains C and P and R, respectively
python image_target_pda.py --da pda --gpu_id 0 --dset office-home --s 0 --few_shot 3 --seed 0 --SAM --lr 0.00003 --src_seed 2019
  1. few-shot source-free Open-set Domain Adaptation (few-shot SFODA) on the Office-Home dataset

  • Train model on the source domain A (s = 0)
python image_source.py --trte val --da oda --gpu_id 0 --dset office-home --max_epoch 50 --s 0 --seed 2019
  • Adaptation to other target domains C and P and R, respectively
python image_target_oda.py --da oda --gpu_id 0 --dset office-home --s 0 --few_shot 3 --seed 0 --SAM --lr 0.00003 --src_seed 2019

Ⅵ.Citation

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

@inproceedings{li2025asymmetric,
  title={Asymmetric Co-training for Source-Free Few-Shot Domain Adaptation},
  author={Li, Gengxu and Wu, Yuan},
  booktitle={Chinese Conference on Pattern Recognition and Computer Vision (PRCV)},
  pages={306--319},
  year={2025},
  organization={Springer}
}

About

[PRCV 2025] Asymmetric Co-Training for Source-Free Few-Shot Domain Adaptation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages