I implement a tensorflow&keras model described in the papers
- "A Neural Algorithm of Artistic Style".
- "Image Style Transfer Using Convolutional Neural Networks", CVPR 2016. by Leon A. Gatys, Alexander S. Ecker, Matthias Bethge
- Ubuntu 16.04
- Python 3.6
- Numpy
- Opencv2
- Matplotlib
- Tensorflow (1.4 <= x <=1.13)
images(dir)
: images for style transfer.neural_style_transfer.py
: main code for style transfer.neural_style_transfer.ipynb
: you can execute this code on jupyternotebook. recommend 'Colab' of Google.
python neural_style_transfer.py --content_image_path <content image path> --style_image_path <style image path>
# ex)
python neural_style_transfer.py --content_image_path images/content/tubingen.jpg --style_image_path images/style/starry-night.jpg
Required :
--content_image_path
: Path of the content image. Default:images/content/tubingen.jpg
--style_image_path
: Path of the style image. Default:images/style/starry-night.jpg
Optional :
--model_type
: Type of pretrained model. Choices: 0(VGG16), 1(VGG19) Default:0
--image_resize
: Resize(int or tuple) images. Default:512
--rescale_image
: Rescale the final image to original size. Default:False
--content_blocks
: Layer list for feature vector of Content image. Default:['block4_conv2']
--style_blocks
: Layer list for feature vector of Style image. Default:['block1_conv1', 'block2_conv1', 'block3_conv1', 'block4_conv1', 'block5_conv1']
--loss_ratio
: Weight of content-loss relative to style-loss. Alpha over beta in the paper. Default:1e-3
--total_variation_weight
: Total Variation weight. Default:0 (If you want to use this, then 8.5e-5)
--initial_type
: The initial image to generate image. Choices: content, style, random. Default:'random'
--optimizer_type
: The optimizer for optimization. Choices: 0(Adam Optimizer), 1(L-BFGS-B Optimizer). Default:1
--learning_rate
: The value of learning rate for Adam Optimizer. Default:1e+1
--beta_1
: Beta_1 of Adam Optimizer. Default:0.9
--beta_2
: Beta_2 of Adam Optimizer. Default:0.999
--epsilon
: Epsilon of Adam Optimizer. Default:1e-08
--iteration
: The number of iterations. Default:150
All of results made from default setting and executed on Colab.
Female Knight (source)
blue-moon-lake (source)
All of results made from default setting and executed on Colab.