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 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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.