Ethan Marks

ColourlessTransformer

ยท 2 min read

PaintTransformer is a neural network that approximates images using paint strokes. This gives it a very pretty and stylized watercolor/painterly aesthetic.

I like how this looks, and I’ll sometimes just run random photos through it to see how they turn out.

A highly stylized watercolour-style image of a concrete walkway runs alongside a dense hedge of flowering bushes, all under a sleek red pergola.
PaintTransformer applied to a photo I took at Taliesin West

Another cool thing you can do is save each step as a frame, which creates a cool animation similar to a watercolor timelapse.

PaintTransformer starts by adding with broad, vague brush strokes and ends with tiny details. It’s just a few blobs of colour at the start and it’s highly detailed at the end. This makes for a fun charades-like game: how quickly can you guess what it’s painting?

How long does it take you to guess what it's painting?

PaintTransformer was developed in this paper by a team of researchers. It was later implemented in PyTorch by Huage001

I wanted to use PaintTransformer, but my makeshift solution of uploading files to a Colab runtime was too clunky to be used at scale. So I instead decided to build a custom interface. I named it ColourlessTransformer because I was going through a phase of naming everything eponymously after my username.

Streamlit

This was my first time working with Streamlit. I originally planned to use Gradio for this project because I had previous experience, but Gradio is an extremely heavy framework for my use case, and the 2-minute starting times were bothering me. I’m quite happy with how the it turned out.

A user interface built with Streamlit, showing a split-screen comparison. On the left is an uploaded image of a fluffy gray cat sitting in front of a red chair and some candles. On the right is the corresponding generated animation, which depicts the same scene rendered in a painterly, watercolor-like style with broad brushstrokes and vibrant colors.
Using ColourlessTransformer to apply PaintTransformer to a photo of my cat, Toby

Usage

If you want to try this out on your own, follow the instructions in the README. You’ll need Git, Python, a GPU, and some familiarity with the terminal.

Conclusion

Two images of the Seattle Space Needle, side-by-side. The left image is an photo, and the one on the right is is heavily stylized and painterly image generated by PaintTransformer
PaintTransformer applied to a photo I took of the Seattle Space Needle

ColourlessTransformer was one of my favorite projects because I started with a complex task that took 3-5 minutes of tedious parameter filling and file reorganization and ended with a sleek, fast, and painless custom application.

Apparently it wasn’t enough to automate watercolor; I also had to automate the automation.

~Ethan