Giter VIP home page Giter VIP logo

tf-adain's Introduction

Overview

Implementation of Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization in Tensorflow

Paper

https://arxiv.org/abs/1703.06868

Setup

git clone https://github.com/ftokarev/tf-adain
cd tf-adain
virtualenv venv --python /usr/bin/python3
source venv/bin/activate
pip install -r requirements.txt
bash models/get_vgg.sh

Usage

Basic

Use --content and --style to provide the respective path to the content and style image, for example:

./test.py --content input/content/cornell.jpg --style input/style/woman_with_hat_matisse.jpg --content_size 0 --style_size 0

To run the code on directories of content and style images use --content_dir and --style_dir options. It will save every possible combination of content and styles to the output directory.

./test.py --content_dir input/content --style_dir input/style

Other options:

  • --crop: Center crop both content and style images beforehand.
  • --content_size: Scale the content image to this size, keeping proportions. Set to zero to keep the original size.
  • --style_size: Scale the style image to this size, keeping proportions. Set to zero to keep the original size.

To see all available options, type:

./test.py -h

Content-Style tradeoff

Use --alpha to adjust the degree of stylization. It should be a value between 0 and 1 (default).

Preserve color

Add --preserve_color to preserve the color of the content image. Example usage:

./test.py --content input/content/newyork.jpg --style input/style/brushstrokes.jpg --content_size 0 --style_size 0 --preserve_color

Style Interpolation

To interpolate between several style images, provide them as a comma-separated list. You can control the relative weight of each style by using the --style_interp_weights option. Example usage:

./test.py --content input/content/avril.jpg --style input/style/picasso_self_portrait.jpg,input/style/impronte_d_artista.jpg --style_interp_weights 1,1 --crop --style_size 400

Spatial Control

Use --mask to provide the path to a binary foreground mask. You can transfer the foreground and background of the content image to different styles. Note that you also to need to provide two style images separated be comma, in which the first one is applied to foreground and the second one is applied to background. Example usage:

./test.py --content input/content/blonde_girl.jpg --style input/style/woman_in_peasant_dress_cropped.jpg,input/style/mondrian_cropped.jpg --mask input/mask/mask.png --content_size 0 --style_size 0

Training

./datasets/get_coco_train.sh
  • Prepare datasets for training
./prepare_dataset.py datasets/coco/train2014/ datasets/coco/
./prepare_dataset.py datasets/wikiart/train/ datasets/wikiart/
  • Launch the training script
./train.py

To see all available options, type:

./train.py -h

Acknowledgement

tf-adain's People

Contributors

alessiamarcolini avatar ftokarev avatar sjosund avatar

Watchers

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