This a PyFunt port of the code for the paper:
Perceptual Losses for Real-Time Style Transfer and Super-Resolution
Justin Johnson,
Alexandre Alahi,
Li Fei-Fei
To appear at ECCV 2016
The paper builds on A Neural Algorithm of Artistic Style by Leon A. Gatys, Alexander S. Ecker, and Matthias Bethge by training feedforward neural networks that apply artistic styles to images. After training, our feedforward networks can stylize images hundreds of times faster than the optimization-based method presented by Gatys et al.
This repository also includes an implementation of instance normalization as described in the paper Instance Normalization: The Missing Ingredient for Fast Stylization by Dmitry Ulyanov, Andrea Vedaldi, and Victor Lempitsky. This simple trick significantly improves the quality of feedforward style transfer models.
Stylizing this image of the Stanford campus at a resolution of 1200x630 takes 50 milliseconds on a Pascal Titan X:
Check the full readme and the original lua+torch source code here: https://github.com/jcjohnson/fast-neural-style
If you find this code useful for your research, please cite
@inproceedings{Johnson2016Perceptual,
title={Perceptual losses for real-time style transfer and super-resolution},
author={Johnson, Justin and Alahi, Alexandre and Fei-Fei, Li},
booktitle={European Conference on Computer Vision},
year={2016}
}
pip install git+git://github.com/dnlcrl/PyFunt.git@dev
Download all pretrained style transfer models by running the script
bash models/download_style_transfer_models.sh
This will download ten model files (~200MB) to the folder models/
.
The script fast_neural_style.py
lets you use a trained model to stylize new images:
python fast_neural_style.py \
-model models/eccv16/starry_night.t7 \
-input_image images/content/chicago.jpg \
-output_image out.png
You can run the same model on an entire directory of images like this:
python fast_neural_style.lua \
-model models/eccv16/starry_night.t7 \
-input_dir images/content/ \
-output_dir out/
You can control the size of the output images using the -image_size
flag.
The full set of options for this script is described here.
You can check other examples of images generated with this code and PyFunt on Tumblr, here and here.
Free for personal or research use; for commercial use please contact me.