【问题标题】:realtime object detection No module named 'tensorflow.compat.v1'实时对象检测没有名为“tensorflow.compat.v1”的模块
【发布时间】:2021-04-06 15:48:43
【问题描述】:

我正在关注https://automaticaddison.com/real-time-object-recognition-using-a-webcam-and-deep-learning/#top 上的实时对象检测,但遇到了障碍 (我用的是windows)

 Traceback (most recent call last):   File "object_detection_test.py",
 line 15, in <module>
     from utils import label_map_util   File "C:\Users\1rock\Documents\TensorFlow\models\research\object_detection\utils\label_map_util.py",
 line 27, in <module>
     import tensorflow.compat.v1 as tf ModuleNotFoundError: No module named 'tensorflow.compat.v1'

我使用pip install --ignore-installed --upgrade tensorflow==1.9 就像上面的链接所说的那样,在运行时我得到了这些包及其版本和一个错误,希望它与问题相关

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.

ipywidgets 7.6.0 requires jupyterlab-widgets&gt;=1.0.0, which is not installed.

Successfully installed absl-py-0.11.0 astor-0.8.1 gast-0.4.0 grpcio-1.34.0 importlib-metadata-3.3.0 markdown-3.3.3 numpy-1.19.4 protobuf-3.14.0 setuptools-51.0.0.post20201207 six-1.15.0 tensorboard-1.9.0 tensorflow-1.9.0 termcolor-1.1.0 typing-extensions-3.7.4.3 werkzeug-1.0.1 wheel-0.36.2 zipp-3.4.0

【问题讨论】:

  • 可以分享print(tensorflow.__version__)的输出吗?
  • 嗨,每当我在控制台上输入print(tensorflow.__version__) 时,我都会收到Unable to initialize device PRN
  • 我查看了一个可能的修复程序,激活了 conda env,然后将目录更改为 tensorflow 文件夹,但仍然收到 Unable to initialize device PRN
  • 但根据我关注的网站是 tensorflow==1.9
  • 用python做。启动python然后执行print(tensorflow.__version__)

标签: python tensorflow object-detection


【解决方案1】:

我使用了 pip install --ignore-installed --upgrade tensorflow==1.9

第 27 行,在 import tensorflow.compat.v1 as tf ModuleNotFoundError: No module named 'tensorflow.compat.v1'

TF 1.9 及更早版本没有compat 模块。要使用它,您需要 TF 1.10+。最好在 conda 虚拟环境中尽可能使用 conda install。

另外,由于您使用的是tensorflow models,请确保您有相应版本的存储库,例如最新的 TF1.x 版本位于 here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-06-30
    • 1970-01-01
    • 1970-01-01
    • 2021-02-11
    • 1970-01-01
    • 2020-12-18
    • 1970-01-01
    相关资源
    最近更新 更多