Python
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 4 commits ahead, 45 commits behind anishathalye:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
.editorconfig
.gitignore
LICENSE.txt
README.md
neural_style.py
stylize.py
vgg.py

README.md

neural-style

An implementation of neural style in TensorFlow.

This implementation is a lot simpler than a lot of the other ones out there, thanks to TensorFlow's really nice API and automatic differentiation.

TensorFlow doesn't support L-BFGS (which is what the original authors used), so we use Adam. This may require require a little bit more hyperparameter tuning to get nice results.

TensorFlow seems to be slower than a lot of the other deep learning frameworks out there. I'm sure this implementation could be improved, but it would probably take improvements in TensorFlow itself as well to get it to operate at the same speed as other implementations. As of now, it seems to be around 3x slower than implementations using Torch.

Running

python neural_style.py --content <content file> --styles <style file> --output <output file>

(run python neural_style.py --help to see a list of all options)

Example 1

Running it for 500-2000 iterations seems to produce nice results. With certain images or output sizes, you might need some hyperparameter tuning (especially --content-weight, --style-weight, and --learning-rate).

The following example was run for 1000 iterations to produce the result (with default parameters):

output

These were the input images used (me sleeping at a hackathon and Starry Night):

input-content

input-style

Example 2

The following example demonstrates style blending, and was run for 1000 iterations to produce the result (with style blend weight parameters 0.8 and 0.2):

output

The content input image was a picture of the Stata Center at MIT:

input-content

The style input images were Picasso's "Dora Maar" and Starry Night, with the Picasso image having a style blend weight of 0.8 and Starry Night having a style blend weight of 0.2:

input-style input-style

Requirements

License

Copyright (c) 2015 Anish Athalye. Released under GPLv3. See LICENSE.txt for details.