Home

Awesome

AdaIN-TF

<p align='center'> <img src='examples/gilbert.gif'> </p>

This is a TensorFlow/Keras implementation of Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization.

Requirements

Optionally:

Training

  1. Download MS COCO images and Wikiart images.

  2. Download VGG19 model: bash models/download_models.sh

  3. python train.py --content-path /path/to/coco --style-path /path/to/wikiart --batch-size 8 --content-weight 1 --style-weight 1e-2 --tv-weight 0 --checkpoint /path/to/checkpointdir --learning-rate 1e-4 --lr-decay 1e-5

  4. Monitor training with TensorBoard: tensorboard --logdir /path/to/checkpointdir

Running a trained model

To stylize images captured from a webcam:

python webcam.py --checkpoint /path/to/checkpointdir --style-path /path/to/wikiart

This script contains a few options:

There are also three keyboard shortcuts:

Additionally, stylize.py will stylize image files. The options are the same as for the webcam script with the addition of --content-path, which can be a single image file or folder. Each style in --style-path will be applied to each content image.

Notes

Acknowledgments

Many thanks to the author Xun Huang for the excellent original Torch implementation that saved me countless hours of frustation. I also drew inspiration from Jon Rei's TF implementation for the .t7 pre-trained decoder and borrowed the clean TF code for the AdaIN transform.

TODO