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

convert pb model to tensorflow.js model #76

Open
shuxiongwuziqi opened this issue Mar 3, 2021 · 2 comments
Open

convert pb model to tensorflow.js model #76

shuxiongwuziqi opened this issue Mar 3, 2021 · 2 comments

Comments

@shuxiongwuziqi
Copy link

shuxiongwuziqi commented Mar 3, 2021

Hello, I try to convert the pb model to tensorflow.js model, but I encountered some problem. I follow the official tutorial to convert model over here. The first difficulty is to find the output_node_names, I used the codes as follows to solve this problem.

with tf.gfile.FastGFile('./model/mobile_facenet.pb','rb') as f:
    graph_def = tf.GraphDef()
    graph_def.ParseFromString(f.read())
tf.import_graph_def(graph_def, name='mobile_facenet')
tensor_name_list = [tensor.name for tensor in tf.get_default_graph().as_graph_def().node]
print(tensor_name_list[-1])

Then, I got ''embeddings'', so the output node name should be ''embeddings''.
Therefore, I use the command as follows to convert this pb model

!tensorflowjs_converter --input_format=tf_frozen_model --output_node_names='embeddings' ./model/mobile_facenet.pb ./model/web_model

Unfortunately, I got error as follows:
KeyError: 'The name "'embeddings'" refers to an Operation not in the graph.'
I do not know how to solve this problem. Please help me, thank you!

@vladmandic
Copy link

just load model in tfjs-node using loadSavedModel and look at it's signature, then convert it using tensorflowjs_converter

btw, take a look at #71 for some other hinds on tfjs usage of this model.

@shuxiongwuziqi
Copy link
Author

shuxiongwuziqi commented Mar 9, 2021 via email

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

2 participants