首页 > 解决方案 > TensorFlow 对象检测:model_main.py 和 train.py 都不再起作用

问题描述

火车.py

Traceback (most recent call last):
  File "object_detection/legacy/train.py", line 48, in <module>
    from tensorflow.contrib import framework as contrib_framework
ModuleNotFoundError: No module named 'tensorflow.contrib'

module_main.py

    Traceback (most recent call last):
  File "object_detection/model_main.py", line 26, in <module>
    from object_detection import model_lib
  File "/content/models/research/object_detection/model_lib.py", line 27, in <module>
    from object_detection import eval_util
  File "/content/models/research/object_detection/eval_util.py", line 40, in <module>
    slim = tf.contrib.slim
AttributeError: module 'tensorflow' has no attribute 'contrib'

由于同样的错误,我什至无法将我的模型从检查点导出到推理图。

export_inference_graph.py

Traceback (most recent call last):
  File "object_detection/export_inference_graph.py", line 108, in <module>
    from object_detection import exporter
  File "/content/models/research/object_detection/exporter.py", line 20, in <module>
    from tensorflow.contrib.quantize.python import graph_matcher
ModuleNotFoundError: No module named 'tensorflow.contrib'

直到今天,所有三个文件都运行良好。培训使用 TF 1.15 和 2.1.0。我将 Colab 与 Python 3.6 和 GPU 训练一起使用。我最近在 tensorflow 的 github repo 中也找不到任何实质性的变化。

有什么想法吗?

标签: tensorflowobject-detection

解决方案


推荐阅读