title: Failed to convert tensorflow frozen graph to pbtxt file
body: <p>I want to extract pbtxt file given an input of tensorflow frozen inference graph. In order to do this I am using the below script :</p>
  <pre><code>import tensorflow as tf
  
  #from google.protobuf import text_format
  from tensorflow.python.platform import gfile
  
  def converter(filename): 
    with gfile.FastGFile(filename,'rb') as f:
      graph_def = tf.GraphDef()
      graph_def.ParseFromString(f.read())
      tf.import_graph_def(graph_def, name='')
      tf.train.write_graph(graph_def, 'pbtxt/', 'protobuf.pbtxt', as_text=True)
      print(graph_def)
    return
  
  
  #converter('ssd_mobilenet_v1_coco_2017_11_17/frozen_inference_graph.pb')  # here you can write the name of the file to be converted
  # and then a new file will be made in pbtxt directory.
  
  converter('ssd_mobilenet_v1_coco_2017_11_17/frozen_inference_graph.pb')
  </code></pre>
  <p>As an example, I am using ssd mobilenet architecture. Using the above code I get the output as pbtxt but I cannot use it. For reference see the image below</p>
  <p><a href="https://i.stack.imgur.com/MRfUt.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MRfUt.jpg" alt="enter image description here" /></a></p>
  <blockquote>
  <p>RIGHT: Image of original pbtxt file of mobile-net architecture</p>
  <p>LEFT: Image of pbtxt file obtained by using above script.</p>
  </blockquote>
  <p>When I use The official pbtxt on the RIGHT I get correct results. But, I do not get any prediction when I use LEFT pbtxt which I generated using above script</p>
  <p>I am using these predictions on open cv DNN module</p>
  <pre><code>tensorflowNet = cv2.dnn.readNetFromTensorflow('ssd_mobilenet_v1_coco_2017_11_17/frozen_inference_graph.pb', 'pbtxt/protobuf.pbtxt')
  </code></pre>
  <p>How do I convert mobilenet frozen inference graph into proper pbtxt format so that I can get inference ?</p>
  <p>References:
  <a href="https://gist.github.com/Arafatk/c063bddb9b8d17a037695d748db4f592" rel="nofollow noreferrer">https://gist.github.com/Arafatk/c063bddb9b8d17a037695d748db4f592</a></p>