【问题标题】:How to use SSD Mobilenet model created using Tensorflow 2.2 in OpenCV 4.4?如何在 OpenCV 4.4 中使用使用 Tensorflow 2.2 创建的 SSD Mobilenet 模型?
【发布时间】:2021-02-02 08:18:29
【问题描述】:

我使用 Tensorflow 2 创建了一个自定义对象检测 ssd mobilenet 模型。我按照以下步骤操作https://github.com/abhimanyu1990/SSD-Mobilenet-Custom-Object-Detector-Model-using-Tensorflow-2。该模型在 Tensorflow 2 上运行良好。

由于我们需要创建冻结模型的文本图形表示以与 opencv 一起使用,我点击此链接 https://github.com/opencv/opencv/wiki/TensorFlow-Object-Detection-API 并使用 tf_text_graph_ssd.py 生成配置文件,以便我可以将它与 OpenCV 一起使用。运行此脚本时出现以下错误 `

Traceback (most recent call last):
  File "/home/phoenix/Documents/repos/python/tensorflow_model/tf_text_graph_common.py", line 313, in writeTextGraph
    cv.dnn.writeTextGraph(modelPath, outputPath)
cv2.error: OpenCV(4.4.0) /tmp/pip-req-build-6amqbhlx/opencv/modules/dnn/src/tensorflow/tf_io.cpp:42: error: (-2:Unspecified error) FAILED: ReadProtoFromBinaryFile(param_file, param). Failed to parse GraphDef file: exported-model/mobile-model/saved_model/saved_model.pb in function 'ReadTFNetParamsFromBinaryFileOrDie'


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "tf_text_graph_ssd.py", line 405, in <module>
    createSSDGraph(args.input, args.config, args.output)
  File "tf_text_graph_ssd.py", line 128, in createSSDGraph
    writeTextGraph(modelPath, outputPath, outNames)
  File "/home/phoenix/Documents/repos/python/tensorflow_model/tf_text_graph_common.py", line 316, in writeTextGraph
    from tensorflow.tools.graph_transforms import TransformGraph
ModuleNotFoundError: No module named 'tensorflow.tools.graph_transforms'

谢谢!

【问题讨论】:

    标签: tensorflow opencv


    【解决方案1】:

    看起来from tensorflow.tools.graph_transforms import TransformGraph 已在 TF 2.x 中删除。替代方法是使用 Grappler。 这个问题https://github.com/tensorflow/tensorflow/issues/43688 可能会有所帮助。谢谢!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-23
      • 1970-01-01
      • 2021-10-14
      • 2021-04-27
      • 1970-01-01
      • 2019-10-02
      • 2019-08-05
      • 1970-01-01
      相关资源
      最近更新 更多