How to do it...

Let us start with the recipe:

  1. Import a few modules such as numpy, scipy, tensorflow, and matplotlib. Then import PIL to manipulate images. Note that as this code runs on a Jupyter notebook that you can download from online, the fragment %matplotlib inline has been added:
import os import sys import numpy as np import scipy.io import scipy.misc import tensorflow as tf import matplotlib.pyplot as plt from matplotlib.pyplot import imshow from PIL import Image %matplotlib inline from __future__ import division
  1. Then, set the input path for the image used to learn the style and for the content image to be repainted according to the style:
OUTPUT_DIR = 'output/' # Style image STYLE_IMAGE = 'data/StarryNight.jpg' # Content image ...

Get TensorFlow 1.x 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.