How do I load a TF Saved Model from AutoML for inference?

asked 2020-03-11 12:10:32 -0500

DhavalNiphade gravatar image

updated 2020-03-12 08:44:50 -0500

  • OpenCV => 4.1.2
  • Operating System / Platform => Windows 64 Bit
  • Compiler => Visual Studio 2017

I've exported a TF SavedModel (a '.pb' file) for object detection via AutoML for edge devices that I can load and test through TensorFlow for inference. However, when I try to load it using OpenCV, it yields the following error:

OpenCV(4.1.2) Error: Unspecified error (FAILED: ReadProtoFromBinaryFile(param_file, param). Failed to parse GraphDef file: D:\\model3.pb) in cv::dnn::ReadTFNetParamsFromBinaryFileOrDie, file C:\build\master_winpack-build-win64-vc15\opencv\modules\dnn\src\tensorflow\tf_io.cpp, line 42

I've tried the solution presented in 11805 but it breaks with:

File ".\", line 83, in main input_graph_def.ParseFromString(data) google.protobuf.message.DecodeError: Error parsing message

The same error pops up when I try any of scripts from TensorFlow Object Detection API Wiki

Minimum code to reproduce the error

`#include <opencv2/dnn.hpp>` `#include <opencv2/imgproc.hpp>` `#include <opencv2/opencv.hpp>` cv::dnn::Net net = cv::dnn::readNetFromTensorflow("saved_model.pb");

edit retag flag offensive close merge delete


I cannot download your model :

    [libprotobuf ERROR G:\Lib\opencv\3rdparty\protobuf\src\google\protobuf\] 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 "<stdin>", line 1, in <module>
cv2.error: OpenCV(4.2.0-dev) G:\Lib\opencv\modules\dnn\src\tensorflow\tf_io.cpp:42: error: (-2:Unspecified error) FAILED: ReadProtoFromBinaryFile(param_file, param). Failed to parse GraphDef file: C:\Users\Laurent\Downloads\saved_model.pb in function 'cv::dnn::ReadTFNetParamsFromBinaryFileOrDie'
LBerger gravatar imageLBerger ( 2020-03-12 03:35:05 -0500 )edit

Something is wrong. is AutoML compatible with opencv? @dkurt

LBerger gravatar imageLBerger ( 2020-03-12 03:37:07 -0500 )edit

@LBerger - Changed its properties. Are you still unable to download?

DhavalNiphade gravatar imageDhavalNiphade ( 2020-03-12 08:47:12 -0500 )edit