Applying style transfer with TFHub
Implementing Neural Style Transfer from scratch is a demanding task. Fortunately, we can use out-of-the-box solutions that live in TensorFlow Hub (TFHub).
In this recipe, we'll style our own images in just a few lines of code by harnessing the utility and convenience that TFHub provides.
Getting ready
We must install tensorflow-hub
. We can do this with just a simple pip
command:
$> pip install tensorflow-hub
If you want to access different sample content and style images, please visit this link: https://github.com/PacktPublishing/Tensorflow-2.0-Computer-Vision-Cookbook/tree/master/ch4/recipe5.
Let's take a look at the sample image:
Let's get started!
How to do it…
Neural Style Transfer with TFHub is a breeze! Follow these steps to complete this recipe:
- Import the necessary dependencies:
import matplotlib.pyplot as plt import numpy as...