Here's an answer to the question "What is Style Transfer?" that I posted recently in a discussion forum. It has the same structure as yesterday's post on the topic, but is shorter and so might be easier to understand.
In its most general sense, rendering one artefact in the style of another. Most research recently has probably been on style transfer in visual art: particularly on rendering photographs in the styles of various famous painters. Here are some examples:
[ Image: viaby Firdaouss Doukkali in Towards Data Science, credited to ]
[ Image: fromby Harish Narayanan in his blog ]
[ Image: viaby Shafeen Tejani in the From Bits to Brains blog, from "Image Style Transfer Using Convolutional Neural Networks" by Leon A. Gatys, Alexander S. Ecker, Matthias Bethge ]
The concept of style transfer doesnâ€™t need to be restricted to visual art. For example, thereâ€™s a paper on style transfer in cooking described in Lucy Blackâ€™s(14 May 2017). The work she describes is by Masahiro Kazama, Minami Sugimoto, Chizuru Hosokawa, Keisuke Matsushima, Lav R. Varshney and Yoshiki Ishikawa, one of whom she says is a professional chef. Itâ€™s written up in an arXiv paper at .
In visual art, the concept doesnâ€™t need to be restricted to photographs and paintings. Prutha Date, Ashwinkumar Ganesan, Tim Oates have written a paper on, also available in the arXiv. (This is one reason Iâ€™m taking an interest.)
But now letâ€™s talk about photographs and paintings. As I understand it, the â€œmodern eraâ€ in style transfer began with a paper by Leon A. Gatys, Alexander S. Ecker and Matthias Bethge,. There had been work on the topic before, but it tended to use only low-level image features to define style, and could cope only with a restricted range of objects in images, e.g. faces. The advance of Gatys et. al. was to use so-called â€œconvolutional neural networksâ€ (a.k.a. â€œconvnetsâ€). These can be trained to recognise a vast range of common objects, making it possible to separate the â€œcontentâ€ of an image (i.e. the things it depicts) from its style. They are also able to recognise higher-level aspects of style than could previous work.
The key points as I understand them are:
1) Style (in most of this work) refers to the technique of a single artist in a single painting. Though there is now research on inferring style from multiple paintings by the same artist, e.g. all Impressionist paintings by Monet.
2) Style means things like the thickness and smoothness of lines, how wiggly they are, the density and distribution of colour, and the surface texture of brush strokes in oil paintings.
3) Style can occur at a range of scales.
[ Image: incorporates Wikipedia's]
In the above images, the circles represent what a vision scientist might call â€œreceptive fieldsâ€. Each one â€œseesâ€ the properties of the image portion within it. The first set of circles â€œseeâ€ how the boundaries of the church and its spire are painted. The second set â€œseeâ€ the swirls in van Goghâ€™s sky. Each one sees an individual swirl, and can perceive bulk properties such as its width and curvature. The third set of circles also â€œseeâ€ the swirls, but in much more detail. They see a swirl as a bundle of strokes, and can work out how far these are apart, how their shapes match, and so on.
4) Style is distributed across the entire image. The above should make that clear. Or think of other examples, such as a cartoonistâ€™s cross-hatching. So estimating style entails working out correlations between different parts of the image.
5) Given two images, itâ€™s possible to work out how close they are in style. In other words, style can be quantified. This is important, because if we write a program that wants to render (say) a portrait of Quoraâ€™s founder in the style of The Starry Night, the program has to know when its output actually looks van-Gogh-ish.
6) As already said, images have â€œcontentâ€ as well as style. The content of an image is the objects it depicts.
7) The detection of content actually rests on a vast amount of work done to train learning programs (these â€œconvnetsâ€) to recognise objects. This work in turn has relied on (a) a huge database of images called; (b) a huge number of volunteers to label the images therein with their descriptions; (c) a huge database of words and concepts called . The last of these gives the volunteers a consistent framework, so that if two volunteers label a picture of a crocodile (say), theyâ€™ll do so in the same way.
8) Unlike style, content is local. Objects occupy a fixed part of an image, and the recogniser need only be interested in that. Unlike style, most objects donâ€™t contain long repeated patterns. (Indeed, if they do, I think weâ€™d often regard that as texture, and the choice of how to depict the texture as style.)
9) Given two images, itâ€™s possible to work out how close they are in content. In other words, content can be quantified. This is important, because if we write a program that wants to render (say) a portrait of Quoraâ€™s founder in the style of The Starry Night, the program has to know when its output actually looks like said founder.
10) OK, now we have everything we need. So suppose I have two images. One, Q, is the â€œcontentâ€ image: the photo of Mr. Quora. One, S, is the â€œstyleâ€ image: a photo of The Starry Night. Now I generate a third image, O, at random. This is going to become my output: Mr. Quora retouched in the style of The Starry Night.
By point 5, I can measure how close O and S are in style. By point 9, I can measure how close O and S are in content. And I can continue doing this no matter how I change O.
So I now start optimising. If O is far in style from S, I tweak it so as to bring it closer. If O is far in content from Q, I tweak it to bring it closer. And I keep doing so until the result is quite close to S in style, and quite close to Q in content.
The important point here is that my tweaker doesnâ€™t itself need to know how to measure style and content. It just needs to feed O into the â€œhow close am I to S in style meterâ€ and the â€œhow close am I to Q in content meterâ€ mentioned two paragraphs ago, then keep tweaking O until both meters give a high reading. And, just to recap, by â€œmeterâ€, I mean the â€œconvnetsâ€ that Gatys et. al. used.
How does the optimisation know how to tweak an image? After all, if it just kept on doing so at random, perhaps millions of years would pass before it got an acceptable result. The answer is something called â€œgradient descentâ€. This is like a man standing on top of a hill, and taking a few strides along each path down it, in order to estimate which path will get him to the base most quickly.
So thatâ€™s a non-technical summary of â€œmodern eraâ€ work on visual style transfer. Iâ€™ve written it up in more detail as a blog post, â€œâ€ . This post has references in it to the paper by Gatys et. al., and to various review and blog articles.
Style transfer research will continue, Iâ€™m sure, in many directions. I can foresee researchers wanting to make it more â€œsemanticâ€. When you see this word, itâ€™s a give-away that the author wants their programs to become less superficial, looking at â€œmeaningsâ€ rather than surface features. And although current work already produces some stunning images, it by no means has a perfect conception of style.
For example,refers to the early cubism of Braque and others, where paintings were made from a variety of fragmentary images, each showing the same object from a different viewpoint. These paintings have a distinctive texture which many will recognise:
[ Image: via, Le Jour ni lâ€™Heure 3854 by George Braque ]
I suspect that if you were to ask the program Gatys et. al. describe to render an object in this style, it would faithfully emulate the texture. But I bet that it would not break the object into fragments and paint each from a different viewpoint. Thatâ€™s one of the main characteristics of the style, but I donâ€™t think the current generation of style-transfer programs could know this.