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) ...

Get Python Deep Learning 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.