O'Reilly logo

Hands-On Serverless Deep Learning with TensorFlow and AWS Lambda by Rustem Feyzkhanov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Running the code

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).

  1. 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."""
  1. The following code shows how we can read the image:
image = 'inputimage.png'image_data = tf.gfile.FastGFile(image, 'rb').read()
  1. 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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required