Style loss using the Gram matrix

After creating an image that has the content of the original image, we will see how to create an image with just the style. Style can be thought of as a mix of colour and texture of an image. For that purpose, we will define style loss. First, we will load the image and convert it to an array, as shown in the following code:

style_image = Image.open(work_dir + 'starry_night.png')style_image = style_image.resize(np.divide(style_image.size, 3.5).astype('int32'))

Here is the style image we have loaded:

Now, we will preprocess this image by changing the channels, by using the following code: ...

Get Deep Learning for Computer Vision now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.