Deepstyle
Neural Art

Deepstyle Neural Art: 2024/2025 Edition

Want to buy my Deepstyle prints? Check out Redbubble.

What is “Deepstyle Neural Art”?

This is based on the seminal research paper "A Neural Algorithm of Artistic Style" by Leon A. Gatys, Alexander S. Ecker, and Matthias Bethge. You can read their findings here.

In short, Neural Style Transfer (NST) allows you to extract the "texture" and "brushwork" from famous paintings (like Van Gogh or Munch) and apply them to your own photographs. As a photographer, I find this tool invaluable for reimagining my portfolio through a digital-painterly lens.


Prerequisites & Modern Tools

To get this working today, you need a computer with Ubuntu 22.04 LTS or 24.04 LTS.

The Modern Workflow:

  • Hardware: An NVIDIA GPU (RTX 3060 or better) is highly recommended. If you don't have one, you can rent a GPU-enabled instance on Lambda Labs or RunPod for pennies an hour.

  • Remote Access: Instead of PuTTY/WinSCP, I now recommend using VS Code with the Remote - SSH extension. It allows you to drag-and-drop files directly into your Ubuntu box and edit code in a modern interface.

Ubuntu 24.04/22.04 LTS

Prerequisites & Modern Tools

To get this working today, you need a computer with Ubuntu 22.04 LTS or 24.04 LTS.

The Modern Workflow:

  • Hardware: An NVIDIA GPU (RTX 3060 or better) is highly recommended. If you don't have one, you can rent a GPU-enabled instance on Lambda Labs or RunPod for pennies an hour.

  • Remote Access: Instead of PuTTY/WinSCP, I now recommend using VS Code with the Remote - SSH extension. It allows you to drag-and-drop files directly into your Ubuntu box and edit code in a modern interface.

Phase 1: Preparing Ubuntu

Do not run these commands as root. Create a dedicated user first:

# Only if you are currently logged in as root

sudo adduser neural
sudo usermod -aG sudo neural
su - neural
1. Update and Dependencies

Ensure your system is current and install the Python environment tools:

sudo apt update && sudo apt upgrade -y
sudo apt install git python3-pip python3-venv libopencv-dev -y
2. Create a Virtual Environment

This prevents "dependency hell" by keeping the art software separate from your system files:

cd ~
python3 -m venv deepstyle_env
source deepstyle_env/bin/activate

Phase 2: Installing PyTorch & Neural Style

We will use a high-performance PyTorch implementation of the Gatys algorithm.

1. Install PyTorch

This command installs the engine that handles the neural network math:

pip install torch torchvision torchaudio
2. Clone the Repository

We will use a robust, modern implementation of the original algorithm:

git clone https://github.com/pytorch/examples.git
cd examples/fast_neural_style
pip install -r requirements.txt

Phase 3: Generating Art

Modern Style Transfer comes in two flavors: Slow/Optimization-based (highest quality, any style) and Fast (instant, but requires pre-trained models).
Using the "Fast" Method (Instant Results)

The repository comes with pre-trained models (e.g., Rain Princess, Candy, Udnie).

# Run the stylization
python3 neural_style/neural_style.py stylize --content-image images/content-images/amber.jpg --output-image images/output-images/my_art.jpg --model saved_models/starry_night.model --cuda 1

(Note: Change --cuda 1 to --cuda 0 if using a CPU, though it will be significantly slower.)

Using the "Slow" Method (The Classic Gatys Look)

If you want to use any painting as a style reference (not just pre-trained ones), I recommend using the Neural-Style-PT repository:

cd ~
git clone https://github.com/ProGamerGov/neural-style-pt.git
cd neural-style-pt
python3 models/download_models.py

# Run style transfer
python3 neural_style.py -style_image van_gogh.jpg -content_image my_photo.jpg -gpu 0 -image_size 1024

The Art of Patience (and Resolution)

