Home

Awesome

<center>Source-free Domain Adaptation via Avatar Prototype Generation and Adaptation</center>

This repository provides the official implementation for "Source-free Domain Adaptation via Avatar Prototype Generation and Adaptation". (IJCAI2021)

Paper

Source-free Domain Adaptation via Avatar Prototype Generation and Adaptation CPGA To handle source-free domain adaptation task, we propose a Contrastive Prototype Generation and Adaptation (CPGA) method. Specifically, CPGA consists of two stage: (1) Prototype generation: under the guidance of the fixed classifier, a generator is trained to generate avatar feature prototypes via and . (2) Protype adaptation: in each training batch, we use the learned prototype generator to generate one prototype for each class. Based on the generated prototypes and pseudo labels obtained by clustering, we align each pseudo-labeled target feature to the corresponding class prototype by training a domain-invariant feature extractor via , and . Note that the classifier is fixed during the whole training phase.

Getting Started

Installation

git clone https://github.com/SCUT-AILab/CPGA.git
cd CPGA
pip install -r requirements.txt

Data Preparation

<!-- - Download the Pneumonia and COVID-19 dataset and put the data in this repo. - Link: [datasets](https://drive.google.com/open?id=1FcXIYJBtfvc1dN54R4cad9cuKVzS8WOb) -->

Training

python train_source --gpu 0 --data_root ./dataset/VISDA-C/train --label_file ./data/visda_synthesis_9_1_split.pkl
python main --gpu 0,1 --max_epoch 1400 --source_model_path ./model_source/synthesis_resnet101_best.pkl --data_path ./dataset/VISDA-C/validation --label_file ./data/visda_real_train.pkl

Testing

To test CPGA on the target domain using the trained model (please assign a trained model path)

python test --gpu 0 --model_path ./model_VISDA-C/best.pkl --data_path ./dataset/VISDA-C/validation --label_file ./data/visda_real_train.pkl
<!-- 提供模型 -->

Results

Classification accuracies (%) on the large-scale VisDA dataset (ResNet-101).

MethodPlaneBicycleBusCarHorseKnifeMcyclPersonPlantSktbrdTrainTruckPer-classPre-training
ResNet-10155.153.361.959.180.617.979.731.281.026.573.58.552.4-
PrDA86.981.784.663.993.191.486.671.984.558.274.542.776.6-
SHOT92.681.180.158.589.786.181.577.889.584.984.349.379.6-
MA94.873.468.874.893.195.488.684.789.184.783.548.181.6-
BAIT93.783.284.565.092.995.488.180.890.089.084.045.382.7-
CPGA (ours)95.689.075.464.991.797.589.783.893.993.487.769.086.0Download

Visualization

We have released the code in the directory ./visualization.

Citation

If you find our work useful in your research, please cite the following paper:

@inproceedings{Qiu2021CPGA,
  title={Source-free Domain Adaptation via Avatar Prototype Generation and Adaptation},
  author={Zhen Qiu and Yifan Zhang and Hongbin Lin and Shuaicheng Niu and Yanxia Liu and Qing Du and Mingkui Tan},
  booktitle={International Joint Conference on Artificial Intelligence},
  year={2021}
}

Contact

For any question, please file an issue or contact

Zhen Qiu: qiuzhenscut@gmail.com
Hongbin Lin: sehongbinlin@mail.scut.edu.cn