In tensorflow the training from the scratch produced following files 6 files:
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.
Windows7/64, tensorflow 1.0, python 3.5.3. GPU: Quadro M2000.
Hi,
I am currently facing the same problems and questions but if I understood correctly, I think you can try something like this (with the freeze_graph script in tensorflow/python/tools) :
python freeze_graph.py --input_graph=/path/to/graph.pbtxt --input_checkpoint=/path/to/model.ckpt-22480 --input_binary=false --output_graph=/path/to/frozen_graph.pb --output_node_names="the nodes that you want to output e.g. InceptionV3/Predictions/Reshape_1 for Inception V3 "
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.
The problem for me is that on my fine-tuned im2txt model, I have the error AssertionError: softmax is not in graph
when I try to freeze the model. If someone can help, that would be great.
Regards,
Stephane
Thank you Stephane
Since all files including the script file are in the same folder I tried a following command:
python freeze_graph.py --input_graph=graph.pbtxt --input_checkpoint=model.ckpt-22480 --input_binary=false --output_graph=frozen_graph.pb --output_node_names=softmax
The script started but I got after a minute an error:
AssertionError: softmax is not in graph
what make a sense - softmax is just the last layer
Then I tried with the output_node_names=InceptionV3/Predictions/Reshape_1
and I got my:
Converted 190 variables to const ops
and the frozen_graph.pb with its 85MB graph has been created.
How did you know what is the name of the output node (InceptionV3/Predictions/Reshape_1) which I should use?
regards
Rafal
Honestly, I mainly followed the tutorial in https://github.com/tensorflow/models/blob/master/slim/export_inference_graph.py and applied the given commands.
As indicated, to obtain the names of the tensors, you can use the summarize_graph script which can take the pb or the pbtxt as an input.
Sorry, but as I am a beginner in Tensorflow, I may not be really more helpful.
Regards,
Stephane
This question is better asked on StackOverflow since it is not a bug or feature request. There is also a larger community that reads questions there. Thanks!
I have the same problem.
@StephaneZFR, the link which you send is not available anymore.
Do you still have the tutorial that you has followed ?
Most helpful comment
Hi,
I am currently facing the same problems and questions but if I understood correctly, I think you can try something like this (with the freeze_graph script in tensorflow/python/tools) :
python freeze_graph.py --input_graph=/path/to/graph.pbtxt --input_checkpoint=/path/to/model.ckpt-22480 --input_binary=false --output_graph=/path/to/frozen_graph.pb --output_node_names="the nodes that you want to output e.g. InceptionV3/Predictions/Reshape_1 for Inception V3 "
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.
The problem for me is that on my fine-tuned im2txt model, I have the error
AssertionError: softmax is not in graph
when I try to freeze the model. If someone can help, that would be great.Regards,
Stephane