cv::dnn::readNetFromTensorflow errors loading by myself trained model
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?
@MinxiangLiu, Thank you! We've extended the script with batch normalization fusion and Identity nodes skipping. Can you try it?
@dkurt, Thank your respond. I try again and
cv.dnn.readNetFromTensorflow
problem have been solved. But have other error atforward
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 looks like you need to update a source code.
@dkurt, I use Wiki of
run the model using OpenCV
source code.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 atforward
stages.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 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
usingfrozen_inference_graph.pb
. I've tested it already.@dkurt, May I ask your version about Opencv?
@MinxiangLiu,@dkurt hello ,how do you solve the error "Const input blob for weights not found in function getConstBlob"