12

I have a custom tensorflow model .pb file. I want to import that in OpenCV using the dnn module. dnn module function requires 2 parameters: .pb file and .pbtxt file? How can I generate .pbtxt file from the .pb file?

cvNet = cv2.dnn.readNetFromTensorflow('FrozenMaster.pb', 'graph.pbtxt')

How to get this graph.pbtxt file?

vezunchik
  • 3,669
  • 3
  • 16
  • 25
hgarg
  • 129
  • 1
  • 3
  • Where did you get the .pb file from? If you made it yourself, what version of TensorFlow are you using? – Sagar Patil Jun 16 '20 at 19:03
  • Check [this](https://github.com/opencv/opencv/issues/16879) issue out for creating frozen_inference_graph.pb from a saved_model.pb. – Isaac Padberg Jan 26 '22 at 20:31

1 Answers1

4
import cv2 
cv2.dnn.writeTextGraph('FrozenMaster.pb', 'graph.pbtxt')

Moreover the following link of opencv github might as well be useful https://github.com/opencv/opencv/wiki/TensorFlow-Object-Detection-API

prixi
  • 59
  • 1
  • 3