Create Your Own “Neural Paintings” using Deep Learning
Neural networks can work on so many things. They can interpret images, understand our voices, and translate conversations. But did you know they can also paint?
Here are some generated results using neural paintings:
Today, I’m going to walk you through how to do that, and show you some of my own results.
Setting Up the Software
First off, make sure you have an up to date copy of Ubuntu (14.04 is what I used). You should have at least a few extra gigs of hard drive space and a RAM at least bigger than 6gb. To run Ubuntu as a virtual machine you can use vagrant and virtualbox.
First make sure you have git installed. To download and install Git, just open a terminal and type “sudo apt-get install git” and follow the instructions.
Step 1: Install torch7
In terminal run these commands (you might need to use sudo with them):
$ cd ~/
$ curl -s https://raw.githubusercontent.com/torch/ezinstall/master/install-deps | bash
$ git clone https://github.com/torch/distro.git ~/torch --recursive
$ cd ~/torch; ./install.sh
Now we need to source and refresh our environment variables, run:
$ source ~/.bashrc
Step 2: Install loadcaffe
$ sudo apt-get install libprotobuf-dev protobuf-compiler$ luarocks install loadcaffe
Alternatively, if you face a problem, you can do this:
$ git clone git@github.com:szagoruyko/loadcaffe.git$ ~/torch/install/bin/luarocks install loadcaffe/loadcaffe-1.0–0.rockspec
Step 3: Install neural-style
First clone neural-style from GitHub:
$ cd ~/
$ git clone https://github.com/jcjohnson/neural-style.git
cd neural-style
Next download the neural network models:
$ sh models/download_models.sh
Step 4: Running it
Now make sure that you have allocated more than 6gb RAM at least to your virtual machine. Then check if neural style is working with this command:
th neural_style.lua -gpu -1 -print_iter 1
Note that you are running this in CPU mode, running it in GPU mode is out of scope of this article.
For instructions about how to use neural styles use:
$ th neural_style.lua ?
Now lets work on some test commands to check if our neural styles are working. First make sure you are in the directory of neural networks, if you followed all the instructions above it should be in ~/neural-network, then run:
th neural_style.lua -style_image examples/inputs/jo.jpg -content_image examples/inputs/julien.jpg -gpu -1 -image_size 256
Note I have dialed down the image size for it to complete in less time. When this command finished the default output file name will be out.png.