Style transfer

Style transfer is a technique that redraws one image in the visual style of another, for example giving a photo the colours and brushwork of a painting, while keeping its content.

Neural style transfer began with a paper posted in August 2015 by Leon Gatys, Alexander Ecker and Matthias Bethge, A Neural Algorithm of Artistic Style. Their insight was that a neural network trained to recognise objects represents an image's content and its style in separable ways, so the two could be taken from different pictures and recombined.

The method used VGG-19, a network pre-trained for image recognition. Content was measured by the network's activations at a deep layer, which record what objects are where. Style was measured by Gram matrices: tables of how strongly different filters fire together across several layers, which capture textures, colours and strokes regardless of where they occur. Starting from the photo plus a little noise, the algorithm adjusted the pixels over thousands of iterations until the image matched the photo's content and the painting's style, which took a few minutes on a GPU as of 2017.

Speed came next. In March 2016 Justin Johnson, Alexandre Alahi and Li Fei-Fei trained a separate network to perform the transformation in a single pass, about 1,000 times faster, fast enough for real time, though each network handled only one style. In 2017 Google showed a network that learned several styles at once, and Huang and Belongie showed real-time transfer of arbitrary styles. Mobile apps such as Prisma and DeepArt brought the effect to phones. The idea had a pre-neural ancestor: image analogies, a patch-based method from 2001.

Style transfer keeps the layout of the original and changes its surface, which separates it from text-to-image generation, where the model invents the whole picture. The same perceptual loss that made fast style transfer work also improved image super-resolution, an early sign of how ideas from this work spread into wider image processing.

Common questions

How does neural style transfer work?

It uses a neural network trained for image recognition to measure two things: the content of one image and the style of another, the latter captured as correlations between the network's features. An output image is then optimised, or produced by a trained network, so that it matches the first image's content and the second image's style.

Who invented neural style transfer?

Leon Gatys, Alexander Ecker and Matthias Bethge introduced it in a paper posted to arXiv in August 2015 and presented at the CVPR conference in 2016. Faster versions followed from Justin Johnson and colleagues in 2016 and from Google and other researchers in 2017.

Is style transfer the same as AI image generation?

No. Style transfer starts from an existing image and changes how it looks while keeping what it shows. Text-to-image generation creates a new image from a description. Modern image generators can imitate styles too, but they work differently.

Finding more

Search for "neural style transfer", "Gatys style transfer" or "arbitrary style transfer" to follow the method and its successors. The original papers on arXiv are short and readable, and encyclopedia articles summarise the main variants with citations. For questions about using artists' styles, look for legal analysis from law firms and academics rather than technical sources.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.