All Projects → vanhuyz → Cyclegan Tensorflow

vanhuyz / Cyclegan Tensorflow

Licence: mit
An implementation of CycleGan using TensorFlow

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Cyclegan Tensorflow

Gannotation
GANnotation (PyTorch): Landmark-guided face to face synthesis using GANs (And a triple consistency loss!)
Stars: ✭ 167 (-84.76%)
Mutual labels:  gan, generative-adversarial-network, cyclegan
Cyclegan
Software that can generate photos from paintings, turn horses into zebras, perform style transfer, and more.
Stars: ✭ 10,933 (+897.54%)
Mutual labels:  gan, generative-adversarial-network, cyclegan
Cyclegan Qp
Official PyTorch implementation of "Artist Style Transfer Via Quadratic Potential"
Stars: ✭ 59 (-94.62%)
Mutual labels:  gan, generative-adversarial-network, cyclegan
Pytorch Cyclegan And Pix2pix
Image-to-Image Translation in PyTorch
Stars: ✭ 16,477 (+1403.38%)
Mutual labels:  gan, generative-adversarial-network, cyclegan
Anime Inpainting
An application tool of edge-connect, which can do anime inpainting and drawing. 动漫人物图片自动修复,去马赛克,填补,去瑕疵
Stars: ✭ 761 (-30.57%)
Mutual labels:  gan, generative-adversarial-network
Gans In Action
Companion repository to GANs in Action: Deep learning with Generative Adversarial Networks
Stars: ✭ 748 (-31.75%)
Mutual labels:  gan, generative-adversarial-network
Cyclegan
PyTorch implementation of CycleGAN
Stars: ✭ 38 (-96.53%)
Mutual labels:  gan, cyclegan
Relativistic Average Gan Keras
The implementation of Relativistic average GAN with Keras
Stars: ✭ 36 (-96.72%)
Mutual labels:  gan, generative-adversarial-network
Pggan Pytorch
🔥🔥 PyTorch implementation of "Progressive growing of GANs (PGGAN)" 🔥🔥
Stars: ✭ 653 (-40.42%)
Mutual labels:  gan, generative-adversarial-network
Instagan
InstaGAN: Instance-aware Image Translation (ICLR 2019)
Stars: ✭ 761 (-30.57%)
Mutual labels:  gan, generative-adversarial-network
Gandlf
Generative Adversarial Networks in Keras
Stars: ✭ 46 (-95.8%)
Mutual labels:  gan, generative-adversarial-network
Context Encoder
[CVPR 2016] Unsupervised Feature Learning by Image Inpainting using GANs
Stars: ✭ 731 (-33.3%)
Mutual labels:  gan, generative-adversarial-network
Fewshot Face Translation Gan
Generative adversarial networks integrating modules from FUNIT and SPADE for face-swapping.
Stars: ✭ 705 (-35.68%)
Mutual labels:  gan, generative-adversarial-network
Cyclegan Vc3
Voice Conversion by CycleGAN (语音克隆/语音转换):CycleGAN-VC3
Stars: ✭ 52 (-95.26%)
Mutual labels:  gan, cyclegan
Adversarial video generation
A TensorFlow Implementation of "Deep Multi-Scale Video Prediction Beyond Mean Square Error" by Mathieu, Couprie & LeCun.
Stars: ✭ 662 (-39.6%)
Mutual labels:  gan, generative-adversarial-network
Pytorch Pretrained Biggan
🦋A PyTorch implementation of BigGAN with pretrained weights and conversion scripts.
Stars: ✭ 779 (-28.92%)
Mutual labels:  gan, generative-adversarial-network
St Cgan
Dataset and Code for our CVPR'18 paper ST-CGAN: "Stacked Conditional Generative Adversarial Networks for Jointly Learning Shadow Detection and Shadow Removal"
Stars: ✭ 13 (-98.81%)
Mutual labels:  gan, generative-adversarial-network
Contrastive Unpaired Translation
Contrastive unpaired image-to-image translation, faster and lighter training than cyclegan (ECCV 2020, in PyTorch)
Stars: ✭ 822 (-25%)
Mutual labels:  generative-adversarial-network, cyclegan
Image To Image Papers
🦓<->🦒 🌃<->🌆 A collection of image to image papers with code (constantly updating)
Stars: ✭ 949 (-13.41%)
Mutual labels:  gan, generative-adversarial-network
Anime person translation
人脸和动漫脸的互转
Stars: ✭ 35 (-96.81%)
Mutual labels:  gan, cyclegan

