how to read a neural network model with openCV

Viewed 4097

I am using cv2.dnn.readNet to use a neural network model for text detection in an image. it takes the following error and I don't have any idea what it is saying.

here's my pice of code:

nn = cv2.dnn.readNet('frozen_east_text_detection.pb')

The error is:

error: OpenCV(4.1.2) /io/opencv/modules/dnn/src/tensorflow/tf_io.cpp:42: error: (-2:Unspecified error) FAILED: ReadProtoFromBinaryFile(param_file, param). Failed to parse GraphDef file: frozen_east_text_detection.pb in function 'ReadTFNetParamsFromBinaryFileOrDie'

I should say Im writing at google colab, thank u...

1 Answers

The first thing I would try is making sure your path is correct. Is the frozen_east_text_detection.pb in the same folder or place as your python script? Try adding the full path into the function, while also adding r the beginning of your path, as to tell python that you aren't using escape characters. If so, I would also change your first statement to the one below.

nn = cv2.dnn.readNet("frozen_east_text_detection.pb")

However, if this still does not work, my guess is that the file you are using is corrupted in someway, and would recommend trying to find another spot to download that file from. From my research that file is apart of a project or tutorial, so finding another copy shouldn't be to difficult.

Related