2

I trained an object detection model using AutoML Vision which was then exported as a 'saved_model.pb' file. I can load and run this model using the following few lines of code:

import tensorflow as tf    
with tf.Session(graph=tf.Graph()) as sess:
        tf.saved_model.loader.load(sess, ['serve'], export_path)
        output = sess.run("detection_boxes:0", feed_dict= { INPUT_NODE : [<some_image_in_binary>]})

When I try to use OpenCV v4.1.2's function cv::dnn::readNetFromTensorflow("saved_model.pb") to load the same model, it breaks with the message:

[libprotobuf ERROR C:\build\master_winpack-build-win64-vc14\opencv\3rdparty\protobuf\src\google\protobuf\wire_format_lite.cc:629] 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.

I've tried changing the occurrences of 'string' to 'bytes' in saved_model.pb after reading an answer somewhere. In this case, the code breaks with an unhandled exception.

Additionally, if I try to parase the file using tf.gfile.FastGile() it yields google.protobuf.message.DecodeError: Error parsing message

Here's the saved model - Model

Any ideas on how to import this model in OpenCV?

Dhaval
  • 31
  • 3

0 Answers0