Optimization-based Neural Style Transfer
Contents
Overview
This page provides instructions on how to set up and run an artistic style transfer program on your machines. The following implementation is based on the optimization method proposed by Gatys et al in 2015 ([1]).
Setup & Execution
Pre-requisites
This program has been implemented in Python 2.7. The following libraries must be installed on your system to run it:
- Numpy
- Scipy
- Keras
- h5py
- Tensorflow
Usage
Download the following zip file for the code Media:NeuralStyleTransfer.zip to your preferred directory on your machine. This program accepts multiple arguments that provide the user with the flexibility of altering inputs and outputs without modifying the code:
(Mandatory)
Without these arguments, the program will not run
- Path to content image
- Path to style images(s). One or more style images can be provided by separating each path with space.
- Path to save generated image.
Open the Terminal from that directory and run the program using the following command:
python NST.py path/to/content/image path/to/content/image path/to/style/image(s) path/to/generated/image
Example:
python NST.py images/inputs/content/Dipping-Sun.jpg images/inputs/style/the_scream.jpg images/inputs/style/wave_kanagawa.jpg Results/blue
(Optional)
These arguments have default values, and can hence be skipped if required
- Minimum image size. Default value: 400. Hence, the generated image saved has a size of 400 x 713.
- To change this, you can pass the following argument to the command:
--image_size <new_value>
Example:--image_size 800
- To change this, you can pass the following argument to the command:
- Content weight. Default value: 0.025.
- To change this, you can pass the following argument to the command:
--content_weight <new_value>.
Example:--content_weight 0.5
- To change this, you can pass the following argument to the command:
- Style weight(s). Default value: 1.0 (in case of single style transfer), 1/n for each style (in case of n-style transfer).
- To change this, you can pass the following argument to the command:
--style_weight <new_value(s) separated by space>.
Example:--style_weight 0.3 0.7
Caution: Weights assigned are matched to the corresponding style image provided in the style path argument.
- To change this, you can pass the following argument to the command:
- Number of iterations. Default value: 10.
- To change this, you can pass the following argument to the command:
--num_iter <new_value>.
Example:--num_iter 25
- To change this, you can pass the following argument to the command:
- Model. Default value: "vgg19".
- To change this, you can pass the following argument to the command:
--model <new_value>.
Example:--model 'vgg16'
- To change this, you can pass the following argument to the command: