VGG16 in TensorFlow
Note
You can follow along with the code in the Jupyter notebook ch-12a_VGG16_TensorFlow
.
For all examples of VGG16 in TensorFlow, we first download the checkpoint file from http://download.tensorflow.org/models/vgg_16_2016_08_28.tar.gz and initialize variables with the following code:
model_name='vgg_16' model_url='http://download.tensorflow.org/models/' model_files=['vgg_16_2016_08_28.tar.gz'] model_home=os.path.join(models_root,model_name) dsu.download_dataset(source_url=model_url, source_files=model_files, dest_dir = model_home, force=False, extract=True)
We also define some common imports and variables:
from tensorflow.contrib import slim from tensorflow.contrib.slim.nets import vgg image_height=vgg.vgg_16.default_image_size image_width=vgg.vgg_16.default_image_size
Image classification using pre-trained VGG16 in TensorFlow
Now let us first try to predict the classes of our test images, without retraining. First, we clear the default graph and define a...