Python
Switch branches/tags
Nothing to show
Latest commit fe34684 May 17, 2017 @giuseppebonaccorso committed on GitHub Update README.md
Permalink
Failed to load latest commit information.
img Initial commit May 16, 2017
.gitignore Initial commit May 16, 2017
README.md Update README.md May 17, 2017
example.py Initial commit May 16, 2017
license Create license May 16, 2017
neural_styler.py Initial commit May 16, 2017

README.md

Neural artistic style tranfer


Based on: Leon A. Gatys, Alexander S. Ecker, Matthias Bethge, "A Neural Algorithm of Artistic Style", arXiv:1508.06576
See also: https://github.com/fchollet/keras/blob/master/examples/neural_style_transfer.py
See some examples on: https://www.bonaccorso.eu/2016/11/13/neural-artistic-style-transfer-experiments-with-keras/

Usage

There are three possibile canvas setup:

  • Picture: The canvas is filled with the original picture
  • Style: The canvas is filled with the style image (resized to match picture dimensions)
  • Random from style: The canvas is filled with a random pattern generated starting from the style image

Some usage examples (both with VGG16 and VGG19):

Picture and style over random:
canvas='random_from_style', alpha_style=1.0, alpha_picture=0.25, picture_layer='block4_conv1'
Style over picture:
canvas='picture', alpha_style=0.0025, alpha_picture=1.0, picture_layer='block4_conv1'
Picture over style:
canvas='style', alpha_style=0.001, alpha_picture=1.0, picture_layer='block5_conv1'

Code snippets

neural_styler = NeuralStyler(picture_image_filepath='img\\GB.jpg',
                                 style_image_filepath='img\\Magritte.jpg',
                                 destination_folder='\\destination_folder',
                                 alpha_picture=0.4,
                                 alpha_style=0.6,
                                 verbose=True)

neural_styler.fit(canvas='picture', optimization_method='L-BFGS-B')
neural_styler = NeuralStyler(picture_image_filepath='img\\GB.jpg',
                                 style_image_filepath='img\\Magritte.jpg',
                                 destination_folder='\\destination_folder',
                                 alpha_picture=0.25,
                                 alpha_style=1.0,
                                 picture_layer='block4_conv1',
                                 style_layers=('block1_conv1',
                                               'block2_conv1',
                                               'block3_conv1',
                                               'block4_conv1',
                                               'block5_conv1'))
                                               
neural_styler.fit(canvas='random_from_style', optimization_method='CG')

Requirements

  • Python 2.7-3.5
  • Keras
  • Theano/Tensorflow
  • SciPy

Examples

Cezanne

Magritte

Dalì

Matisse

Picasso

Rembrandt

De Chirico

Mondrian