This is a Keras implementation of style transfer techniques described in the following paper:
- Image Style Transfer Using Convolutional Neural Networks by Leon A. Gatys, Alexander S. Ecker, Matthias Bethge
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.
- Keras 2.1.2
- Python 3.6.3
- Python packages: numpy, scipy, PIL
python style_transfer.py [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)
├── image/
│ ├── content/ # content images
│ ├── style/ # style images
│ └── results/ # outcomes from style-transfer
├── style_transfer.py
└── utils.py
All examples are obtained by default settings.
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
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, 훈민정음
- Image Style Transfer Using Convolutional Neural Networks by Leon A. Gatys, Alexander S. Ecker, Matthias Bethge
- Keras examples by Keras Team
- Keras based Neural Style Transfer by giuseppebonaccorso
- Fast AI's Deep learning course by Fast AI
- Tensorflow Style-Transfer by Hwalsuk Lee
- TensorFlow (Python API) implementation of Neural Style by cysmith