Hello Guys …
I was Trying to Convert this Tiramisu Model into a Protobuff File to run this Model on Android …
def export_model(saver, model, input_node_names, output_node_name):
MODEL_NAME='tiramisu'
tf.train.write_graph(K.get_session().graph_def, 'out', \
MODEL_NAME + '_graph.pbtxt')
saver.save(K.get_session(), 'out/' + MODEL_NAME + '.chkp')
freeze_graph.freeze_graph('out/' + MODEL_NAME + '_graph.pbtxt', None, \
False, 'out/' + MODEL_NAME + '.chkp', output_node_name, \
"save/restore_all", "save/Const:0", \
'out/frozen_' + MODEL_NAME + '.pb', True, "")
input_graph_def = tf.GraphDef()
with tf.gfile.Open('out/frozen_' + MODEL_NAME + '.pb', "rb") as f:
input_graph_def.ParseFromString(f.read())
output_graph_def = optimize_for_inference_lib.optimize_for_inference(
input_graph_def, input_node_names, [output_node_name],
tf.float32.as_datatype_enum)
with tf.gfile.FastGFile('out/opt_' + MODEL_NAME + '.pb', "wb") as f:
f.write(output_graph_def.SerializeToString())
print("graph saved!")
Tried Calling this function >>
export_model(tf.train.Saver(), model, [model.input.name], model.output.name)
It gives the below error >>
INFO:tensorflow:Restoring parameters from out/tiramisu.chkp
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-80-ce4abb242ea5> in <module>()
----> 1 export_model(tf.train.Saver(), model, [model.input.name], model.output.name)
<ipython-input-71-81c8aebbb95e> in export_model(saver, model, input_node_names, output_node_name)
5 saver.save(K.get_session(), 'out/' + MODEL_NAME + '.chkp')
6
----> 7 freeze_graph.freeze_graph('out/' + MODEL_NAME + '_graph.pbtxt', None, False, 'out/' + MODEL_NAME + '.chkp', output_node_name, "save/restore_all", "save/Const:0", 'out/frozen_' + MODEL_NAME + '.pb', True, "")
8
9 input_graph_def = tf.GraphDef()
/usr/local/lib/python3.5/dist-packages/tensorflow/python/tools/freeze_graph.py in freeze_graph(input_graph, input_saver, input_binary, input_checkpoint, output_node_names, restore_op_name, filename_tensor_name, output_graph, clear_devices, initializer_nodes, variable_names_blacklist)
177 clear_devices,
178 initializer_nodes,
--> 179 variable_names_blacklist)
180
181
/usr/local/lib/python3.5/dist-packages/tensorflow/python/tools/freeze_graph.py in freeze_graph_with_def_protos(***failed resolving arguments***)
114 input_graph_def,
115 output_node_names.split(","),
--> 116 variable_names_blacklist=variable_names_blacklist)
117
118 with gfile.GFile(output_graph, "wb") as f:
/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/graph_util_impl.py in convert_variables_to_constants(sess, input_graph_def, output_node_names, variable_names_whitelist, variable_names_blacklist)
202 # This graph only includes the nodes needed to evaluate the output nodes, and
203 # removes unneeded nodes like those involved in saving and assignment.
--> 204 inference_graph = extract_sub_graph(input_graph_def, output_node_names)
205
206 found_variables = {}
/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/graph_util_impl.py in extract_sub_graph(graph_def, dest_nodes)
139
140 for d in dest_nodes:
--> 141 assert d in name_to_node_map, "%s is not in graph" % d
142
143 nodes_to_keep = set()
AssertionError: truediv:0 is not in graph
Below is the Model.summary ()
https://pastebin.com/72gUrRr0
Can Some one Suggest…