Giter VIP home page Giter VIP logo

fast-style-transfer's Introduction

fast-style-transfer

Just a little fun I had during the summer implementing fast style transfer in TensorFlow. When I have the time, I'll look into implementing n-style transfer and universal style transfer.

Our implementation is based off Logan Engstrom's implementation. The following modifications where made:

  1. Transpose convolutions were replaced with nearest neighbor upsampling, based on Odena's Deconvolution and Checkerboard Artifacts.
  2. Zero-padding replaced with reflection-padding in convolutions, based on Dumoulin's A Learned Representation For Artistic Style.
  3. Added Tensorboard visualizations.

Dependencies

You'll need

python==2.7
ffmpeg==3.2.2

You'll also need the following python libraries

numpy==1.13.0
scipy==0.18.1
tensorflow==1.1.0
tensorbayes==0.2.0

Run style transfer

Get training data

Get data and VGG weights for training:

sh get_data.sh

Train model

Example of training with target style data/styles/hatch.jpg:

python main.py train \
  --content-weight 15 \
  --style-weight 100 \
  --target-style data/styles/hatch.jpg \
  --validation-dir data/validation

Models are automatically saved to checkpoints/MODEL_NAME where MODEL_NAME is STYLE_sw=STYLE_WEIGHT (e.g. checkpoints/hatch_sw=100). A validation directory is required to monitor the visual performance of the fast-style-transfer network. The default arguments work fairly well, so the only thing you really need to provide is the target style.

Test model

Once trained we can test the model on, for example, images in the data/validation directory:

python main.py test \
  --model-name MODEL_NAME \
  --ckpt CKPT \
  --test-dir data/validation \

If --ckpt is not provided, the latest checkpoint from checkpoints/MODEL_NAME is loaded.

Or if you have a specific jpg/png/mp4 file:

python main.py test \
  --model-name MODEL_NAME \
  --ckpt CKPT \
  --test-file path/to/test/file

Here is style transfer applied to Linkin Park's Numb :D

Tensorboard visualization

A tensorboard summary is created and saved in log when training the model. You can see how the model is doing there. smileyball

fast-style-transfer's People

Contributors

ruishu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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