Pinterest Stumbleupon Whatsapp
Ads by Google

Neural networks can do a lot of things. They can interpret images, understand our voices 6 Google Now Features That Will Change How You Search 6 Google Now Features That Will Change How You Search You may already be using Google Now on your Android device, but are you getting all that you can out of it? Knowing about these small features can make a big difference. Read More , and translate conversations How Skype's Star Trek Translator Works How Skype's Star Trek Translator Works Skype's new translate feature offers something dreamed of since Star Trek -- an effortless way to communicate across languages. Read More . But did you know they can also paint?

A recent research paper (entitled “A Neural Algorithm of Artistic Style“) has kicked off a flurry of online discussion with some striking visual examples. Essentially, the paper discusses a technique to train a deep neural network Microsoft vs Google - Who Leads the Artificial Intelligence Race? Microsoft vs Google - Who Leads the Artificial Intelligence Race? Artificial intelligence researchers are making tangible progress, and people are starting to talk seriously about AI again. The two titans leading the artificial intelligence race are Google and Microsoft. Read More to separate artistic style from image structure, and combine the style of one image with the structure of another. The upshot of all of this is that you can train a huge neural network to turn photographs into “neural paintings” that look as though they were painted by famous artists — “digital counterfeits,” so to speak.

Here are some examples from the article. The first image is the original. The later images are the generated results, with the  painting from which the style was sampled shown in miniature.

PaperImages

The original researchers have not released their code, unfortunately. However, some intrepid programmers have replicated their results over the last few days, and their code is available, open source on the Internet. All you need to run it is a linux machine and a little bit of patience.

Today, I’m going to walk you through how to do that, and show you some of my own results. You can think of this as a loose sequel to our DeepDream tutorial Create Your Own Artificial Fever Dreams with Google's "DeepDream" Create Your Own Artificial Fever Dreams with Google's "DeepDream" Have you seen the trippy images coming out of DeepDream? Want to make your own? Look no further! Read More . It’s a bit complicated, but anyone with a Linux machine can follow along — no coding experience needed.

Ads by Google

Setting Up the Software

First off, if you aren’t in a big hurry or don’t have a Linux machine, you can still play with DeepStyle using the DeepForger Twitter bot (send it an image and a style, and it will eventually reply with the results you want). If you want to process more images quickly (and with more control over the results), read on for the tutorial.

First off, make sure you have an up to date copy of Ubuntu (14.04 is what I used). You’re should have at least a few extra gigs of hard drive space. For more information, check out our tutorial on dual-booting Ubuntu alongside Windows Tired Of Windows 8? How To Dual Boot Windows & Ubuntu Tired Of Windows 8? How To Dual Boot Windows & Ubuntu If you discover that Windows 8 isn't quite your cup of tea, and you have no feasible path to downgrade, it may be a good idea to dual boot with Linux to have an alternative... Read More . You’re also going to need root privileges, so make sure you do before proceeding.

Basic Tools

Right of the bat, this is an open-source project, so we’re going to want to have Git installed. Git is the gold standard for version control software What Is Git & Why You Should Use Version Control If You’re a Developer What Is Git & Why You Should Use Version Control If You’re a Developer As web developers, a lot of the time we tend to work on local development sites then just upload everything when we’re done. This is fine when it’s just you and the changes are small,... Read More . Pretty much every open source project worth knowing about is hosted on Github.

To download and install Git, just open a terminal and type “sudo apt-get install git” and agree to the installer’s demands.

Next: we’re going to set up some basics tools needed to make the software work.

First, install Lua. This is the language that the tool is written in. It is pretty simple. Just type “sudo apt-get install lua5.2” and follow the installation process.

Second, we’re going to get Luarocks. This is the tool that makes it easier to install other tools (don’t you love Linux?). For this one, type “sudo apt-get install luarocks” and follow the installations steps.

Third, we’re going to install Luajit. This is a just-in-time compiler for Lua that will make our lives a little bit simpler. Just type “sudo apt-get install luajit.”

So far so good.

Frameworks

Next up, we’re going to install Torch, a scientific computing and machine learning framework that makes up the backbone of the application. Unfortunately, this one can’t be installed using apt-get (the standard Ubuntu package manager).

