dengdan / seglink

An Implementation of the seglink alogrithm in paper Detecting Oriented Text in Natural Images by Linking Segments
GNU General Public License v3.0
495 stars 178 forks source link

Different output between .pb and .ckpt file #59

Open YIYANGCAI opened 4 years ago

YIYANGCAI commented 4 years ago

Hello! Thanks for this great work of text detection. I am recently working on a task of text detection and applying this model. the performance on my own data after training is wonderful. However, when I converted my training model of ckpt to pb model, the inference result of pb changes a lot. I cannot find out where the problem is, could you help me to locate my problem?

here is my conversion code from ckpt to pb model:


def freezeGraph(input_checkpoint, output_nodes_names, output_graph):
    '''
    :param input_checkpoint:
    :param output_graph: 
    :return:
    '''
    # checkpoint = tf.train.get_checkpoint_state(model_folder) 
    # input_checkpoint = checkpoint.model_checkpoint_path 

    # 
    output_node_names = output_nodes_names
    saver = tf.train.import_meta_graph(input_checkpoint + '.meta', clear_devices=True)
    graph = tf.get_default_graph() # 
    input_graph_def = graph.as_graph_def()  # 

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

        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__':
    nodes = getOutNodes('./seglink.txt') 
    freezeGraph('./ckpt/model.ckpt-5882', nodes, './pb/seglink.pb')

the seglink.txt is recording the nodes' name of nodes seglink.txt

I wonder if its the problem of conversion

With many thanks if you can offer me some help of this problem!