Fine-tuning a network using TFHub
One of the easiest ways to fine-tune a network is to rely on the wealth of pre-trained models that live in TensorFlow Hub (TFHub). In this recipe, we'll fine-tune a ResNetV1152 feature extractor to classify flowers from a very small dataset.
Getting ready
We will need tensorflow-hub
and Pillow
for this recipe. Both can be installed easily, like this:
$> pip install tensorflow-hub Pillow
We'll use a dataset known as 17 Category Flower Dataset
, which can be accessed at http://www.robots.ox.ac.uk/~vgg/data/flowers/17. I encourage you to get a re-organized copy of the data here: https://github.com/PacktPublishing/Tensorflow-2.0-Computer-Vision-Cookbook/tree/master/ch3/recipe3/flowers17.zip. Download and decompress it in a location of your choosing. From now on, we'll assume the data is in ~/.keras/datasets/flowers17
.
The following are some sample images from this dataset: