How to do it...

Let's implement these steps in code (The code file is available as Deepdream.ipynb in GitHub):

  1. Import the relevant packages and import the image:
import keras.backend as Kimport multiprocessingimport tensorflow as tfimport warningsfrom keras.applications.vgg19 import VGG19from keras.applications.imagenet_utils import preprocess_inputfrom scipy.optimize import minimizefrom skimage import img_as_float, img_as_ubytefrom skimage.io import imread, imsavefrom skimage.transform import pyramid_gaussian, rescaleimport scipyfrom keras.preprocessing import imagefrom keras.applications.vgg19 import preprocess_inputimport matplotlib.pyplot as plt%matplotlib inline

Preprocess the image so that it can then be passed to the VGG19 model: ...

Get Neural Networks with Keras Cookbook 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.