【问题标题】:OpenCV - Tensorflow model import errorOpenCV - Tensorflow 模型导入错误
【发布时间】:2018-08-30 11:04:22
【问题描述】:

我使用 ssd_mobilenet_v1_coco 模型和 OpenCV 进行对象检测。

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

使用原始 graph.pbtxt 时可以。 但是当我使用 tf_text_graph_ssd 创建 pbtxt 文件时 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

然后:

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

报错:

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

pb转pbtxt有什么问题?

我的目标是使用图像再训练创建自定义模型并将其用于 OpenCV。 https://www.tensorflow.org/tutorials/image_retraining

所以我有一个自定义模型,但没有 pbtxt 文件。

首先我尝试为示例 ssd_mobilenet_v1_coco 模型创建 pbtxt。

【问题讨论】:

  • 您的问题解决了吗?我有同样的:(

标签: python opencv tensorflow


【解决方案1】:

您还必须指定配置文件。我认为如果你已经使用 tensorflow API 完成了迁移学习,那么你会发现一个名为 pipeline.config 的文件以及 freeze_inference_graph.pb 文件。将该文件用作 --config pipeline.config 以及语法。它应该可以解决问题。

【讨论】:

    【解决方案2】:

    我可以通过以下命令使用 tf_text_graph_ssd.py 创建 pbtxt 文件。

        python tf_text_graph_ssd.py --input=C:\Users\Hp\Desktop\anas\Robomy\tfLearn\cell_inference_graph\frozen_inference_graph.pb --output=C:\Users\Hp\Desktop\anas\Robomy\tfLearn\cell_inference_graph\ssd_mobilenet_v1_balls_2018_05_20.pbtxt --config C:\Users\Hp\Desktop\anas\Robomy\tfLearn\data\ssd_mobilenet_v2_coco.config
    

    这个 pbtxt 在 opencv 上完美运行

    【讨论】:

      猜你喜欢
      • 2017-08-30
      • 2021-10-20
      • 2017-09-17
      • 1970-01-01
      • 1970-01-01
      • 2018-03-16
      • 2018-11-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多