/ada_in-tf

TensorFlow implementation of a style transfer network using AdaIN

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

AdaIN on TensorFlow

A barebones TensorFlow implementation of a style transfer neural network using adaptive instance normalization (AdaIN)
Uses a pretrained VGG19 for the encoder, closely following Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization by Xun Huang, Serge Belongie

Usage

Train with COCO dataset (available here) as content images and WikiArt dataset (available here) as style images.
Run training with command:

python main.py train <path/to/content-dir> <path/to/style-dir>

Current script will save only the model weights by default as a Keras HDF5 file (.h5), rather than a TensorFlow SavedModel.


For sampling on inference, run:

python main.py infer <path/to/content-image> <path/to/style-image> --model_path <path/to/model-weights> --alpha <alpha> --samples <samples>

Observations

On inference, the images are upsampled by default to a 2048x2048 shape using bilinear interpolation before being passed to the model. This I found to provide the best resulting output images when downsampled back to the original size of the content images. That said, 1024x1024 will also work to produce minimal artifacting on medium-sized images but going higher will usually produce better results.

Content Style Result