def run_inference_on_image(image):
 if (not tf.gfile.Exists(image)):
  tf.logging.fatal('File does not exist %s', image)
 image_data = tf.gfile.FastGFile(image, 'rb').read()
 create_graph()
 with tf.Session() as sess:
  softmax_tensor = sess.graph.get_tensor_by_name('softmax:0')
  predictions = sess.run(softmax_tensor, {'DecodeJpeg/contents:0': image_data})
  predictions = np.squeeze(predictions)
  node_lookup = NodeLookup()
  top_k = predictions.argsort()[(- FLAGS.num_top_predictions):][::(-1)]
  for node_id in top_k:
   human_string = node_lookup.id_to_string(node_id)
   score = predictions[node_id]
   print(('%s (score = %.5f)' % (human_string, score)))

def run_inference_on_image ( image ) : if ( not tf . gfile . Exists ( image ) ) : tf . logging . fatal ( 'File does not exist %s' , image ) image_data = tf . gfile . FastGFile ( image , 'rb' ) . read ( ) create_graph ( ) with tf . Session ( ) as sess : softmax_tensor = sess . graph . get_tensor_by_name ( 'softmax:0' ) predictions = sess . run ( softmax_tensor , { 'DecodeJpeg/contents:0' : image_data } ) predictions = np . squeeze ( predictions ) node_lookup = NodeLookup ( ) top_k = predictions . argsort ( ) [ ( - FLAGS . num_top_predictions ) : ] [ : : ( - 1 ) ] for node_id in top_k : human_string = node_lookup . id_to_string ( node_id ) score = predictions [ node_id ] print ( ( '%s (score = %.5f)' % ( human_string , score ) ) )
runs inference on an image .