Git Product home page Git Product logo

fast-neural-doodle's Introduction

Faster neural doodle

This is my try on drawing with neural networks, which is faster than Alex J. Champandard's version, and similar in quality. This approach is based on neural artistic style method (L. Gatys), whereas Alex's version uses CNN+MRF approach of Chuan Li.

It takes several minutes to redraw Renoir example using GPU and it will easily fit in 4GB GPUs. If you were able to work with Justin Johnson's code for artistic style then this code should work for you too.

Requirements

  • torch
  • torch.cudnn (optional)
  • torch-hdf5
  • python + numpy + scipy + h5py + sklearn

Tested with python2.7 and latest conda packages.

Do it yourself

First download VGG-19.

cd data/pretrained && bash download_models.sh && cd ../..

Use this script to get intermediate representations for masks.

python get_mask_hdf5.py --n_colors=4 --style_image=data/Renoir/style.png --style_mask=data/Renoir/style_mask.png --target_mask=data/Renoir/target_mask.png

Now run doodle.

th fast_neural_doodle.lua -masks_hdf5 masks.hdf5 -vgg_no_pad

And here is the result. Renoir First row: original, second -- result.

And Monet. Renoir

Multiscale

Processing the image at low resolution first can provide a significant speed-up. You can pass a list of resolutions to use when processing. Passing 256 means that the images and masks should be resized to 256x256 resolution. With 0 passed no resizing is done. Here is an example for cmd parameters:

  • -num_iterations 450,100 -resolutions 256,0 Which means: work for 450 iterations at 256x256 resolution and 100 iterations at original.

Monet and Renoir examples take ~1.5 min to process with these options.

Misc

  • Supported backends:

    • nn (CPU/GPU mode)
    • cudnn
    • clnn (not tested yet..)
  • When using -backend cudnn do not forget to switch -cudnn_autotune.

Acknowledgement

The code is heavily based on Justin Johnson's great code for artistic style.

fast-neural-doodle's People

Contributors

dmitryulyanov avatar

Watchers

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