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

Viewed 9341

I am following a Real time object detection on https://automaticaddison.com/real-time-object-recognition-using-a-webcam-and-deep-learning/#top and I have hit a road block I followed all the instructions and checked for any errors but still got this error (I am using 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'

I used pip install --ignore-installed --upgrade tensorflow==1.9 just what the link above said and whilst running I got these packages and their versions and an error hope it would be relevant to the question

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

1 Answers

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 and earlier do not have compat module. To use it you need TF 1.10+. Its better to use conda install everywhere possible with conda virtual enviroment.

Also since you are using tensorflow models make sure you has corresponding version of repository, for example latest TF1.x version located here

Related