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.
- PyTorch >= 1.13.0 (with suitable CUDA and CuDNN version)
- torchvision >= 0.14.0
- python3
- Numpy, argparse, scipy, PIL
- sklearn, opencv-python, tqdm
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.
This is the framework of our method. More details of the framework of our model are shown in our paper.
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
Original Office-31 dataset can be found here
Office-Home dataset can be found here.
Office-Home dataset can be found here.
terra_incognita dataset can be found here.
The dataset we used can be downloaded by running download.py.
python download.py --data_dir=./If some URLs do not work due to various factors, you can copy the URLs and download them manually.
- 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- 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- 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- 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- 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- 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 2019If 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}
}