I'm doing an object detection project on the raspi-5 and i run this code on the cmd line
python Tensorflow/models/research/object_detection/model_main_tf2.py --model_dir=Tensorflow/workspace/models/my_ssd_mobnet --pipeline_config_path=Tensorflow/workspace/models/my_ssd_mobnet/pipeline.config --num_train_steps=5000
However, I encounter this error: pi@pi:~/Desktop/RealTimeObjectDetection $ python Tensorflow/models/research/object_detection/model_main_tf2.py --model_dir=Tensorflow/workspace/models/my_ssd_mobnet --pipeline_config_path=Tensorflow/workspace/models/my_ssd_mobnet/pipeline.config --num_train_steps=5000 Traceback (most recent call last): File "/home/pi/Desktop/RealTimeObjectDetection/Tensorflow/models/research/object_detection/model_main_tf2.py", line 31, in from object_detection import model_lib_v2 File "/usr/local/lib/python3.11/dist-packages/object_detection-0.1-py3.11.egg/object_detection/model_lib_v2.py", line 29, in from object_detection import inputs File "/usr/local/lib/python3.11/dist-packages/object_detection-0.1-py3.11.egg/object_detection/inputs.py", line 24, in from tensorflow.compat.v1 import estimator as tf_estimator ImportError: **cannot import name 'estimator' from 'tensorflow.compat.v1' **(/usr/local/lib/python3.11/dist-packages/tensorflow/_api/v2/compat/v1/init.py)
Need some advice on what to do to fix it
I tried downgrading the version for Tensorflow
Name: tensorflow Version: 2.15.0 Summary: TensorFlow is an open source machine learning framework for everyone. Home-page: https://www.tensorflow.org/ Author: Google Inc. Author-email: [email protected] License: Apache 2.0 Location: /home/pi/.local/lib/python3.11/site-packages Requires: tensorflow-cpu-aws Required-by: tf-models-official
and im running on Python 3.11
This is not my answer but it worked for me.
Recently, Google Colab updated its TensorFlow version from 2.15.0 to 2.16.1. Try reinstalling TensorFlow using the following commands:
!pip uninstall tensorflow --y
!pip install tensorflow==2.15.0
then restart runtime when asked in colab. You should be able to import the correct version of TensorFlow.
Source = https://github.com/tensorflow/tensorflow/issues/63618