serizba / cppflow

Run TensorFlow models in C++ without installation and without Bazel
https://serizba.github.io/cppflow/
MIT License
779 stars 177 forks source link

Problem on reading a .pb model #191

Open FrancescaCi opened 2 years ago

FrancescaCi commented 2 years ago

Hi, Can I have some support for reading a .pb model, please? I am trying to use the example code load_model to open a different model .pb, I have the .pb file but not the variables as the example, and the error is: SavedModel load for tags { serve }; Status: fail: NOT_FOUND: Could not find meta graph def matching supplied tags: { serve }. To inspect available tag-sets in the SavedModel, please use the SavedModel CLI: saved_model_cli. Took 7103 microseconds. terminate called after throwing an instance of 'std::runtime_error' what(): Could not find meta graph def matching supplied tags: { serve }. To inspect available tag-sets in the SavedModel, please use the SavedModel CLI: saved_model_cli

How can I manage this issue? Thank you so much.

sph001 commented 2 years ago

just incase you are still looking for an answer.

I had a similar problem, the issue was that the model was a frozen graph and must be loaded using:

auto Model = model(model_path, cppflow::model::FROZEN_GRAPH)

FrancescaCi commented 2 years ago

thank you so much. I will try your solution and let you know!

FrancescaCi commented 2 years ago

thank you so much for the support. Do you know why I am facing this issues, in your opinion? error: ‘FROZEN_GRAPH’ is not a member of ‘cppflow::model’ 10 | auto Model = cppflow::model("../model", cppflow::model::FROZEN_GRAPH);

@sph001

ljn917 commented 2 years ago

Can you try cppflow::model::TYPE::FROZEN_GRAPH?

On Tue, Jun 21, 2022, 8:27 PM FrancescaCi @.***> wrote:

thank you so much for the support. Do you know why I am facing this issues, in your opinion? error: ‘FROZEN_GRAPH’ is not a member of ‘cppflow::model’ 10 | auto Model = cppflow::model("../model", cppflow::model::FROZEN_GRAPH);

@sph001 https://github.com/sph001

— Reply to this email directly, view it on GitHub https://github.com/serizba/cppflow/issues/191#issuecomment-1161681987, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALDTHUQDVLI6RWKRBD35UTVQGYMHANCNFSM5UMCDC3Q . You are receiving this because you are subscribed to this thread.Message ID: @.***>

FrancescaCi commented 2 years ago

error: ‘TYPE’ is not a member of ‘cppflow::model’ 10 | auto Model = cppflow::model("../model", cppflow::model::TYPE::FROZEN_GRAPH); | ^~~~ Yes.... Infact I am not understanding why it is recognizing as not a member

serizba commented 1 year ago

Hi @FrancescaCi

Did you manage to fix this? Did you try with the latest version of the code?

ljn917 commented 1 year ago

I think cppflow::model::FROZEN_GRAPH is the right one here. Can you check if you include model.h and the enum TYPE is there?

On Tue, Jun 21, 2022, 9:28 PM FrancescaCi @.***> wrote:

error: ‘TYPE’ is not a member of ‘cppflow::model’ 10 | auto Model = cppflow::model("../model", cppflow::model::TYPE::FROZEN_GRAPH); | ^~~~ Yes.... Infact I am not understanding why it is recognizing as not a member

— Reply to this email directly, view it on GitHub https://github.com/serizba/cppflow/issues/191#issuecomment-1161749929, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALDTHTUYZUUXSF6QDXC353VQG7QJANCNFSM5UMCDC3Q . You are receiving this because you commented.Message ID: @.***>

bmiftah commented 1 year ago

Hi , If still looking for solution for this issue, let me share what I tried . For the issue of loading frozen model , I did the following : - (similar to what was mentioned ealier , but note the model is frozen one ! )

cppflow::model model("Froozen_model/ab_frozen_graph.pb",cppflow::model::TYPE::FROZEN_GRAPH);

loading the model was okay but later when I make inference using thi loaded model using : output_tensor = model(input_1);

This error showed up :- No operation named "serving_default_input_1" exists -

I don't have operation named serving_default_input_1 in my model , rather I have 'input_1' as my input node , Is that what cppflow expects ? I saw else where this issue was rasied but still I couldnt get work around for this issue ? I stuck here for long and any suggestion is appreciated !