O'Reilly logo

Python Deep Learning Cookbook by Indra den Bakker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

  1. We start with importing all the necessary libraries as follows:
from keras.preprocessing.image import load_img, img_to_arrayfrom scipy.misc import imsaveimport numpy as npfrom scipy.optimize import fmin_l_bfgs_bimport timeimport argparsefrom keras.applications import vgg16from keras import backend as K
  1. Next, we load the two images that we will use for style transfer and plot them:
base_image_path = 'Data/golden_gate.jpg'style_reference_image_path = 'Data/starry_night.jpg'result_prefix = 'result_'width, height = load_img(base_image_path).sizeimg_rows = 400img_cols = 600img_channels = 3plt.figure(figsize=(15, 15))plt.subplot(2, 2, 1)img = load_img(base_image_path)plt.imshow(img)plt.subplot(2, 2, 2)img = load_img(style_reference_image_path) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required