In the 2016 version of this guide, we struggled to hit 512px. Today, with an NVIDIA RTX card, you can easily generate 1024px or 2048px images.

  • VRAM Warning: A 1024px image usually requires about 8GB of Video RAM (VRAM).

  • Upscaling: To get prints ready for Redbubble, I recommend running your output through an AI Upscaler like Real-ESRGAN. This allows you to turn a 1024px neural output into a crisp 4096px file suitable for large canvas prints.

Resources

Want to buy my Deepstyle prints? Check out Redbubble.

Don’t know what “Deepstyle Neural Art” is?

This is based on the research paper by Leon A. Gatys, Alexander S. Ecker and Matthias Bethge, you can read about their findings here.

In short, you can apply styles from famous painters like Vincent van Gogh, Rembrandt, Edvard Munch or whomever you choose to your photos for a interesting effect.

As a photographer i find this interesting, since i have a large supply of my own material to apply this to.

To get this to work you need a computer with Ubuntu 14.04 LTS or Ubuntu 16.04 LTS installed, or you could rent a box in the cloud from Digitalocean.

Other useful software that you might want to have handy on your computer to transfer the output files from the Ubuntu box would be PuTTY (for issueing commands in SSH) and WinSCP (for file transfer).

I hope you find this tutorial useful!

Assuming you have Ubuntu installed, lets get to it!

OLD VERSION (just here for archive purposes)
UBUNTU 16.04 LTS:

Do not do this as root, first create a user.

Example (if you are logged in as root) :

sudo adduser neural
sudo usermod -aG sudo neural
su neural
cd ~

Dependencies needed
(copy/paste commands below to your terminal):
  1. Make sure everything is up to date
    sudo apt-get update && sudo apt-get upgrade
  2. Install GIT
    sudo apt-get install git
  3. Install OpenBLAS
    sudo apt-get install libopenblas-dev
  4. Install Torch
    git clone https://github.com/torch/distro.git ~/torch --recursive
    cd ~/torch; bash install-deps;
    ./install.sh

    Answer YES when install is finished and do a :

    source ~/.bashrc
  5. Update LuaRocks needed for this
    luarocks install torch
    luarocks install nn
    luarocks install image
    luarocks install lua-cjson
Installing Fast Neural Style:

We will be using Fast Neural Style from Justin Johnson on Github.

  1. Make sure you are in home directory
    cd ~
  2. Clone Neural Style repo
    git clone https://github.com/jcjohnson/fast-neural-style.git
  3. Go into directory
    cd fast-neural-style
  4. Download models (around 655MB download)
    bash models/download_style_transfer_models.sh
    bash models/download_vgg16.sh
    Keep in mind that you might have to edit the scripts files on change http to https for the downloads to work.
  5. To do this:
    sudo nano models/download_style_transfer_models.sh
    sudo nano models/download_vgg16.sh

    After this you should be all setup for churning out neural art.

    To get started:

    1. Make sure you are in correct directory
      cd ~/fast-neural-style
    2. Command for running Neural Style (without GPU)
      th slow_neural_style.lua -content_image images/content/YOURCONTENTFILE.jpg -style_image images/styles/YOURSTYLEFILE.jpg -output_image YOURFILENAME.png -num_iterations 1000 -print_every 1
      This will output a image 512px wide, which is the default setting, and print every iteration on screen with a total of 1000 iterations (this can be changed your liking)
      Check Fast Neural Style on Github for more information on parameters.

      You can change this by doing:
      th slow_neural_style.lua -style_image NAMEOFPAINTING.jpg
      -content_image YOURPHOTO.jpg -gpu -1 -image_size SIZEINPIXELS
      -output_image NAMEOFOUTPUT.png -num_iterations NUMBEROFITERATIONS -print_every ITERATIONSTOPRINTONSCREEN

      Be advised that the pixel size will affect how much RAM is used, for a 512px image you should have a minimum of 4GB RAM.
      Using a box in the cloud can help you with this, like a compute optimized server with 64GB RAM and 32 dedicated hyperthreads from Digitalocean.

      I have been making neural art with pixel sizes up towards 2560px on Digitalocean with their largest servers for compute/ml setups.

UBUNTU 14.04 LTS:

