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 to pb model file and using libtensorflow to interface #11

Closed
wolf943134497 opened this issue May 26, 2021 · 0 comments
Closed

Comments

@wolf943134497
Copy link

Hi @tcies Thanks for your great works!
I want to use your pretrained model in libtensorflow, because I need to use c++ api. I convert your checkpoint files to pb model file using freeze_graph.py scipts, but the pb model can not use in libtensorflow , because I found the pb files only left 1 opts (vgg16_netvlad_pca/WPCA/kernel). my code are as follows:

def freeze_graph(input_checkpoint,output_graph):
output_node_names = "vgg16_netvlad_pca/WPCA/kernel"
saver = tf.train.import_meta_graph(input_checkpoint + '.meta', clear_devices=True)

with tf.Session() as sess:
    saver.restore(sess, input_checkpoint) 
    output_graph_def = graph_util.convert_variables_to_constants(  
        sess=sess,
        input_graph_def=sess.graph_def,
        output_node_names=output_node_names.split(","))

    with tf.gfile.GFile(output_graph, "wb") as f: 
        f.write(output_graph_def.SerializeToString()) 
    print("%d ops in the final graph." % len(output_graph_def.node)) 

if name == "main":
input_checkpoint='netvlad/vd16_pitts30k_conv5_3_vlad_preL2_intra_white'
out_pb_path="./frozen_model.pb"
freeze_graph(input_checkpoint,out_pb_path)

any suggestions?
thanks!

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

1 participant