cv::dnn::readNetFromTensorflow errors loading by myself trained model

asked 2018-02-01 04:18:31 -0600

MinxiangLiu gravatar image

I follow TensorFlow Object Detection API and have been trained model. I use ssd_mobilenet_v1_pets.config and revise num_classes, some path. Then I reference Wiki and use tf_text_graph_ssd.py script to generate a text graph representation. Final I try run cvNet = cv.dnn.readNetFromTensorflow("frozen_inference_graph.pb", "graph.pbtxt") ,but result show error: OpenCV Error: Unspecified error (Const input blob for weights not found) in cv::dnn::experimental_dnn_v2::'anonymous-namespace'::TFImporter::getConstBlob, file C:\ci\opencv_1512684736357\work\modules\dnn\src\tensorflow\tf_importer.cpp, line 555 Traceback (most recent call last): File "~\object-detection.py", line 4, in <module> cvNet = cv.dnn.readNetFromTensorflow("frozen_inference_graph.pb", "graph.pbtxt") cv2.error: C:\ci\opencv_1512684736357\work\modules\dnn\src\tensorflow\tf_importer.cpp:555: error: (-2) Const input blob for weights not found in function cv::dnn::experimental_dnn_v2::`anonymous-namespace'::TFImporter::getConstBlob

My trained config file and result link

Any suggestions how to make my model work in OpenCV?

edit retag flag offensive close merge delete

Comments

@MinxiangLiu, Thank you! We've extended the script with batch normalization fusion and Identity nodes skipping. Can you try it?

dkurt gravatar imagedkurt ( 2018-02-01 08:12:31 -0600 )edit

@dkurt, Thank your respond. I try again and cv.dnn.readNetFromTensorflow problem have been solved. But have other error at forward stages. The error : OpenCV Error: Bad argument (PriorBox layer parameter does not contain min_size parameter.) in cv::dnn::PriorBoxLayerImpl::getParameter, file C:\ci\opencv_1512684736357\work\modules\dnn\src\layers\prior_box_layer.cpp, line 87 Traceback (most recent call last): File "D:\Program\PythonCode\tools\tomato-object-detection.py", line 9, in <module> cvOut = cvNet.forward() cv2.error: C:\ci\opencv_1512684736357\work\modules\dnn\src\layers\prior_box_layer.cpp:87: error: (-5) PriorBox layer parameter does not contain min_size parameter. in function cv::dnn::PriorBoxLayerImpl::getParameter

MinxiangLiu gravatar imageMinxiangLiu ( 2018-02-02 04:58:29 -0600 )edit

@MinxiangLiu looks like you need to update a source code.

dkurt gravatar imagedkurt ( 2018-02-02 05:49:43 -0600 )edit

@dkurt, I use Wiki of run the model using OpenCV source code.

MinxiangLiu gravatar imageMinxiangLiu ( 2018-02-02 08:31:34 -0600 )edit

I try to use Wiki of Troubleshooting. I imitate source code of Wiki. I get result here:opt_graph.pb. I run again but error not solve at forward stages.

MinxiangLiu gravatar imageMinxiangLiu ( 2018-02-02 08:33:47 -0600 )edit

Then I try use graph transformation tool and I imitate source code of Wiki. I get result here:opt_graph_trans.pb. But I get error when I run tf_text_graph_ssd.py. The error assert(graph_def.node[0].op == 'Placeholder') AssertionError. So @dkurt, does you have any suggestions?

MinxiangLiu gravatar imageMinxiangLiu ( 2018-02-02 08:35:32 -0600 )edit

@MinxiangLiu I mean your OpenCV source code could should be updated firstly. There is no an assertion at line 87 anymore since https://github.com/opencv/opencv/comm... (Dec 5, 2017). BTW you need to run just a tf_text_graph_ssd.py using frozen_inference_graph.pb. I've tested it already.

dkurt gravatar imagedkurt ( 2018-02-02 09:29:39 -0600 )edit

@dkurt, May I ask your version about Opencv?

MinxiangLiu gravatar imageMinxiangLiu ( 2018-02-03 02:53:25 -0600 )edit

@MinxiangLiu,@dkurt hello ,how do you solve the error "Const input blob for weights not found in function getConstBlob"

xbcreal gravatar imagexbcreal ( 2018-03-02 23:11:29 -0600 )edit