Let's look at the available files, inputimage.png and testinception.py, which we're about to run. In this example, we'll be using the Panda image (inputimage.png).
- As shown in the following code, there's the NodeLookup class, which will help us to translate responses from the model to the label name:
class NodeLookup(object): """Converts integer node ID's to human readable labels."""
- The following code shows how we can read the image:
image = 'inputimage.png'image_data = tf.gfile.FastGFile(image, 'rb').read()
- Then, this is the code that tells how we import the pre-trained model:
with tf.gfile.FastGFile('classify_image_graph_def.pb', 'rb') as f: graph_def = tf.GraphDef() graph_def.ParseFromString(f.read()) tf.import_graph_def(graph_def, ...