Temporary PyTorch implementation of Cross-Domain Generalization: Enhancing Rare Disease Data Representation using Diffusion Model by Wonseok Oh et al.
We propose the Cross-Domain Genralization model, which translates the input domain data type A into output domain data B.
$ conda create -n cd_gen python=3.6
$ pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html
$ conda install -c conda-forge packaging
$ conda install -c "conda-forge/label/cf201901" visdom
$ conda install -c conda-forge gputil
$ conda install -c conda-forge dominate
Download the dataset with following script e.g.
bash ./datasets/download_cut_dataset.sh (update required)
please refer to the original repository of CUT and UNSB
Refer the ./run_train.sh
file or
python train.py --dataroot ./datasets/Domain_A_penumonia --name A2B \
--mode sb --lambda_SB 1.0 --lambda_NCE 1.0 --gpu_ids 0 -direction A2B
for reverse direction run the below code,
python train.py --dataroot ./datasets/Domain_A_penumonia --name B2A \
--mode sb --lambda_SB 1.0 --lambda_NCE 1.0 --gpu_ids 0 -direction B2A
Although the training is available with arbitrary batch size, we recommend to use batch size = 1.
Refer the ./run_test.sh
file or
python test.py --dataroot [path/to/dataset] --name [experiment] --mode [user-mode] \
--phase test --epoch [test-epoch] --eval --num_test [number-image] \
--gpu_ids 0 --checkpoints_dir ./checkpoints
The outputs will be saved in ./results/[experiment]/
Folders named as fake_[num_NFE]
represent the generated outputs with different NFE steps.
For evaluation, we use official module of pytorch-fid
python -m pytorch_fid [/output/path] [/real/path]
/real/path
should be test images of target domain.
For testing on our vgg-based trained model,
Refer the ./vgg_sb/scripts/test_sc_main.sh
file
The pre-trained checkpoints are provided here
Will be updated
Our source code is based on CUT and UNSB.
We used pytorch-fid for FID calculation.
We modified the network based on the implementation of DDGAN.