A recent research paper (entitled «Artistic Style Neural Algorithm») has sparked a wave of online discussions with several striking illustrative examples. In essence, the article discusses a technique for training a deep neural network to separate the art style from the structure of an image and combine the style of one image with the structure of another. The result of all this is that you can train a huge neural network to turn photographs into «neural paintings» that look like they were painted by famous artists — so-called «digital fakes».
Here are some examples from the article. The first image is the original. The later images are generated results and the drawing from which the sample was taken is shown in thumbnail.
The original researchers did not release their code, unfortunately. However, some intrepid programmers have been copying their results from the last few days and their code is available open source on the Internet. All you need to get started is a Linux machine and a little patience.
First, if you’re not in a hurry or don’t have a Linux computer, you can still play around with DeepStyle with DeepForger bot on Twitter (send him the image and style and he will eventually respond with the results you want). If you want to process more images quickly (and with more control over the results), read on for a tutorial.
To download and install Git, just open a terminal and type »
sudo apt-get install git » and agree to the requirements of the installer.
Next: we’re going install some basic tools, necessary for the operation of the software.
Install Lua first. This is the language in which the tool is written. It’s pretty simple. Just type »
sudo apt-get install lua5.2 ” and follow the installation process.
Second, we’re going to get Luarox. It’s a tool that makes it easy to install other tools (don’t you love Linux?). To do this, enter »
sudo apt-get install luarocks » and follow
sudo apt-get install luarocks by installation.
Third, we are going to install Luajit. This is a timely compiler for Lua that will make our lives a little easier. Just type »
sudo apt-get install luajit «.
So far, so good.
Next, we’re going to install Torch, a scientific computing and machine learning framework that forms the backbone of the application. Unfortunately, it cannot be installed using apt-get (the standard Ubuntu package manager).
Luckily, they have a one-line installer that uses command line magic. Go back to your terminal and type »
curl -s https://raw.githubusercontent.com/torch/ezinstall/master/install-all | bash
curl -s https://raw.githubusercontent.com/torch/ezinstall/master/install-all | bash «.
When you’re done, type »
luajit -ltorch «. This will bring up the cutter interface and check that everything is installed correctly.
Way out of this.
Now we are going to install loadcaffe — package for the neural network. Install its only dependency by typing »
sudo apt-get install libprotobuf-dev protobuf-compiler «. You can then install the package itself using »
sudo luarocks install loadcaffe" .
Double checking dependencies
Finally, we’re going to pre-update some things, just to make sure everything runs smoothly.
sudo luarocks install image to make sure your image pack is up to date. Then type »
luarocks install nn «, which will do the same for your «nn» package.
Setting the Deep Style
Good! At this point, we are ready to actually install the software itself. For the sake of cleanliness, create a new folder in your home directory (‘mkdir DeepStyle’). Then enter it using »
cd Deepstyle «. Now type »
sudo git clone https://github.com/jcjohnson/neural-style.git".
Next, we need to download the model. Make a cup of coffee or something, it will take some time. Go back to the terminal and type »
sudo sh models/download_models.sh «. This will start a long, complicated download process. If it fails due to permission errors, try giving yourself read and write permissions to the appropriate folders using chmod.