Skip to content

Implementation of neural style transfer in Tensorflow as proposed by Gatys et al.

Notifications You must be signed in to change notification settings

briwilcox/Iterative-Neural-Style-Transfer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Iterative-Neural-Style-Transfer

Tensorflow implementation of neural style transfer as proposed by Gatys et al.in the paper A Neural Algorithm of Artistic Style

Sharing a simplified implementation of the style transfer algorithm. Code has been written and executed on GoogleCollab. A brief explanation can be found here

The below examples have been generated with 1000 iterations of Adam Optimizer (lr= 5.0 to 20.0) with content (α) and style (β) weights set to roughly 1e1 and 1e-1 respectively. The original paper mentioned that the ratio α/β was set to 1e-3, 1e-4 or 1e-5 but somehow I was not able to achieve good results with it.

Size of images ranged from 320x320 to 512x512 and took ~45-60 mins to train on CPU and ~2 mins on a GPU. Computation time increases accordingly if the image size is set to be large.

Different hyperparameter settings can be appropriate for different sets of images.

Examples

Content Images

Style Images

Generated Images

Usage

IMAGE_SIZE = <IMAGE_SIZE>
content_image_filename = <content_image_filename>
style_image_filename = <style_image_filename>
run_style_transfer(content_image_filename=content_image_filename,
                  style_image_filename=style_image_filename,
                  epochs=<number_of_epochs>,
                  learning_rate=<learning_rate>,
                  alpha=<content_weight>,
                  beta=<style_weight>
                  prefix=<prefix_of_generated_output_filenames>)

Example:

IMAGE_SIZE = 320
content_image_filename = './dog.jpg'
style_image_filename = './/starry_night.jpg'
run_style_transfer(content_image_filename=content_image_filename,
                  style_image_filename=style_image_filename,
                  epochs=1000,
                  learning_rate=10.0,
                  alpha=10,
                  beta=1e-1,
                  prefix='dog-starry_night')

About

Implementation of neural style transfer in Tensorflow as proposed by Gatys et al.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 100.0%