Luckily, they do have a one-line installer that uses some command-line magic. Return to your terminal and enter “curl -s https://raw.githubusercontent.com/torch/ezinstall/master/install-all | bash“.

When you’re done, type “luajit -ltorch“. This will bring up the torch interface and verify that everything was installed correctly.

Exit out of that.

Now we’re going to install loadcaffe — a neural-network specific package. Install its only dependency by typing “sudo apt-get install libprotobuf-dev protobuf-compiler“. Then you can install the package itself using “sudo luarocks install loadcaffe".

Double Checking Dependencies

Finally, we’re going to pre-emptively update some stuff just to make sure everything goes smoothly.

Type “sudo luarocks install image” to make sure that your image package is up to date. Next, enter “luarocks install nn” which will do the same for your ‘nn’ package.

Installing Deep Style

Alright! At this point, we’re ready to actually install the software itself. For cleanliness sake, 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 up, we’ve got to download the model. Make a cup of coffee or something, this will take a while. Back to the terminal, and type “sudo sh models/download_models.sh“. That’ll start a long, elaborate download process. If it fails because of permission errors, try giving yourself read-write permissions on the relevant folders, using chmod.

Using Deep Style

Okay, we’re good to go. Using the software is pretty simple.

Make sure you’re in the DeepStyle/neural-style directory in the terminal. Now, you’re going to need some images to work on. Download them off the Internet (or whatever), then copy them into the DeepStyle/neural-style folder using the file browser.

Now you can use the command line to process individual images. The format is pretty straightforward:

th neural_style.lua -style_image YOURPAINTINGHERE.jpg - content_image YOURPHOTOHERE.jpg -gpu -1

(Obviously, you’ll need to replace the chunks in ALL CAPS with the names of your files).

That will get the neural network started. It’ll run for about an hour, spitting out new partially-converged images every few minutes until it finishes. The -gpu -1 flag stops it from trying to access your GPU.

After several hours of trying (and bricking the operating system several times) I was unable to get Ubuntu and CUDA to play nice with my GPU (an NVIDIA GTX 970). If you have more luck with that, you’ll want to install CUDA and cudann.torch (see the github repo for more information). If not, that’s fine — it’ll still work using your your CPU; it’ll just be a little slower.

If you have any issues getting all of this working, just ask me in the comments, and I’ll do my best to help you out.

Results

Here are some images I’ve generated over the last couple of days. The results are mixed, but many of them are pretty impressive.

zack-paden-composite

Click here for full resolution.

This one is of my friend Zack on a hiking trip to Yellowstone. The style comes from an abstract painting, created by Theresa Paden. I was curious to see how the system would do using an image with absolutely no structure. The results are pretty neat, and you can definitely see the similarities to the style image.

jerseycity-demuth-composite

Click here for full resolution.

This one comes courtesy of one of my favorite artists, Charles Demuth (see: Incense of a New Church, and Figure 5 in Gold). Interestingly, Demuth is one of primary visual inspirations for the art of Team Fortress 2 Team Fortress 2: The Free-to-Play Steam Game You Must Play Team Fortress 2: The Free-to-Play Steam Game You Must Play Is Team Fortress 2 just a quick game to test graphics and performance, or is it a game worth playing repeatedly? Read More , as you can see from the style image.

I fed it an image of Jersey City that I found on Wikimedia. The results are… pretty good. It didn’t pick up on the angularity of Demuth’s style, but it certainly picked up the soft, textured look and the color palette.

flowers-okeefe-composite

Click here for full resolution.

This one is an attempt to generate a synthetic O’Keeffe, using a fairly mundane picture of some flowers I found. The results are, frankly, spectacular. Aesthetically, this is one of my favorite results. The richness of O’Keeffe’s colors and shapes come through clearly. The layered edges of the flower petals become the edges of the leaves in the background. The flowers themselves dissolve into colors, becoming almost abstract.

It would be a good painting if a human did it. I’m very tempted to spend a couple of days rendering a higher resolution version of this one and have it framed.

shannon-picasso-composite

Click here for full resolution.