Dependencies needed
(copy/paste commands below to your terminal):
  1. Make sure everything is up to date
    sudo apt-get update && sudo apt-get upgrade
  2. Install GIT
    sudo apt-get install git
  3. Install LUA
    sudo apt-get install lua5.2
  4. Install LuaRocks
    sudo apt-get install luarocks
  5. Install LuaJIT
    sudo apt-get install luajit.
  6. Install Torch
    sudo curl -s https://raw.githubusercontent.com/torch/ezinstall/master/install-all | bash
  7. Install LoadCaffe
    sudo apt-get install libprotobuf-dev protobuf-compiler
    sudo luarocks install loadcaffe
  8. Update LuaRocks needed for this
    sudo luarocks install paths
    sudo luarocks install sys
    sudo luarocks install image
    sudo luarocks install nn
    sudo luarocks install optim
Installing Neural Style:

We will be using Neural Style from Justin Johnson on Github.

  1. Make sure you are in home directory
    cd or cd ~
  2. Make directory
    mkdir DeepStyle
  3. Go into directory
    cd Deepstyle
  4. Clone Neural Style repo
    sudo git clone https://github.com/jcjohnson/neural-style.git
  5. Go into directory
    cd neural-style
  6. Download models (around 655MB download)
    sudo sh models/download_models.sh

After this you should be all setup for churning out neural art.

To get started:

  1. Make sure you are in correct directory
    cd ~/DeepStyle/neural-style
  2. Command for running Neural Style (without GPU)
    sudo th neural_style.lua -style_image NAMEOFPAINTING.jpg -content_image YOURPHOTO.jpg -gpu -1 -output_image NAMEOFOUTPUT.png
    This will output a image 512px wide, which is the default setting.
    Check Neural Style on Github for more information on parameters.

    You can change this by doing:
    sudo th neural_style.lua -style_image NAMEOFPAINTING.jpg
    -content_image YOURPHOTO.jpg -gpu -1 -image_size SIZEINPIXELS
    -output_image NAMEOFOUTPUT.png

    Be advised that the pixel size will affect how much RAM is used, for a 512px image you should have a minimum of 4GB RAM.
    Using a box in the cloud can help you with this, like Digitalocean.

Some of my results:

Hallgrimskirkja in Reykjavik, Iceland with the style of Charles Demuth (Style: right)Kvernufoss in Iceland with style of H.R Giger (Style: right)
Bryggen in Bergen, Norway with the style of Charles Demuth (Style: right)Styled from “Heart of the Andes” by Fredric Edwin Church (Style: middle)Skogafoss in Iceland – “The Scream” Edvard Munch Style (Style: right)
THE ART OF PATIENCE:

Generating these images can take time, depending on your hardware, with the use of GPU it will be a lot faster, or by using a cloud service like Digitalocean (non GPU, but quite affordable) or Amazon EC2 (for GPU cloud)

If you’re going with the Amazon EC2 (g2.2xlarge or g2.8xlarge) alternative there is a good tutorial on Reddit for this.

If you decide to use the GPU on your Ubuntu box here’s how to do it:
(requires a CUDA capable card from Nvidia)

  1. Go to home directory
    cd or cd ~
  2. Download repo from Nvidia
    sudo wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_7.5-18_amd64.deb
  3. Install repo
    sudo dpkg -i cuda-repo-ubuntu1404_7.5-18_amd64.deb
  4. Update packagelist
    sudo apt-get update
  5. Install CUDA
    sudo apt-get install cuda
  6. Reboot to load driver
    sudo reboot
  7. Check if card is being recognized
    nvidia-smi
  8. Install CUDA backend for torch
    sudo luarocks install cutorch
    sudo luarocks install cunn
  9. Check if backend is working
    cd ~/DeepStyle/neural-style
    sudo th -e "require 'cutorch'; require 'cunn'; print(cutorch)"
    This should produce a output.
  10. Test with neural style
    sudo th neural_style.lua -gpu 0 -print_iter 2

USES:

There are many possibilites with Neural style, here are some examples: