Neural Style Transfer.

Neural Style Transfer

Implementation of Neural Style Transfer using a GAN(Generative Adversial Network) using the technique outlined in A Neural Algorithm of Artistic Style.

What is Neural Style Transfer

Neural Style Transfer is a technique that takes two images, a content image and a style image, and blends them together so the content image is in the style of the style image.


run in cmd

py .\ --content "images/content/city.jpg" --style "images/style/art.jpg"

or edit the variables

set the path to the content image and style image in the file.

# path to images
CONTENT_IMG_PATH = "images/content/planets.jpg"
STYLE_IMG_PATH = "images/style/art.jpg"

# image will save every epoch under
# save/IMG_SAVE_NAME-{n}.png
IMG_SAVE_NAME = "mountain-greatwave"

You can alter the weights in the style_weight, content_weight, and total_variation_weight

style_weight = 1e-2  # default: 1e-2
content_weight = 1e4  # default: 1e4
total_variation_weight = 30  # default: 30


Running for around 10 epochs(1000 steps) tends to yield the best results. With certain images it may be better to run more or less epochs as well as editing the weights to generate a better image.

The following example was run with 10 epochs with default weights.

Blended Neural Style Image

The Content Image and Style Image for this example

Content Image:

Content Image

Style Image:

Style Image

Other Examples

Deepspace Scene style with La Muse Painting

Deepspace-Art Painting

Sunset mountain style with Greatwave Painting

Sunset Mountain Painting

Vertical City Scene styled with Scream Painting

Cityscape blended painting


Install dependencies with Pip

pip install tensorflow numpy Pillow


  • Tensorflow
  • Numpy
  • Pillow