实时对象检测没有名为 'tensorflow.compat.v1' 的模块

realtime object detection No module named 'tensorflow.compat.v1'

我正在关注 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:\Usersrock\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 上面 link 所说的,同时 运行 我得到了这些包及其版本和一个错误希望它与问题相关

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>=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

I used pip install --ignore-installed --upgrade tensorflow==1.9

line 27, in 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 make sure you has corresponding version of repository, for example latest TF1.x version located here