How to do it...

Perform the following steps:

  1. First, we'll download the pre-trained network in mat format. The mat format is a matlab object, and the scipy package in Python has a method that can read it. The link to download the mat object is here. We save this model in the same folder our Python script is in, for reference:
http://www.vlfeat.org/matconvnet/models/beta16/imagenet-vgg-verydeep-19.mat 
  1. We'll start our Python script by loading the necessary libraries:
import osimport scipy.ioimport scipy.miscimport imageiofrom skimage.transform import resizefrom operator import mulfrom functools import reduceimport numpy as npimport tensorflow as tffrom tensorflow.python.framework import opsops.reset_default_graph()
  1. Then we can declare ...

Get TensorFlow Machine Learning Cookbook - Second Edition 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.