Skip to content

convert pb model to tensorflow.js model #76

@shuxiongwuziqi

Description

@shuxiongwuziqi

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions