Feed-Forward-Style-Transfer implemented in TensorFlow

This is a TensorFlow implementation of Perceptual Losses for Real-Time Style Transfer and Super-Resolution using [instance normalization]() as a regularizer to improve training efficiency and test results.1

The loss derived from A Neural Algorithm of Artistic Style is used to train a generative neural network to apply artistic style transfer to some input image. Total variation denoising is used as a regularizer to reduce unrealistic constrast between adjacent pixels, which in turn reduces visible noise.

Unlike the non-feed-forward implementation, this implementation is deterministic due to the nature of the generator.

Implementation Architecture

A generative convolutional neural network was used with downsampling layers followed by residual blocks. This is followed by upsampling layers accomplished using fractionally strided convolutions, which has been incorrectly termed "deconvolution" in some publications. Normalization of inputs is performed to reducing internal covariate shift.

For description of the generator's output, a pretrained VGG network was used. It is provided here by machrisaa on GitHub. The VGG implementation was customized to accomodate the implementation requirements requirements and is of the 16-layer variety.

1 The generative network can still support batch normalization if needed. Simply replace instance normalization calls with batch normalization and adjust the generator's input size.

Results

Prerequisites

Usage

To train a generative model to apply artistic style transfer invoke train.py with the file path of the image who's style you'd like to learn. A new directory with the name of the file will be created under the lib/generators and it will contain the network's trained paramater values for future use.

python train.py /path/to/style/image

To apply artistic style transfer to an image, invoke test.py with its file path through --input and specify the desired style through --style (i.e., "starry-night").

python test.py --input /path/to/input/image --style "style name"

To list available styles (trained models in lib/generators, invoke test.py with the --styles flag.

python test.py --styles

Files