Artistic Style Transfer App

A cli application which trains the models for style images and stylizes the content images based on the style model selected. This tool is based on the paper by Perceptual Losses for Real-Time Style Transfer and Super-Resolution and Instance Normalization.

Live demo

Check out the live demo of these models at bit.ly/stylizeapp
GitHub repo for the website: Stylize App

Requirements

The tool is written in Python and uses Pytorch and SciPy. A GPU is not required but it can significantly speed up the process of training, the styling however can be done using CPU of a normal laptop or computer as well using the saved models.

Model

Model diagram from Johnson et al

Model makes use of a Transformation Network which converts the input image into output image. We use a loss network pretrained for image classification to define perceptual loss functions that measure perceptual differences in content and style between the images. The loss network remains fixed during the training process.

Usage

Stylize Image

python stylize.py --content-image </path/to/content/image> --model </path/to/saved/model> --output-image </path/to/output/image> --cuda 0

Train Model

python train.py --dataset </path/to/train-dataset> --style-image </path/to/style/image> --save-model-dir </path/to/save-model/folder> --epochs 2 --cuda 1

The hyper-parameters content-weight and style-weight may be altered depending on the style to be trained on for better results.

Live webcam stylizing

Webcam example

python webcam.py --model </path/to/saved/model> --width 640 --height 360 --cuda 1

Press esc to exit the camera capture window.

Models

Stored under models as: mosaic.model
Mosaic Style example
Credits for content image: Aryaman Arya