What we will do is also called Neural style transfer Is a method of mixing two images and creating a new image from the content image by copying the style of another image, which is called a style image. The resulting image is often referred to as a stylized image.
In this article, we will copy Andy Warhol’s style from Marilyn Diptych to our photographs. Warhol created the Monroe diptych in 1962, first painting the canvas with different colors and then placing the now famous image of Marilyn on top of the canvas. Although Warhol is not the founder of Pop Art, he is one of the most influential figures in the genre.
On the technical side of the tutorial, instead of using the off-the-shelf Magenta network, we will use a pretrained VGG-19 computer vision model and tweak it. Thus, this article is a guide to portable learning, as well as computer vision. By using transfer learning capabilities, we can achieve better results if we can properly tune the model and have a wide range of additional customization options.
portable learning Is a subsection of machine learning and artificial intelligence, the purpose of which is to apply the knowledge gained as a result of performing one task (original task) to another, but similar task (target task).
I will briefly talk about the model that we will be tuning: VGG-19.
VGG is a convolutional neural network with a depth of 19 layers. It was built and trained by K. Simonyan and A. Zisserman at Oxford University in 2014. All information about this is in the article. Very Deep Convolutional Networks for Large-Scale Image Recognitionpublished in 2015. The VGG-19 network has been trained using over one million images from the ImageNet database. She trained on 224×224 pixel color images. Naturally, you can import the ImageNet model with the weights already trained. This pre-trained network can classify up to a thousand objects. In this tutorial, we will get rid of the top used for classification and add our own additional layers so that it can be used for neural style transfer. Here is the official network visualization from academic work:
As I mentioned, whose style could be more iconic and more appropriate than Andy Warhol’s style for transferring to pop art. We’ll use his iconic work, Marilyn Diptych, as the styling base, and his Unsplash portrait photo as the main content:
Setting paths to images
Using TensorFlow I can write
get_files [получить файлы] from external URLs. With the code below, I will upload images to my Colab notebook, one for style and one for content: