Giter Site home page Giter Site logo

prbs5kong / crossdomain_gen Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 13.92 MB

Code of the paper Cross-Domain Generalization: Enhancing Rare Disease Data Representation using Diffusion Model

License: MIT License

TeX 0.29% Python 96.11% Shell 0.73% C++ 0.37% Cuda 2.19% MATLAB 0.31%

crossdomain_gen's Introduction

Cross-Domain Generalization

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.

Environment

$ 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 

Dataset Download

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

Training

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.

Test & Evaluation

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

References

Will be updated

Acknowledgement

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.

crossdomain_gen's People

Contributors

prbs5kong avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

crossdomain_gen's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.