AI Paints Like Bob Ross: A PyTorch Tutorial

AI Paints Like Bob Ross: A PyTorch Tutorial

Introduction

Who wouldn’t be impressed by the soothing voice and gentle strokes of Bob Ross, the famous painter known for his happy little trees and clouds? In this article, we’ll explore how to use artificial intelligence (AI) to create paintings in the style of Bob Ross using PyTorch, a popular deep learning framework.

What is drawlikebobross?

The objective of the project is to transform a color image into a patchwork image resembling a Bob Ross painting style. This is achieved by using a neural network architecture called Adversarial Autoencoder (AAE), which we’ll discuss in more detail later.

Retrieving Data

Before we start training the network, we need to gather data to build a dataset. Fortunately, we found a set of data about Bob Ross’s works on the Two Inch Brush website. This site contains all of Bob Ross’s paintings in the following format:





http://www.twoinchbrush.com/images/paintingN.png

We used a script called scrapper.sh to fetch the data.

Data Preprocessing

Since our goal is to convert color images to Bob Ross style images, we decided to use mean shift filtering to achieve a smooth image. This operation takes a patch image as input and outputs an original image. To minimize training time, we preprocessed most of the original color images into smooth pictures and stored them in HDF5 format.

Neural Network Architecture

The project uses the Adversarial Autoencoder (AAE) network structure, also known as AAE. AAE is a type of autoencoder that uses a variational method to reason about the distribution of the encoder output. The blog presentation by Hjweide provides an in-depth explanation of AAE.

Our Model Input Data

We want to input a color image to the network and output a Bob Ross style image. The specific implementation process is as follows:

  1. Use AAE networks to migrate style
  2. Choose PyTorch as the implementation framework due to its ease of use and strong consistency
  3. Divide the training process into four parts:
    • models.py: Neural Networks
    • loader.py: data load operation
    • trainer.py: ultra-training network configuration parameters
    • train.py: training boot files

Training

The longer the network training, the better the network output Bob Ross style image effects. We trained the model on a rented g2 on AWS workstation, which took about a day, running 2,500 steps.

Conclusion

We have successfully used AI to create paintings in the style of Bob Ross using PyTorch. The open-source code also contains a web App, which you can download and test. We recommend students to spend two days practicing with this small item.

Code and Resources

You can find the complete code and resources on the QbitAI public view.