Here’s my friend Shannon in her Halloween costume, by way of a Picasso print. Interestingly, the device chose to paint the lower portion of her face white (similar to the color layout of the Picasso piece). I’m not sure if this was a coincidence or not, but the results are striking. It also seems to have correctly identified Shannon’s hair on the left hand side, and re-drawn it using the color and linework from the hair in the style image. Ditto for her hat.

This is one of the pieces where the limitations of the technique start to become clear. If Picasso were actually painting Shannon, he’d have thrown away the structure of her face and skewed the features to achieve the effect he wanted. This system doesn’t understand those sorts of high level concepts, and is able to imitate only superficial aspects of the style, like the dark, angular lines and color palette.

eiffel-vangogh-composite

Click here for full resolution.

Fairly straightforward: a picture of the Eiffel Tower, and Van Gogh’s other Starry Night. It does a good job rendering the cloud in a Van Gogh-ey style, despite the absence of clouds in the original image. It also does a good job of translating the scene from day to night.

I wasn’t sure why it decided to render the tip of the Fiffel tower as a pillar of fire. It looks cool, but it’s not really justifiable from the input data. Then I realized that the style image has thirteen long, vertical yellow strips in it, in the form of the reflections in the water. That’s a pretty massive cluster, given so little training data. The poor thing has probably learned that any high-contrast vertical edge must be one of those reflections. You can see more extraneous vertical stripes faintly in the clouds.

nebula-vangogh-composite

Click here for full resolution.

Same Van Gogh painting, but this time I gave it some actual stars to paint. In this case, the pillars portion of the Eagle nebula. I like the results — although, once again you can see its obsession with yellow stripes. Every vertical portion of the pillar becomes a bright, wobbly yellow line. It’s also clearly upset by the green, which did not occur in the training data, and does its best to get rid of it in favor of blue and black.

Technology

Some results from this are extremely compelling, although the technique has clear limitations. Some images have lousy composition, and the system has difficulty with more abstract artists like Picasso — who famously liked to distort his subject matter, scattering its features. The algorithm picks up his angular lines, and clashing colors, but is still a slave to the pixel values of the image. It doesn’t have the comprehension you’d need to deviate too far from the source material.

What excites me about all this is that I don’t think those limitations are fundamental.

The approach being used here — train a network on one image and use it to construct another — is fundamentally kind of a hack. It gives the network very little data to work with. A more advanced version of this application would use a network that has information on many paintings, and perhaps even real images, to give it plenty of context about the image it’s trying to “paint.”

A deep grasp of style can only exist in a broader context. You can’t derive it from a single image. Designing an architecture that gives the system access to broader data might allow it to derive a more “human-like” understanding of the image, and how artists represent different elements of the real world. Such a network might be able to produce images that are more abstract and have a better composition. Such algorithms would cease to be a cool toy (like this) and become a way to produce actual, original art.

Which is a very peculiar thought, in some ways.

Making Your Own Images

If you get a disappointing result, you can play around with the options a little to try to get more convincing results. The full list is on the Github. The important ones are

  • -content_weight -value How much to weight the content reconstruction term. Default is 5e0.
  • -style_weight -value: How much weight to give to the style image. Default is 1e2.
  • -style_scale – value: How large of image patches should the system analyze (Larger becomes more abstract). Default is 1.0.

Once you get everything working to your satisfaction, please post your most interesting images in the comments. I am really interested to see what you guys come up with.

