Home

Awesome

Fast Style Transfer

A tensorflow implementation of fast style transfer described in the papers:

I recommend you to check my previous implementation of A Neural Algorithm of Artistic Style (Neural style) in here, since implementation in here is almost similar to it.

Sample results

All style-images and content-images to produce following sample results are given in style and content folders.

Chicago

Following results with --max_size 1024 are obtained from chicago image, which is commonly used in other implementations to show their performance.

Click on result images to see full size images.

<p align='center'> <img src = 'content/chicago.jpg' height="220px"> </p> <p align='center'> <img src = 'style/thumbs/wave.jpg' height = '210px'> <img src = 'samples/chicago_wave.jpg' height = '210px'> <img src = 'samples/chicago_the_scream.jpg' height = '210px'> <img src = 'style/thumbs/the_scream.jpg' height = '210px'> <br> <img src = 'style/thumbs/la_muse.jpg' height = '210px'> <img src = 'samples/chicago_la_muse.jpg' height = '210px'> <img src = 'samples/chicago_rain_princess.jpg' height = '210px'> <img src = 'style/thumbs/rain_princess.jpg' height = '210px'> <br> <img src = 'style/thumbs/the_shipwreck_of_the_minotaur.jpg' height = '210px'> <img src = 'samples/chicago_shipwreck.jpg' height = '210px'> <img src = 'samples/chicago_udnie.jpg' height = '210px'> <img src = 'style/thumbs/udnie.jpg' height = '210px'> <br> </p>

Female Knight

The source image is from https://www.artstation.com/artwork/4zXxW

Results were obtained from default setting except --max_size 1920.
An image was rendered approximately after 100ms on GTX 980 ti.

Click on result images to see full size images.

<p align='center'> <img src = 'content/female_knight.jpg' height="220px"> </p> <p align='center'> <img src = 'style/thumbs/wave.jpg' height = '210px'> <img src = 'samples/female_knight_wave.jpg' height = '210px'> <img src = 'samples/female_knight_the_scream.jpg' height = '210px'> <img src = 'style/thumbs/the_scream.jpg' height = '210px'> <br> <img src = 'style/thumbs/la_muse.jpg' height = '210px'> <img src = 'samples/female_knight_la_muse.jpg' height = '210px'> <img src = 'samples/female_knight_rain_princess.jpg' height = '210px'> <img src = 'style/thumbs/rain_princess.jpg' height = '210px'> <br> <img src = 'style/thumbs/the_shipwreck_of_the_minotaur.jpg' height = '210px'> <img src = 'samples/female_knight_shipwreck.jpg' height = '210px'> <img src = 'samples/female_knight_udnie.jpg' height = '210px'> <img src = 'style/thumbs/udnie.jpg' height = '210px'> <br> </p>

Usage

Prerequisites

  1. Tensorflow
  2. Python packages : numpy, scipy, PIL(or Pillow), matplotlib
  3. Pretrained VGG19 file : imagenet-vgg-verydeep-19.mat
          * Please download the file from link above.
          * Save the file under pre_trained_model
  4. MSCOCO train2014 DB : train2014.zip
          * Please download the file from link above. (Notice that the file size is over 12GB!!)
          * Extract images to train2014.

Train

python run_train.py --style <style file> --output <output directory> --trainDB <trainDB directory> --vgg_model <model directory>

Example: python run_train.py --style style/wave.jpg --output model --trainDB train2014 --vgg_model pre_trained_model

Arguments

Required :

Optional :

Trained models

You can download all the 6 trained models from here

Test

python run_test.py --content <content file> --style_model <style-model file> --output <output file> 

Example: python run_test.py --content content/female_knight.jpg --style_model models/wave.ckpt --output result.jpg

Arguments

Required :

Optional :

Train time

Train time for 2 epochs with 8 batch size is 6~8 hours. It depends on which style image you use.

References

The implementation is based on the projects:

[1] Torch implementation by paper author: https://github.com/jcjohnson/fast-neural-style

[2] Tensorflow implementation : https://github.com/lengstrom/fast-style-transfer

Acknowledgements

This implementation has been tested with Tensorflow over ver1.0 on Windows 10 and Ubuntu 14.04.