title: I created protobuf model file in TensorFlow and used it in python with opencv package. Why is this not working?
body: <p>I tried to use .pb and .pbtxt files with the python OpenCV package. But it didn't work. Here is my code,</p>
  <pre><code>import cv2
  
  # Load a model imported from Tensorflow
  tensorflowNet = cv2.dnn.readNetFromTensorflow('saved_model.pb', 'label_map.pbtxt')
  
  # Input image
  img = cv2.imread('image (60).png')
  rows, cols, channels = img.shape
  
  # Use the given image as input, which needs to be blob(s).
  tensorflowNet.setInput(cv2.dnn.blobFromImage(img, size=(640, 640), swapRB=True, crop=False))
  
  # Runs a forward pass to compute the net output
  networkOutput = tensorflowNet.forward()
  
  # Loop on the outputs
  for detection in networkOutput[0, 0]:
  
      score = float(detection[2])
      if score &gt; 0.2:
          left = detection[3] * cols
          top = detection[4] * rows
          right = detection[5] * cols
          bottom = detection[6] * rows
  
          # draw a red rectangle around detected objects
          cv2.rectangle(img, (int(left), int(top)), (int(right), int(bottom)), (0, 0, 255), thickness=2)
  
  # Show the image with a rectagle surrounding the detected objects
  cv2.imshow('Image', img)
  cv2.waitKey()
  cv2.destroyAllWindows()
  </code></pre>
  <p>Here is the error,</p>
  <pre><code>[libprotobuf ERROR D:\a\opencv-python\opencv-python\opencv\3rdparty\protobuf\src\google\protobuf\wire_format_lite.cc:581] String field 'opencv_tensorflow.FunctionDef.Node.ret' contains invalid UTF-8 data when parsing a protocol buffer. Use the 'bytes' type if you intend to send raw bytes. 
  Traceback (most recent call last):
    File &quot;D:\Disk_4\Python Projects\FDAM\main.py&quot;, line 14, in &lt;module&gt;
      tensorflowNet = cv2.dnn.readNetFromTensorflow('saved_model.pb', 'label_map.pbtxt')
  cv2.error: OpenCV(4.6.0) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\tensorflow\tf_io.cpp:42: error: (-2:Unspecified error) FAILED: ReadProtoFromBinaryFile(param_file, param). Failed to parse GraphDef file: saved_model.pb in function 'cv::dnn::ReadTFNetParamsFromBinaryFileOrDie'
  </code></pre>
  <p>I found this code in <a href="https://jeanvitor.com/tensorflow-object-detecion-opencv/" rel="nofollow noreferrer">https://jeanvitor.com/tensorflow-object-detecion-opencv/</a> and changed it with my file names.
  I trained the model and generated this saved_model.pb file in TensorFlow.
  Why is this code not working? please help me. This is my first project with machine learning.</p>