cv2.dnn.readNetFromTensorflow returns errors when loading .pb and .pbtxt files

asked 2019-02-13 23:13:52 -0500

Chetan_Patil gravatar image

updated 2019-02-14 02:33:15 -0500

berak gravatar image

I have created an Enet in Keras (with two custom layers which are MaxPooling2DWithArgmax and MaxUnpooling2D), i have also ported the keras model (using the custom_objects argument in model.load_model( ) function ) to tensorflow to generate the .pb as well as.pbtxt files. Now, when i load these files into cv2.readNetFromTensorflow it throws me the following error.

error: OpenCV(3.4.3) C:\projects\opencv-python\opencv\modules\dnn\src\tensorflow\tf_importer.cpp:614: error: (-215:Assertion failed) const_layers.insert(std::make_pair(name, li)).second in function 'cv::dnn::experimental_dnn_34_v7::`anonymous-namespace'::addConstNodes'

When i load just the .pb file into the function, it throws me different error which is shown below.

error: OpenCV(3.4.3) C:\projects\opencv-python\opencv\modules\dnn\src\tensorflow\tf_importer.cpp:495: error: (-2:Unspecified error) Input layer not found: zero_padding2d_10/Pad in function 'cv::dnn::experimental_dnn_34_v7::`anonymous-namespace'::TFImporter::connect'

PS: i have tried with the latest version OpenCv(4.0) as well, still the same issues.

edit retag flag offensive close merge delete

Comments

I have exactly the same problem

NadavB gravatar imageNadavB ( 2019-04-01 10:08:26 -0500 )edit