This is my try on drawing with neural networks, which is much faster than Alex J. Champandards version, and similar in quality. This approach is based on neural artistic style method (L. Gatys), whereas Alexs 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 Johnsons code for artistic style then this code should work for you too.
- torch
- torch.cudnn (optional)
- torch-hdf5
- python + numpy + scipy + h5py + sklearn
Tested with python2.7 and latest conda
packages.
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.
First row: original, second -- result.
-
Supported backends:
- nn (CPU/GPU mode)
- cudnn
- clnn (not tested yet..)
-
When using
-backend cudnn
do not forget to switch-cudnn_autotune
.
The code is heavily based on Justin Johnsons great code for artistic style.