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.
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)
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):
These were the input images used (me sleeping at a hackathon and Starry Night):
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):
The content input image was a picture of the Stata Center at MIT:
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:
- TensorFlow
- SciPy
- Pillow
- NumPy
- Pre-trained VGG network (MD5
8ee3263992981a1d26e73b3ca028a123
)
Copyright (c) 2015-2016 Anish Athalye. Released under GPLv3. See LICENSE.txt for details.