Code Monkey home page Code Monkey logo

cyclegan's Introduction




CycleGAN in PyTorch

forthebadge made-with-python ForTheBadge built-with-love

We provide PyTorch implementation for both unpaired and paired image-to-image translation applied for medical image segmentation.

The code was strongly inspired by the code of : Jun-Yan Zhu and Taesung Park.

Motivation

The main objective of this work is twofold :

  • Generate synthetic cell images that model the distribution of the input images for data augmentation. Use both of the synthetic and real cells images for training a contextaware CNN that can accurately segment these cells. See : GANs

  • We propose to employ a segmentation method based on cycle-consistent generative adversarial networks that can be trained even in absence of prepared image-mask pairs

Prerequisites

  • Python 3
  • CPU or NVIDIA GPU + CUDA CuDNN

Getting Started

Installation

  • Clone this repo:
git clone https://github.com/AissamDjahnine/CycleGAN.git
cd CycleGAN
  • Install PyTorch and 0.4+ and other dependencies (e.g., torchvision and dominate).

    • For pip users, please type the command pip install -r requirements.txt.
  • Train a model:

python train.py --dataroot ./datasets/rpedata --name rpedata --model cycle_gan --gan_mode vanilla --dataset_mode unaligned --n_epochs 100 --n_epochs_decay 50 --save_epoch_freq 20 

To see more intermediate results, check out ./checkpoints/maps_cyclegan/web/index.html.

  • Test the model:
  • Change the --dataroot and --name to be consistent with your trained model's configuration.

  • Using --model cycle_gan requires loading and generating results in both directions. The results will be saved at ./results/. Use --results_dir {directory_path_to_save_result} to specify the results directory.

  • For your own experiments, you might want to specify --netG, --norm, --no_dropout to match the generator architecture of the trained model.

python test.py --dataroot datasets/rpedata --name rpedata --dataset_mode aligned --no_dropout  --model cycle_gan --norm
  • The test results will be saved to a html file here: ./results/maps_cyclegan/latest_test/index.html.

Unpaired, Paired datasets :

  • For paired mode, please use the python function : combine_A_B.py to join train images. you should have two folders : train and test with joined images.

  • For unpaired mode, you should have 4 folders : trainA, trainB, testA, testB with images in both domains.

  • You can download an unpaired version of Human U2OS cells : Unpaired_dataset.

  • You can download a paired version of Human Retinal Pigment Epithelium (RPE) cells : Paired data

Notebook :

  • You find the notebook associated with this projects. after cloning the project , open the notebook and follow instructions

Tensorboard

If you're familiar with Tensorboard , skip this section

In your terminal, run:

tensorboard --logdir ./runs
  • You should be looking to : gans

Acknowledgments

Our code is inspired by pytorch-DCGAN.

References

  • Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks.
    Jun-Yan Zhu, Taesung Park, Phillip Isola, Alexei A. Efros. In ICCV 2017.

  • "Generative Adversarial Networks." Ian J. Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, Yoshua Bengio. ArXiv 2014.

  • "Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks" Alec Radford, Luke Metz, Soumith Chintala

Questions :

Generic badge Ask Me Anything ! GitHub followers

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please feel free to contact if case of issues.

cyclegan's People

Contributors

aissamdjahnine avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

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.