Style Transfer

Paintings require a special skill only a few have mastered. Paintings present a complex interplay of content and style. Photographs, on the other hand, are a combination of perspectives and light. When the two are combined, the results are spectacular and surprising. This process is called artistic style transfer. The following is an example of this, where the input image is of Neckarfront in Tübingen, Germany, and the style image is of the famous painting The Starry Night, by Vincent van Gogh. Interesting, isn't it? Take a look at the following images:

Left image: The original photograph depicting the Neckarfront in Tübingen, Germany. Right image: The painting (inset: The Starry Night by Vincent van Gogh) that provided the style for the respective generated image. Source: A Neural Algorithm of Artistic Style, Gatys et al. (arXiv:1508.06576v2)

If you look at the preceding images closely, the painting-styled image on the right seems to have picked up the content from the photograph on the left. The style, colors, and stroke patterns from the painting generated the final outcome. This fascinating outcome is a result of a transfer learning algorithm presented in the paper, A Neural Algorithm for Artistic Style, by Gatys et al. (https://arxiv.org/abs/1508.06576). We will discuss the intricacies of this paper from an implementation point of view, and see how we can perform this technique ourselves.

In this chapter, we will be focusing on leveraging deep learning along with transfer learning for building a neural style transfer system. The key areas of focus in the chapter include the following:

  • Understanding neural style transfer
  • Image preprocessing methodology
  • Building loss functions
  • Constructing a custom optimizer
  • Style transfer in action

We will be covering theoretical concepts around neural style transfer, loss functions and optimization. Besides this, we will use a hands-on approach to implement our own neural style transfer model. The code for this chapter is available for quick reference in the Chapter 10 folder in the GitHub repository at https://github.com/dipanjanS/hands-on-transfer-learning-with-python which you can refer to as needed to follow along with the chapter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset