Installing Neural Style on Ubuntu

Install Git

If you have not already done so, you will need to install Git.

$ sudo apt-get install git

Install Torch

Easy to follow guide:  http://torch.ch/docs/getting-started.html#_

Do this first!  Do not install Luarocks or Luajit.  The Torch installation comes with Luarocks and Luajit.  If you install them separately, it will mess up the path, and some of the other programs will not work.

$ git clone https://github.com/torch/distro.git ~/torch --recursive
$ cd ~/torch; bash install-deps;
$ ./install.sh

Update PATH.

source ~/.bashrc

Install Loadcaffe

github:  https://github.com/szagoruyko/loadcaffe

$ sudo apt-get install libprotobuf-dev protobuf-compiler
$ luarocks install loadcaffe

Do not use sudo for the Luarocks commands.  After installing loadcaffe, install image and nn.  This adds functionality for different image types and neural networks.

$ luarocks install image
$ luarocks install nn

Install Neural Style

github:  https://github.com/jcjohnson/neural-style

installation guide:  https://github.com/jcjohnson/neural-style/blob/master/INSTALL.md

$ git clone https://github.com/jcjohnson/neural-style.git

Do not use sudo.

$ cd neural-style
$ sh models/download_models.sh

To run the program, use the command:

th neural_style.lua -style_image <style image file> -content_image <picture file> -gpu -1

This runs the program using CPU.

(optional)  Install CUDA and CuDNN

If you have an NVIDIA card, using GPU acceleration will make Neural Style run a lot faster.

How to install CUDA and CuDNN:  http://endlesswatts.com/installing-cuda-tookit-cudnn-ubuntu/

Once you’ve done that, you can enable the features in Torch.

$ luarocks install cutorch
$ luarocks install cunn

$ luarocks install cudnn

The command for GPU acceleration is:

th neural_style.lua -style_image <style image file> -content_image <picture file> -gpu 0 -backend cudnn

 

 

links:

https://github.com/jcjohnson/neural-style/blob/master/INSTALL.md

http://torch.ch/docs/getting-started.html#_

https://github.com/szagoruyko/loadcaffe

https://blog.gruffdavies.com/tag/neural-style/

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

CommentLuv badge