Skip to content

Curt-Park/style_transfer_keras

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Style Transfer with Keras

This is a Keras implementation of style transfer techniques described in the following paper:

Differences from the paper

All differences are marked with comments that start with '! the original paper ...'

  • The CNN Model: VGG16 is used instead of VGG19.
  • The loss function for style representations: It is divided by (2. * feature map size * channel number).
  • The initial canvas: a content image.

They make better results on my implementation rather than the settings suggested by the original paper, empirically.

Developed with

  • Keras 2.1.2
  • Python 3.6.3
  • Python packages: numpy, scipy, PIL

How to run

python style_transfer.py [options]

Options

$ python style_transfer.py --help
usage: style_transfer.py [-h] [--content CONTENT] [--style STYLE]
                         [--output OUTPUT] [--iteration ITERATION]
                         [--loss_ratio LOSS_RATIO]
                         [--initialization {random,content,style}]
                         [--save_image_every_nth SAVE_IMAGE_EVERY_NTH]
                         [--verbose VERBOSE]

optional arguments:
  -h, --help            show this help message and exit
  --content CONTENT     The path of the content image (Default: './images/content/tubingen.jpg')
  --style STYLE         The path of the style image (Default: './images/style/shipwreck.jpg')
  --output OUTPUT       The directory path for results (Default: './outputs/')
  --iteration ITERATION
                        How many iterations you need to run (Default: 1000)
  --loss_ratio LOSS_RATIO
                        The ratio between content and style -> content / style (Default: 1e-3)
  --initialization {random,content,style}
                        The initial canvas (Default: 'content')
  --save_image_every_nth SAVE_IMAGE_EVERY_NTH
                        Save image every nth iteration (Default: 10)
  --verbose VERBOSE     Print reports (Default: True)

File descriptions

├── image/
│   ├── content/ # content images
│   ├── style/ # style images
│   └── results/ # outcomes from style-transfer
├── style_transfer.py
└── utils.py

Sample Results

All examples are obtained by default settings.

Reproduction

The attempt to reproduce Figure 3 of the paper, which renders a photograph of the Neckarfront in Tübingen, Germany in the style of 5 different paintings. + You can see the generating progress video by clicking the image.

Top Row (left to right): No style, The Shipwreck of the Minotaur, The Starry Night

Bottom Row (left to right): Composition VII, The Scream, Seated Nude

More trials

These are more trials on my son's photo. As above, the generating progress videos will be played by clicking the images.

Top Row (left to right): No style, Girl before a mirror

Bottom Row (left to right): Hokusai, 훈민정음

References

Paper

Implementation