rpautrat / SuperPoint

Efficient neural feature detector and descriptor
MIT License
1.89k stars 417 forks source link

Unable to load the pre-trained model using tensorflow #260

Open yrq0208 opened 2 years ago

yrq0208 commented 2 years ago

Hi, I have been trying to load the pre-trained model provided in the pretrained_models folder, but each time when I try to load the saved_model.pb file, I encountered the "Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary" error, After some googling I was told that this is because the version that is used to save the model is not the same as the one I used to load it, but I am already using tensorflow-gpu 1.12 so this seems a bit strange to me, can anyone shed some lights on this?

here is the python code I used to load the pretained model, for now it works with models from other NN, but it does not work with superpoint,

import tensorflow as tf import sys from tensorflow.python.platform import gfile from tensorflow.core.protobuf import saved_model_pb2 from tensorflow.python.util import compat

GRAPH_PB_PATH = '/home/ruiqi/SuperPoint/pretrained_models/sp_v6/saved_model.pb' # Sets the directory of the .pb file. with tf.Session(graph=tf.Graph()) as sess: print("load graph")

tf.saved_model.loader.load(sess, ['saved_model'], GRAPH_PB_PATH)

#graph = tf.get_default_graph()
#print(graph.get_operations())
with gfile.FastGFile(GRAPH_PB_PATH, 'rb') as f:
    data = compat.as_bytes(f.read())
    sm = saved_model_pb2.SavedModel()
    sm.ParseFromString(data)
    g_in = tf.import_graph_def(sm.meta_graphs[0].graph_def)
    #graph_def = tf.GraphDef()
    #graph_def.ParseFromString(f.read())
    #tf.import_graph_def(graph_def, name='')
    for i, node in enumerate(sm.meta_graphs[0].graph_def.node):
        print("Name of the node : %s" % node.name)
rpautrat commented 2 years ago

Hi, the released model was trained with an even older version of tensorflow I think. I do not remember exactly which one, but probably one around TF 1.7. Maybe you could try with that version?

yrq0208 commented 2 years ago

Hi @rpautrat, thank for the reply. I tried TF 1.7, and I encountered a new error "ValueError: No op named NonMaxSuppressionV3 in defined operations", and I was told NonMaxSuppressionV3 is not introduced until TF 1.8? So then I tried TF 1.8 and I am back to "Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary". It seems to be just some kind of TF version issue flying around here, which I am quite confuse. But still thanks for your help!