Regressor Based Image Stylization

We’re happy to showcase a side project from our Head of Research, Alec Radford. Using regression based machine learning techniques, he’s recently released an open-source image stylization library, stylize, for Python. Feel free to check out the repo and play with the code there!

Here’s what he has to say about it:

Inspired by the various projects implementing polygonal stylization of images via blends of genetic algorithms and hill climbing and Andrej Karpathy’s rephrasing of the problem in a machine learning framework.

Whereas genetic algorithm and hill climbing approaches can take hours, stylize runs in seconds with much greater flexibility and higher fidelity when desired.

 


Usage (example.py has more detail):

from stylize import render
from scipy.misc import imread

image = imread('image.jpg')
defaults = render(image)

 

Our Test Subject, my cat Iggy
Iggy the Cat

 

Default stylization
Default stylization

render(image)

 


 

Abstract
Abstract

render(image,depth=4)

 

Smooth
Smooth

render(image,iterations=25)

 

More Detail
More Detail

render(image,ratio=0.00005)

 

Less Detail
Less Detail

render(image,ratio=0.001)

 


 

Visualizing the Process

Iggy the Stylized Cat
How it Works

stylize is currently based off of regression trees and an ensembled version of that model, the random forest regressor. Regression trees work by recursively partitioning (“splitting”) their input feature space and assigning associations to those partitions (such as colors). At each frame the model splits every partition in half again until hitting its minimum partition size.

Suggested Posts

Machine Learning So Easy, Even Your Cat Could Do It (Part 2): Text Tags

Exploring Computer Vision (Part II): Transfer Learning

Auto-tagging Interior Design Styles