Implementation of Google Brain's A Learned Representation For Artistic Style in Tensorflow. You can mix various type of style image using just One Model and it's still Fast!
Figure1. Using one model and making multi style transfer image. Center image is mixed with 4 styleThis paper is next version of Perceptual Losses for Real-Time Style Transfer and Super-Resolution and Instance Normalization: The Missing Ingredient for Fast Stylization. These papers are fast and nice result, but one model make only one style image.
The key of this paper is Conditional instance normalization.
Instance normalization is similar with batch normalization,but it doesn't accumulate mean(mu), variance(alpha). Conditional instance normalization have N scale(gamma) and N shift(beta). N means style number. This mean when you add new style, you just train new gamma and new beta. See the below results.
From Scratch. Train weight, bias, gamma, beta
(40000 iteration)Fine-Tuned. Gradually change to new style. Train new gamma, beta.
(4000 iteration, 1/10 scratch)Recommand to download project files here (src, model, vgg, image, etc.). And Download COCO on your data folder. Example command lines are below and train_style.sh, test_style.sh.
"-scw, --style_control_weights" is style control argument. If you want single style then set argument like "1 0 0 ... 0 0", "0 0 0 ... 0 0 1". If you want multi style then set argument like "0.5 0.5 0 ... 0 0", "0.3 0.3 0.3 ... 0 0", "1 1 1 1 ... 1 1 1"
From Scratch
python main.py -f 1 -gn 0 -p MST -n 5 -b 16 \
-tsd images/test -sti images/style_crop/0_udnie.jpg \
-scw 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \
Fine-Tuned
python main.py -f 1 -gn 0 -p MST -n 1 -b 16 \
-tsd images/test -sti images/style_crop/1_la_muse.jpg \
-scw 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \
Single style
python main.py -f 0 -gn 0 -p MST \
-tsd images/test \
-scw 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \
Multi Style
python main.py -f 0 -gn 0 -p MST \
-tsd images/test \
-scw 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 \
- TensorFlow 1.0.0
- Python 2.7.12, Pillow 3.4.2, scipy 0.18.1, numpy 1.11.2
This project borrowed some code from Lengstrom's fast-style-transfer. And Google brain's code is here (need some install)