In tensorflow the training from the scratch produced following 6 files:
- events.out.tfevents.1503494436.06L7-BRM738
- model.ckpt-22480.meta
- checkpoint
- model.ckpt-22480.data-00000-of-00001
- model.ckpt-22480.index
- graph.pbtxt
I would like to convert them (or only the needed ones) into one file graph.pb to be able to transfer it to my Android application.
I tried the script freeze_graph.py
but it requires as an input already the input.pb file which I do not have. (I have only these 6 files mentioned before). How to proceed to get this one freezed_graph.pb file? I saw several threads but none was working for me.
First, use the following code to generate the graph.pb file. with tf.Session() as sess:
then, use summarize graph get the output node name. Finally, use
to generate the freeze graph.
You can use this simple script to do that. But you must specify the names of the output nodes.
If you don't know the name of the output node or nodes, there are two ways
You can explore the graph and find the name with Netron or with console summarize_graph utility.
You can use all the nodes as output ones as shown below.
But I think it's unusual situation, because if you don't know the output node, you cannot use the graph actually.
As it may be helpful for others, I also answer here after the answer on github ;-). I think you can try something like this (with the freeze_graph script in tensorflow/python/tools) :
The important flag here is --input_binary=false as the file graph.pbtxt is in text format. I think it corresponds to the required graph.pb which is the equivalent in binary format.
Concerning the output_node_names, that's really confusing for me as I still have some problems on this part but you can use the summarize_graph script in tensorflow which can take the pb or the pbtxt as an input.
Regards,
Steph
I tried the freezed_graph.py script, but the output_node_name parameter is totally confusing. Job failed.
So I tried the other one: export_inference_graph.py. And it worked as expected!
The tensorflow installation package I used is from here: https://github.com/tensorflow/models