CycleGAN-TensorFlow

An implementation of CycleGan using TensorFlow (work in progress).

Original paper: https://arxiv.org/abs/1703.10593

Results on test data

apple -> orange

Input Output Input Output Input Output
apple2orange_1 apple2orange_1 apple2orange_2 apple2orange_2 apple2orange_3 apple2orange_3

orange -> apple

Input Output Input Output Input Output
orange2apple_1 orange2apple_1 orange2apple_2 orange2apple_2 orange2apple_3 orange2apple_3

Environment

  • TensorFlow 1.0.0
  • Python 3.6.0

Data preparing

  • First, download a dataset, e.g. apple2orange
$ bash download_dataset.sh apple2orange
  • Write the dataset to tfrecords
$ python3 build_data.py

Check $ python3 build_data.py --help for more details.

Training

$ python3 train.py

If you want to change some default settings, you can pass those to the command line, such as:

$ python3 train.py  \
    --X=data/tfrecords/horse.tfrecords \
    --Y=data/tfrecords/zebra.tfrecords

Here is the list of arguments:

usage: train.py [-h] [--batch_size BATCH_SIZE] [--image_size IMAGE_SIZE]
                [--use_lsgan [USE_LSGAN]] [--nouse_lsgan]
                [--norm NORM] [--lambda1 LAMBDA1] [--lambda2 LAMBDA2]
                [--learning_rate LEARNING_RATE] [--beta1 BETA1]
                [--pool_size POOL_SIZE] [--ngf NGF] [--X X] [--Y Y]
                [--load_model LOAD_MODEL]

optional arguments:
  -h, --help            show this help message and exit
  --batch_size BATCH_SIZE
                        batch size, default: 1
  --image_size IMAGE_SIZE
                        image size, default: 256
  --use_lsgan [USE_LSGAN]
                        use lsgan (mean squared error) or cross entropy loss,
                        default: True
  --nouse_lsgan
  --norm NORM           [instance, batch] use instance norm or batch norm,
                        default: instance
  --lambda1 LAMBDA1     weight for forward cycle loss (X->Y->X), default: 10.0
  --lambda2 LAMBDA2     weight for backward cycle loss (Y->X->Y), default:
                        10.0
  --learning_rate LEARNING_RATE
                        initial learning rate for Adam, default: 0.0002
  --beta1 BETA1         momentum term of Adam, default: 0.5
  --pool_size POOL_SIZE
                        size of image buffer that stores previously generated
                        images, default: 50
  --ngf NGF             number of gen filters in first conv layer, default: 64
  --X X                 X tfrecords file for training, default:
                        data/tfrecords/apple.tfrecords
  --Y Y                 Y tfrecords file for training, default:
                        data/tfrecords/orange.tfrecords
  --load_model LOAD_MODEL
                        folder of saved model that you wish to continue
                        training (e.g. 20170602-1936), default: None

Check TensorBoard to see training progress and generated images.

$ tensorboard --logdir checkpoints/${datetime}

If you halted the training process and want to continue training, then you can set the load_model parameter like this.

$ python3 train.py  \
    --load_model 20170602-1936

Here are some funny screenshots from TensorBoard when training orange -> apple:

train_screenshot

Notes

  • If high constrast background colors between input and generated images are observed (e.g. black becomes white), you should restart your training!
  • Train several times to get the best models.

Export model

You can export from a checkpoint to a standalone GraphDef file as follow:

$ python3 export_graph.py --checkpoint_dir checkpoints/${datetime} \
                          --XtoY_model apple2orange.pb \
                          --YtoX_model orange2apple.pb \
                          --image_size 256

Inference

After exporting model, you can use it for inference. For example:

python3 inference.py --model pretrained/apple2orange.pb \
                     --input input_sample.jpg \
                     --output output_sample.jpg \
                     --image_size 256

Pretrained models

My pretrained models are available at https://github.com/vanhuyz/CycleGAN-TensorFlow/releases

Contributing

Please open an issue if you have any trouble or found anything incorrect in my code :)

License

This project is licensed under the MIT License - see the LICENSE file for details.

References

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].