Image Credits: human brain painter via Shutterstock

  1. MG
    November 10, 2016 at 12:40 am

    And is there a way to set this up under Windows, or only under Linux?

    Seeing as how most of the world uses Windows, it would be nice if there were an app / tutorial for that, and not just for the 3 Linux uber-nerds who know how to do all this ... and care to. ;)

  2. Sng
    November 5, 2016 at 2:13 am

    Hi, I am trying to use neural style but I have problems..

    - where should I put the images into? just into the DeepStyle/neural-style folder?
    - what should I type in order for me to get to /DeepStyle/neural-style directory?
    - its not working for me well... I am newbie to coding and having really hard time to get this work..

  3. Lembert
    July 16, 2016 at 3:26 pm

    Thank you for the tutorial. I got an error with "curl -s https://raw.githubusercontent.com/torch/ezinstall/master/install-all | bash"

    It says libqt4-core and libqt4-core not found. It is on an Ubuntu Server 16.04. With apt-cache i didnt found similar packages. How can I fix it to install it correct?

    • David
      July 21, 2016 at 10:31 am

      I get the same error on Ubuntu 16.04

      • David Gruber
        July 21, 2016 at 3:24 pm

        So I've tried to follow these instructions http://torch5.sourceforge.net/manual/InstallQTDebian.html without success as the link http://ml.nec-labs.com/download/qt/qt4-x11_4.4.0-4.dsc seems to be broken. I then went back and installed libqt4-dev (I have not installed libqt4-gui and neither libqt4-core, but I do have libqtcore4 and libqtgui4 on my system. They probably are related somehow, but don't aks me how. I am not really an expert). According to a google forum entry (I cannot find the URL any more) you don't need those two libraries in Ubuntu anyway. So I went ahead without them and torch seems to be installed just fine on my system. At least "luajit -ltorch" did not return an error.
        As we speak, I am trying to generate a first neural painting. I'll let you know if it worked or not (I am on a really slow machine...).

  4. Keegan
    June 23, 2016 at 7:22 am

    Hello,
    Thanks for the tutorial. I'm having trouble launching the command at the end to actually run the program. It informs me that "th" is not a recognized command; I'm using the following command (copied from the shell): th neural-style.lua -style.lua -style_image Van_Gogh_-_Starry_Night.jpg content_image xcom2-HD.jpg -gpu -1

    What did I do wrong?

  5. skylar f southard
    June 18, 2016 at 10:24 pm
  6. Simon
    May 26, 2016 at 10:13 am

    Thanks so much for this write up. This is a nice introduction to linux for me!

    I was wondering, how much faster is it to run with CUDA?

    Would you be able to make a step-by-step for this?

    Thanks!

  7. ryan
    May 7, 2016 at 10:02 pm

    i'm trying to get this going in an ubuntu 16.04 virtual machine (host win10), but it's not going great. this step:

    curl -s https://raw.githubusercontent.com/torch/ezinstall/master/install-all | bash

    would not complete successfuly. i went to torch.ch and tried an install using their instructions, then re-ran the above line, and it reported success. so i continued and finished your walkthrough. but when i try to run the code to blend to images:

    th neural_style.lua -style_image YOURPAINTINGHERE.jpg - content_image YOURPHOTOHERE.jpg -gpu -1

    (replacing the caps with my file names of course) i get the following error:

    Couldn't load models/VGG_ILSVRC_19_layers.caffemodel
    /usr/local/bin/luajit: neural_style.lua:73: attempt to index a nil value
    stack traceback:
    neural_style.lua:73: in function 'main'
    neural_style.lua:500: in main chunk
    [C]: in function 'dofile'
    /usr/local/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
    [C]: at 0x004057a0

    • David Capito
      July 5, 2016 at 11:10 pm

      I would check to make sure the models are in the correct folder (did they end up in the Deepstyle folder instead of the models folder?).

    • Rtototo
      July 13, 2016 at 10:07 am

      - curl wasn't included in my dsitribution (Mint 17)
      - the command failed due to restricted right to /usr/local/lib/

      Additionally to the very nice explanation in the original post do:

      sudo apt-get install curl

      and put a sudo infront of the curl term

      sudo curl -s https://raw.githubusercontent.com/torch/ezinstall/master/install-all | bash

  8. Ivan
    May 5, 2016 at 1:03 pm

    th neural_style.lua -gpu -1 -print_iter 1
    [libprotobuf WARNING google/protobuf/io/coded_stream.cc:505] Reading dangerously large protocol message. If the message turns out to be larger than 1073741824 bytes, parsing will be halted for security reasons. To increase the limit (or to disable these warnings), see CodedInputStream::SetTotalBytesLimit() in google/protobuf/io/coded_stream.h.
    [libprotobuf WARNING google/protobuf/io/coded_stream.cc:78] The total number of bytes read was 574671192
    Successfully loaded models/VGG_ILSVRC_19_layers.caffemodel
    /usr/local/bin/luajit: /usr/local/share/lua/5.1/loadcaffe/loadcaffe.lua:20: attempt to index a nil value
    stack traceback:
    /usr/local/share/lua/5.1/loadcaffe/loadcaffe.lua:20: in function 'load'
    neural_style.lua:73: in function 'main'
    neural_style.lua:500: in main chunk
    [C]: in function 'dofile'
    /usr/local/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
    [C]: at 0x00406260

    Hi, what is wrong? Ubuntu 14.04.1 LTS

    • michel
      May 26, 2016 at 6:30 am

      Same here in Ubuntu 15.10. I guess some update broke the installation.

      • seamuso
        May 27, 2016 at 12:52 am

        using sudo fixed it for me

        • michel
          May 28, 2016 at 3:30 pm

          sudo worked! Thanks a lot

        • Adam
          October 28, 2016 at 6:38 pm

          I used sudo, and I'm getting the same warning message.

        • Adam
          October 28, 2016 at 6:39 pm

          I used sudo and am still getting the same warning message?

        • John
          November 20, 2016 at 3:36 am

          Do you mind sharing your script? I still get an error when typing:
          sudo th neural_style.lua -style_image us.jpg -content_image sun.jpg -gpu -1

  9. AP
    April 7, 2016 at 7:58 am

    Is there any way of increasing the resolution of the output image? The same resolution as the input image ideally.

    • AP
      April 7, 2016 at 8:40 am

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

      You can increase size by:
      -image_size: Maximum side length (in pixels) of of the generated image. Default is 512

      However setting this to 2048 yields an out of memory error (Hyper V VM with 4GB RAM), so I used 1024

      I also used: -optimizer adam
      The optimization algorithm to use; either lbfgs or adam; default is lbfgs. L-BFGS tends to give better results, but uses more memory. Switching to ADAM will reduce memory usage; when using ADAM you will probably need to play with other parameters to get good results

      -image_size 1024 and -optimizer adam worked with 4GB memory.

  10. AP
    April 7, 2016 at 3:51 am

    I have never installed or used ubuntu before and the install worked flawlessly. Detailed and great instructions. Ubuntu 14.04.4 LTS under Hyper-V VM Gen2 (Windows 8.1 Pro).

  11. michael grosberg
    April 3, 2016 at 8:40 pm

    Thanks for the instructions!
    While installing torch I get this error:

    W: Failed to fetch http://dl.google.com/linux/chrome/deb/dists/stable/Release Unable to find expected entry 'main/binary-i386/Packages' in Release file (Wrong sources.list entry or malformed file)

    (not sure why it's looking for 1386, I have a 64bit Ubuntu 14.04)
    And torch ends up not being installed correctly.
    Anyone know what to do?

  12. combatplayer
    March 28, 2016 at 10:54 pm

    Hello, thanks to your help ive finally gotten it to work, however, once i put in the info needed to produce the image
    "th neural_style.lua -style_image A.jpg - content_image B.jpg -gpu -1"
    it gives me the following error:
    "invalid argument:"
    followed by a list of all the different input options..

    • combatplayer
      March 28, 2016 at 11:16 pm

      ah, i believe one of the dashes was of the wrong sort, writing it out anew seems to have fixed it.

  13. J. B
    March 22, 2016 at 9:43 pm

    Thanks a thousand times! I could never ever do this on my own! Also, thanks MH for your addendum, i was getting stuck downloading the models. Thanks to you, everything went fine.

    • J. B
      March 22, 2016 at 9:44 pm

      I mean BH, not MH -,-

  14. DrSiemer
    March 22, 2016 at 2:22 pm

    Hi, thanks for this guide! I followed your instructions and managed to get everything installed on a Xubuntu 14.04 Virtualbox. Anyone that gets "/usr/local/bin/luajit: C++ exception" should probably assign more RAM, that's what fixed this error for me.

    "Your user does not have write permissions in /usr/local/lib/luarocks/rocks" during framework installation was fixed by running "sudo su" before running curl.
    "Attempt to index a nil value" error was fixed by adding "sudo" to the "th neural_style.lua ..." line.

    With 10GB of RAM it takes a little over 2 hours to process a 359x600 image, but it's working! I'm going to setup Linux on my home desktop now :)

  15. vishnu lokhande
    March 20, 2016 at 6:27 am

    I keep getting this error when I run the line "curl -s https://raw.githubusercontent.com/torch/ezinstall/master/install-all | bash".

    "
    Enter code here...Error: Your user does not have write permissions in /usr/local/lib/luarocks/rocks
    -- you may want to run as a privileged user or use your local tree with --local.
    "

    Also, I'm not able to run a test lua file with the command "th test.lua"
    Please help

    • DrSiemer
      March 22, 2016 at 10:10 am

      Before running curl, type "sudo su"

  16. BH
    March 18, 2016 at 8:54 pm

    where can we find the command-line options, for instance, to make the final image as high resolution as the input image?

  17. neunzehneck
    March 18, 2016 at 8:55 am

    Thanks for this guide!
    Here my best picture (3 hours of computing time, 10Gb Ram, 768x512 resolution).
    https://drive.google.com/open?id=0BxK22w1GOYdHM002Wl9RMk9rY2c

  18. BH
    March 18, 2016 at 5:21 am

    Thanks so much! The install instructions on the torch website don't work; these ones do.

    There's a very minor step missing here: After
    $ sudo git clone https://github.com/jcjohnson/neural-style.git
    add
    $ cd neural-style

  19. BH
    March 18, 2016 at 4:23 am

    I run into trouble at

    $ sudo luarocks install loadcaffe

    Error: No results matching query were found.

    $ sudo luarocks install image

    Error: No results matching query were found.

    This might be because I installed torch7 using the instructions at http://torch.ch/docs/getting-started.html#_ instead of using torch/ezinstall/master/install-all . torch has at least 3 different install scripts hidden in its code, and no documentation on github on how to install it.

  20. gzyb
    March 3, 2016 at 5:23 pm

    everything works, or starts working after a quick google search, except for:
    "th: command not found"

    google provides no good remedy. what is wrong? i guess its some command for running torch, but torch works fine, just this command does not.

    • DrSiemer
      March 23, 2016 at 11:16 pm

      You are probably running 32bit, you need 64bit

  21. j0k0
    March 2, 2016 at 11:03 pm

    I am running Ubuntu 14.04 on a virtual machine. After inserting

    th neural_style.lua -style_image YOURPAINTINGHERE.jpg - content_image YOURPHOTOHERE.jpg -gpu -1

    I get the error "Segmentation fault (core dumped)" after a few steps.

    conv1_1: 64 3 3 3
    ...
    conv5_4: 512 512 3 3
    fc6: 1 1 25088 4096

    Adter that it breaks with "Segmentation fault (core dumped)". Any ideas how to solve this? Sorry, I am new to Ubuntu...

    • Mick
      March 4, 2016 at 10:53 am

      It's a very memory intensive process which should really be run on your GPU. Try using smaller pictures, more memory in your VM or running natively.

    • DrSiemer
      March 22, 2016 at 10:42 am

      See https://github.com/jcjohnson/neural-style/issues/39
      It could be you are running a 32bit OS, you need 64bit.
      Type in the following in the terminal;

      uname -m

      It will give you either x86_64, which is 64-bit, or something else, which is 32-bit.

    • AP
      April 7, 2016 at 8:01 am

      I am not an ubuntu expert but I noticed this when I tried:

      th neural_style.lua -style_image YOURPAINTINGHERE.jpg – content_image YOURPHOTOHERE.jpg -gpu -1

      should be

      th neural_style.lua -style_image YOURPAINTINGHERE.jpg -content_image YOURPHOTOHERE.jpg -gpu -1

      The change is here:
      -content_image (no space between - and content_image)

  22. DrKhaled
    February 28, 2016 at 11:42 am

    I always get an error when trying to install torch saying "./install.sh: line 58: cmake not found"
    What can I do in order to fix this? Please help!

    • DrKhaled
      February 28, 2016 at 11:43 am

      typo. the actual error message is: "./install.sh: line 58: cmake: command not found"

    • piotrek
      March 3, 2016 at 4:59 pm

      well, you should obviously install cmake
      "sudo apt-get install cmake" solves the case
      its also good to run "sudo apt-get install build-essential" if you have a fresh system

  23. deepkid
    February 4, 2016 at 5:22 am

    Awesome Tut! This got me going on my virtualbox! Many thanks!

  24. yiseob
    January 6, 2016 at 8:49 am

    I have a 2015 macbook with Ati gpu.
    Can I try it except nvidia gpu??

    • Jan
      January 14, 2016 at 8:12 am

      Jep. But prepare yourself to struggle with getting torch to work :b That was the hardest thing for me to get up and running..

      • yiseob
        January 18, 2016 at 4:03 pm

        thanks for answer Jan :)

  25. Von
    January 5, 2016 at 9:41 pm

    Installed all the required packages on Mac but I get the following error when running the script:

    [libprotobuf WARNING google/protobuf/io/coded_stream.cc:537] Reading dangerously large protocol message. If the message turns out to be larger than 1073741824 bytes, parsing will be halted for security reasons. To increase the limit (or to disable these warnings), see CodedInputStream::SetTotalBytesLimit() in google/protobuf/io/coded_stream.h.
    [libprotobuf WARNING google/protobuf/io/coded_stream.cc:78] The total number of bytes read was 574671192
    Successfully loaded models/VGG_ILSVRC_19_layers.caffemodel
    /usr/local/bin/luajit: /usr/local/share/lua/5.1/loadcaffe/loadcaffe.lua:20: attempt to index a nil value
    stack traceback:
    /usr/local/share/lua/5.1/loadcaffe/loadcaffe.lua:20: in function 'load'
    neural_style.lua:73: in function 'main'
    neural_style.lua:499: in main chunk
    [C]: in function 'dofile'
    /usr/local/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
    [C]: at 0x010dfbfc40

    • DrSiemer
      March 22, 2016 at 11:46 am

      Run "th neural_style.lua" with sudo in front of it ;)

      • John
        November 20, 2016 at 3:24 am

        When I type in:
        sudo th neural_style.lua -style_image us.jpg -content_image sun.jpg -gpu -1

        I get the error:

        sudo: th: command not found

        • DrSiemer
          November 20, 2016 at 11:53 am

          Are you on 64 bit?
          You can try to refresh the bashrc file:
          "source ~/.bashrc"

      • John
        November 20, 2016 at 3:26 am

        When I type:
        sudo th neural_style.lua -style_image us.jpg -content_image su

        I get an error message:
        sudo: th: command not found

  26. VeloxBY
    December 4, 2015 at 10:43 pm

    Hello and thanks for such deep guide!

    I have problem - Ubuntu start getting stuck in random moment (i can't find any relationships between my manipulation and crash of the system).

    I use clean Ubuntu 14.04 LTS,
    my config is 3.3GHz Intel Core i3-3220, 8GB RAM, old GeForce GT240 (1024MB), old Samsung 160GB HDD and AsRock B75 Pro-3-M motherboard.

    My system start freezing after installing the Torch framework (Maybe after installing of Loadcaffe). It freezes in absolutely random moment.

    I'm low experienced Linux user, so I just have no idea, how to detect the source of th problem.

    Sorry for my english.

    • VeloxBY
      December 5, 2015 at 2:17 am

      So far - problem is not in the software or HDD.
      With different HDD's it has same bug.

      But when I start using my laptop (Asus K56CM, 8GB RAM, Intel Core i5 1.7GHz, TOSHIBA 500GB HDD, GeForce 635M (And Intel HD4000).) - problem was solved.

      Now I'm waiting for my first paintings.

  27. Lachlan
    November 23, 2015 at 8:42 pm

    Hello friend, thanks for putting this together!

    I'm getting two errors, which may be related:

    First I get libprotobuf WARNING google/protobuf/io/coded_stream.cc:505 Reading dangerously large protocol message.

    Then it successfully goes through the conv's and all the way to "applying style" and then suddenly prints "Killed". No images are ever created.

    Do you have any idea why this might be happening?

    Thanks in advance,
    Lachlan

    • Lachlan
      November 25, 2015 at 8:00 am

      this was resolved by increasing the memory on the machine

  28. Claudio Bognolo
    October 6, 2015 at 12:22 pm

    UBUNTU 32bit: run neural_style.lua on a Pentium dual core 2.7 Ghzx2 4 GiB no GPU (-gpu -1) optimizer adam, vgg_normalised caffe model, image_size 128.
    Program stops after "WARNING: Skipping content loss" with a "Segmentation Error (core dump created)". No iteration takes place.
    System monitor during process gives both CPU's at 100%, storage 65% swap 0%.
    Always the same disappointing result for any setting of image_size and/or size of content and style images.
    Can you pls help me?
    Claudio

    • Claudio Bognolo
      October 16, 2015 at 1:35 pm

      Problem solved installing UBUNTU 14.04 64bit on a i7-4790 quad core 8GiB.
      Amazing images!
      Claudio

  29. Giacomo Arcuri
    September 18, 2015 at 3:58 pm

    I have problems during "sudo luarocks install loadcaffe" it says it doesn't recognize the option line "-std=c++11". Anyone having this problem?

    • Aaron
      November 25, 2015 at 4:55 pm

      you're using an old version of ubuntu, most likely. Doesn't look like versions of GCC that are on versions prior to 14.04 will support the C++11 options.

      Upgrade to Ubuntu 14.04 and make sure all your software is up to date.

  30. Jimmy Anderson
    September 17, 2015 at 10:47 am

    I too have got the permissions issue. I know the article says to chmod it. But what permissions does it need?

    • tsaint
      September 17, 2015 at 12:04 pm

      I used 777 which gives read, write,execute permission to everyone (security issue if left at that) but I THINK the problem was being in the DeepStyle directory at this step rather than the neural_style directory. (when I changed to there, it worked fine)

      having said that, after finishing all the steps, I can't get it to run without error. I made the mistake of creating a neural-style, rather than neural_style directory. On first run, it had a problem, then I renamed a file ( I think it was neural_style.lua to neural-style.lua) - it at least ran, but aborted with an error. Maybe I need to repeat every step after creating that bloody directory.

  31. tsaint
    September 17, 2015 at 7:35 am

    Since I don't know what I'm doing, I've made a guess that I should have changed to the neural-style directory BEFORE trying :
    sudo sh models/download_models.sh

    It's certainly downloading ok now, whether to the correct place or not I'll find out!

  32. tsaint
    September 17, 2015 at 6:49 am

    Thanks for the effort you put in to this article.

    Installed Ubuntu, learning as I went, got through a fair number of the s/w install steps until I got to:
    "sudo apt-get install libprotobuf-dev protobuf-compiler",
    when I got:
    "Failed to fetch http://au.archive.ubuntu.com/ubuntu/pool/main/p/protobuf/libprotoc8_2.5.0-9ubuntu1_amd64.deb 404 Not Found" with many subsequent errors.
    After that I couldn't go any further. Any ideas please?
    Tony

    • tsaint
      September 17, 2015 at 7:21 am

      Fixed the last problem - used the software centre to get the 2 "bits".
      Now, with the models download step, I get:
      sh: 0: Can't open models/download_models.sh
      (Don't think it's the problem, but I did chmod 777 the deepstyle directory

      • deepkid
        February 4, 2016 at 5:21 am

        I had same problem, but I chmod 777 the download_models.sh file itself and that fixed the problem.

        • chrisB
          February 29, 2016 at 7:40 pm

          Hi Deepkid

          Please paste the exact command that you used to chmod 777 the download_models.sh file . Thank you

        • Deepkid
          March 8, 2016 at 12:14 pm

          Hi chrisB

          I managed to get the right permissions going. Thank you

          I now have another problem - when I try the command to actually create a new image I get this:

          ubuntu@ip-172-31-40-32:~/DeepStyle/neural-style$ th neural_style.lua -style_image art1.jpg -content_image boys.jpg -gpu -1
          [libprotobuf WARNING google/protobuf/io/coded_stream.cc:505] Reading dangerously large protocol message. If the message turns out to be larger than 1073741824 bytes, parsing will be halted for security reasons. To increase the limit (or to disable these warnings), see CodedInputStream::SetTotalBytesLimit() in google/protobuf/io/coded_stream.h.
          [libprotobuf WARNING google/protobuf/io/coded_stream.cc:78] The total number of bytes read was 574671192
          Successfully loaded models/VGG_ILSVRC_19_layers.caffemodel
          /usr/local/bin/luajit: C++ exception
          ubuntu@ip-172-31-40-32:~/DeepStyle/neural-style$

Leave a Reply

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