Search code examples
pythontensorflowdeep-learningtensorboardtensorflow-lite

How can you identify Input and Output name in tensorboard graph like this one in the pictures attached to this post?


I used the MobileNet_v1_1.0_224 tensorflow model for object detection. Now, I have my custom frozen graph (.pb file) that I need to convert to tflite extension so that I can use my model for mobile devices.

Can someone help me to identify the input and the output names in this tensorboard graph? I need them to use as input and output parameters to convert my frozen graph (.pb file) to tensorflow lite (.tflite) file

graph from tensorboard

same graph


Solution

  • You can use this code:

    import tensorflow as tf
    gf = tf.GraphDef()   
    m_file = open('frozen_inference_graph.pb','rb')
    gf.ParseFromString(m_file.read())
    
    with open('somefile.txt', 'a') as the_file:
        for n in gf.node:
            the_file.write(n.name+'\n')
    
    file = open('somefile.txt','r')
    data = file.readlines()
    print ("\noutput name = ")
    print (data[len(data)-1])
    
    print ("Input name = ")
    file.seek ( 0 )
    print (file.readline())
    

    In my case I had

    output name: SemanticPredictions
    input name: ImageTensor