Code Monkey home page Code Monkey logo

fast_multi_style_transfer-tf's Introduction

Fast Multi Style Transfer

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 style

This 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.

Implementation Details

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)

Usage

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"

Train

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 \

Test

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  \

Requirements

  • TensorFlow 1.0.0
  • Python 2.7.12, Pillow 3.4.2, scipy 0.18.1, numpy 1.11.2

Attributions/Thanks

This project borrowed some code from Lengstrom's fast-style-transfer. And Google brain's code is here (need some install)

fast_multi_style_transfer-tf's People

Watchers

James Cloos avatar Jasonking avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.