Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to convert .meta, .data and .index model files into one graph.pb file? #2283

Closed
rafalfirlejczyk opened this issue Aug 24, 2017 · 5 comments

Comments

@rafalfirlejczyk
Copy link

rafalfirlejczyk commented Aug 24, 2017

In tensorflow the training from the scratch produced following files 6 files:

  1. events.out.tfevents.1503494436.06L7-BRM738
  2. model.ckpt-22480.meta
  3. checkpoint
  4. model.ckpt-22480.data-00000-of-00001
  5. model.ckpt-22480.index
  6. 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.

Windows7/64, tensorflow 1.0, python 3.5.3. GPU: Quadro M2000.

@StephaneZFR
Copy link

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

@rafalfirlejczyk
Copy link
Author

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

@StephaneZFR
Copy link

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

@reedwm
Copy link
Member

reedwm commented Sep 11, 2017

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!

@reedwm reedwm closed this as completed Sep 11, 2017
@ricardobnjunior
Copy link

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants