Skip to content

Instantly share code, notes, and snippets.

@solaris33
Created March 27, 2017 13:27
Show Gist options
  • Save solaris33/43612034adcece85ff2430bb2fc68627 to your computer and use it in GitHub Desktop.
Save solaris33/43612034adcece85ff2430bb2fc68627 to your computer and use it in GitHub Desktop.
model_fn = 'tensorflow_inception_graph.pb'
# creating TensorFlow session and loading the model
graph = tf.Graph()
sess = tf.InteractiveSession(graph=graph)
with tf.gfile.FastGFile(model_fn, 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
t_input = tf.placeholder(np.float32, name='input') # define the input tensor
imagenet_mean = 117.0
t_preprocessed = tf.expand_dims(t_input-imagenet_mean, 0)
tf.import_graph_def(graph_def, {'input':t_preprocessed})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment