I have a frozen trained model for object detection that has already been tested on videos. I wanna optimize the model using the optimize_for_inference library using this code:
import tensorflow as tf
from tensorflow.python.tools import freeze_graph
from tensorflow.python.tools import optimize_for_inference_lib
input_graph_def = tf.GraphDef()
with tf.gfile.Open("frozen_inference_graph.pb", "rb") as f:
data = f.read()
input_graph_def.ParseFromString(data)
output_graph_def = optimize_for_inference_lib.optimize_for_inference(
input_graph_def,
['input'], ## input
['y_'], ## output
tf.float32.as_datatype_enum)
f = tf.gfile.FastGFile("./inference_graph/optimized_inference_graph.pb", "wb")
f.write(output_graph_def.SerializeToString())
I tested the generated optimized_inference_graph.pb but it issued this error during testing:
DecodeError Traceback (most recent call last) in () 5 with tf.gfile.GFile(PATH_TO_CKPT, 'rb') as fid: 6 serialized_graph = fid.read() ----> 7 od_graph_def.ParseFromString(serialized_graph) 8 tf.import_graph_def(od_graph_def, name='') 9
DecodeError: Error parsing message
Is this library no longer available? Is it replaced by transform
_graph?