Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV - Tensorflow model import error

I use ssd_mobilenet_v1_coco model with OpenCV for object detection.

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

When using original graph.pbtxt it is OK. But when i create pbtxt file using tf_text_graph_ssd https://github.com/opencv/opencv/blob/master/samples/dnn/tf_text_graph_ssd.py

python tf_text_graph_ssd.py --input frozen_inference_graph.pb --output pbtxt/frozen_inference_graph.pbtxt

and then:

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

it gives error:

OpenCV Error: Unspecified error (Input layer not found: 

FeatureExtractor/MobilenetV1/zeros) in 
cv::dnn::experimental_dnn_v3::`anonymous-
namespace'::TFImporter::populateNet, file C:
\projects\opencv-python\opencv\modules\dnn\src\tensorflow\tf_importer.cpp, 
line 1061
Traceback (most recent call last):
File "opencv_tensorflow.py", line 3, in <module>
cvNet = cv.dnn.readNetFromTensorflow('frozen_inference_graph.pb', 
'pbtxt/frozen_inference_graph.pbtxt')
cv2.error: C:\projects\opencv-
python\opencv\modules\dnn\src\tensorflow\tf_importer.cpp:1061: error: (-2) 
Input layer not found: FeatureExtractor/MobilenetV1/zeros in function cv::d
nn::experimental_dnn_v3::`anonymous-namespace'::TFImporter::populateNet

What is the problem when converting pb to pbtxt?

Here my aim is create custom model using image retraining and use it on OpenCV. https://www.tensorflow.org/tutorials/image_retraining

So I have a custom model but not pbtxt file.

First i try to create pbtxt for an example ssd_mobilenet_v1_coco model.