Content loss

Since pixels are not a good choice, we will use the CNN features of various layers, as they are a better representation of the content. The initial layers as seen in Chapter 3, Image Retrieval, have high-frequency such as edges, corners, and textures but the later layers represent objects, and hence are better for content. The latter layer can compare the object to object better than the pixel. But for this, we need to first import the required libraries, using the following code:

import numpy as npfrom PIL import Imagefrom scipy.optimize import fmin_l_bfgs_bfrom scipy.misc import imsavefrom vgg16_avg import VGG16_Avgfrom keras import metricsfrom keras.models import Modelfrom keras import backend as K

Now, let's load the required ...

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.