- python 3.6.8
conda create -n HCDG python=3.6.8
-
PyTorch 1.5.0
conda activate HCDG conda install pytorch==1.5.0 torchvision cudatoolkit=9.2 -c pytorch pip install tensorboardX==2.0 pip install opencv-python pip install pyyaml pip install MedPy pip install tqdm pip install matplotlib conda install -c anaconda scikit-image
-
Download the Fundus dataset into your own folder and change
--data-dir
correspondingly. -
Train the model.
python train.py -g 0 --datasetTrain 1 2 3 --datasetTest 4 --batch-size 4 --resume ./pretrained-weight/test4-40.pth.tar # You need to pretrain a vanilla model
-
Test the model.
python test.py --model-file ./logs/test4/20210910_215812.079473/checkpoint_50.pth.tar --datasetTest 4 -g 0
If you find this code helpful, please cite our paper:
@article{yang2021hcdg,
title={Hcdg: A Hierarchical Consistency Framework for Domain Generalization on Medical Image Segmentation},
author={Yang, Yijun and Wang, Shujun and Zhu, Lei and Yu, Lequan},
publisher={AIIM-D-22-01172}
}