Skip to content

Instantly share code, notes, and snippets.

@tachim

tachim/fff.py Secret

Created August 17, 2016 22:46
Show Gist options
  • Save tachim/6d44136171be86430dba16fecafa5872 to your computer and use it in GitHub Desktop.
Save tachim/6d44136171be86430dba16fecafa5872 to your computer and use it in GitHub Desktop.
def create_graph():
with tf.gfile.FastGFile(os.path.join(MODEL_DIR, 'classify_image_graph_def.pb'), 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
_ = tf.import_graph_def(graph_def, name='')
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()
# Creates graph from saved GraphDef.
with tf.Session(config=tf.ConfigProto(
allow_soft_placement=True,
log_device_placement=True,
)) as sess:
print sess.graph.get_collection(tf.GraphKeys.VARIABLES)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment