# Styling image based on image using Artistic Neural Algorithm in Tensorflow

Have you thought modifying an image based on other image features? I tried the same to understand how CNN works in terms of understanding the image.

Neural Algorithm of the Artistic Style (Gatys et al.http://arxiv.org/abs/1508.06576)

Here is the final/result Image:

 Source Image Style Image

Coding Source: https://github.com/janivanecky/Artistic-Style

Above is a very simple implementation of Neural Algorithm of the Artistic Style (Gatys et al.http://arxiv.org/abs/1508.06576) in Tensorflow. I used VGG implementation from Chris and modified it slightly, stripping away unnecessary layers.

In the examples below I used content image as an initialization, it seems to provide more consistent image, but in the code, you can switch easily to noise initialization on line 109 in style.py. I used Adam for optimizer and let it run for 500 iterations.

## Usage

python style.py content_image_path style_image_path [output_image]
[{top,center,bottom,left,right}] [content_scale] [style_weight]

### Running Command:

\$ python style.py avkash.jpg samurai.jpg result.jpg center 1 1

Iteration 0: 101205584.0
Iteration 5: 28933696.0
Iteration 10: 12709578.0
Iteration 15: 6670791.0
……….
……….
Iteration 480: 104311.460938
Iteration 485: 97180.828125
Iteration 490: 91784.2890625
Iteration 495: 88249.4609375

### Configuration:

• Total 500 iteration – Line # 144 in style.py
• It is using tensorflow adam oprimizer – Line #137 style.py – tf.train.AdamOptimizer
• This network has 4 CNN as defined in vgg.py

• Make sure vgg.py & vgg19.npy is in the same folder along with style.py
• Try to chage the optimizer and see the results:

### Apendix:

ubuntu@XXXXX:~\$ pip show Pillow
Name: Pillow
Version: 3.4.2
Summary: Python Imaging Library (Fork)
Home-page: http://python-pillow.org
Author: Alex Clark (Fork Author)
Author-email: aclark@aclark.net
Location: /usr/local/lib/python2.7/dist-packages
Requires:
ubuntu@XXXXX:~\$ pip show tensorflow
Name: tensorflow
Version: 0.11.0rc2
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow.org/