sirius-ai / MobileFaceNet_TF

Tensorflow implementation for MobileFaceNet
Apache License 2.0
433 stars 169 forks source link

convert pb model to tensorflow.js model #76

Open shuxiongwuziqi opened 3 years ago

shuxiongwuziqi commented 3 years ago

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 commented 3 years ago

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 https://github.com/sirius-ai/MobileFaceNet_TF/issues/71 for some other hinds on tfjs usage of this model.

shuxiongwuziqi commented 3 years ago

Get it. Thank you very much!

------------------ Original message ------------------ From: "Vladimir Mandic"; Sendtime: Monday, Mar 8, 2021 11:16 PM To: "sirius-ai/MobileFaceNet_TF"; Cc: "吴梓祺"1306557901@qq.com; "Author"; Subject: Re: [sirius-ai/MobileFaceNet_TF] convert pb model to tensorflow.js model (#76)

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.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.