Code Monkey home page Code Monkey logo

fast-neural-style's Introduction

Minor changes of base repository.

Fast neural style transfer

A short writeup and example images are up on my blog.

In an attempt to learn Tensorflow I've implemented an Image Transformation Network as described in Perceptual Losses for Real-Time Style Transfer and Super-Resolution by Johnson et al.

This technique uses loss functions based on a perceptual similarity and style similarity as described by Gatys et al to train a transformation network to synthesize the style of one image with the content of arbitrary images. After it's trained for a particular style it can be used to generate stylized images in one forward pass through the transformer network as opposed to 500-2000 forward + backward passes through a pretrained image classification net which is the direct approach.

Usage

First get the dependecies (COCO training set images and VGG model weights):

./get_files.sh

To generate an image directly from style and content, typically to explore styles and parameters:

python neural_style.py --CONTENT_IMAGE content.png --STYLE_IMAGES style.png

Also see other settings and hyperparameters in neural_style.py

To train a model for fast stylizing:

python fast_neural_style.py --TRAIN_IMAGES_PATH coco_img_path --STYLE_IMAGES style.png --BATCH_SIZE 4

Where --TRAIN_IMAGES_PATH points to a directory of JPEGs to train the model. The paper uses the COCO image dataset (13GB). With my 2GB GTX960 card I can do a batch_size of 3 images. The paper trains the model for 2 epochs (160.000/BATCH_SIZE iteration).

To generate images fast with an already trained model:

python fast_neural_style.py --CONTENT_IMAGES path_to_images_to_transform

Requirements

Acknowledgement

fast-neural-style's People

Contributors

olavhn avatar bazarevsky avatar

Watchers

James Cloos avatar fun_dl 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.