Ask Your Question
0

OpenCV 3.4.1 error readNetFromTensorflow Can't open .pb in cv::dnn::ReadProtoFromBinaryFile

asked 2018-10-11 07:29:40 -0600

kgs gravatar image

I have a problem with opening protobuf file using opencv C++. I use this code:

cv::String weights = "frozen_inference_graph_face.pb";
cv::String pbtxt = "prototxt.pbtxt";
auto graph = cv::dnn::readNetFromTensorflow(weights, pbtxt);

I have this error:

OpenCV(3.4.1) Error: Unspecified error (FAILED: fs.is_open(). Can't open "frozen_inference_graph_face.pb") in cv::dnn::ReadProtoFromBinaryFile, file C:.hunter_Base\acbf4b9\93b3222\8eb84a0\Build\OpenCV\Source\modules\dnn\src\caffe\caffe_io.cpp, line 1126

It works well when I open it with Python code like this and detect image correctly:

cvNet = 
cv.dnn.readNetFromTensorflow('frozen_inference_graph.pb','prototxt.pbtxt')

I have trained ssd_mobilenet_v1_pets. Cannot understand why I cannot open it with my C++ code and the error is refers to cafe, when I use tensorflow. Maybe the configuration of builded OpenCV is wrong? I set WITH_PROTOBUF=ON and BUILD_opencv_dnn=ON.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-10-11 07:33:48 -0600

berak gravatar image

updated 2018-10-13 10:30:39 -0600

the error is from here , and it literally means, what it says !

check the filename / path again, most likely the relative path used there differs from your python situation

(oh, and both opencv's caffe and tf importers use protobuf for serialization, that's why you get the message from caffe_io)

edit flag offensive delete link more

Comments

Yes, thank you , it was because of the path.

kgs gravatar imagekgs ( 2018-10-13 10:20:51 -0600 )edit

what i am doing in heroku? it shows me same error but i can't resolve it in python

Shubhamrock428 gravatar imageShubhamrock428 ( 2018-10-15 12:10:14 -0600 )edit

@Shubhamrock428 - please do NOT post answers here, if you have a question or comment, thank you ...

berak gravatar imageberak ( 2018-10-15 12:12:37 -0600 )edit
soufiane sabiri gravatar imagesoufiane sabiri ( 2019-03-14 12:03:56 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-10-11 07:29:40 -0600

Seen: 7,710 times

Last updated: Oct 13 '18