Created
May 6, 2020 10:52
-
-
Save dkurt/3486f09fafe568ee20e500310dedcb9f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
from tensorflow.python.tools import optimize_for_inference_lib | |
pb_file = 'resnet_v2_101_299_frozen.pb' | |
graph_def = tf.compat.v1.GraphDef() | |
try: | |
with tf.io.gfile.GFile(pb_file, 'rb') as f: | |
graph_def.ParseFromString(f.read()) | |
except: | |
with tf.gfile.FastGFile(pb_file, 'rb') as f: | |
graph_def.ParseFromString(f.read()) | |
graph_def = optimize_for_inference_lib.optimize_for_inference(graph_def, ['input'], ['output'], tf.float32.as_datatype_enum) | |
with tf.gfile.FastGFile('resnet_v2_101_299_opt.pb', 'wb') as f: | |
f.write(graph_def.SerializeToString()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment