cannot import name 'estimator' from 'tensorflow.compat.v1'
Prerequisites
Please answer the following questions for yourself before submitting an issue.
- [ yes] I am using the latest TensorFlow Model Garden release and TensorFlow 2.
- [ Yes] I am reporting the issue to the correct repository. (Model Garden official or research directory)
- [Yes ] I checked to make sure that this issue has not been filed already.
1. The entire URL of the file you are using
https://github.com/tensorflow/models/tree/master/research/object_detection
2. Describe the bug
I am using tensorflow 2.19 and latest version of the object detection api. While training the models it raises error estimator cannot import name estimator from tensorflow.compat.v1. I found that the last support for the estimator from tensorflow.comapt.v1 was in tensorflow==2.15. I tried downgrading to 2.15 which solves this issue but raises other issues.
3. Steps to reproduce
command = [ "python", "models/research/object_detection/model_main_tf2.py", f"--model_dir={checkpoint_path}", f"--pipeline_config_path={pipeline_config_path}", "--num_train_steps=10000", "--sample_1_of_n_eval_examples=1", "--alsologtostderr" ]
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
4. Expected behavior
It should have trained the model without raising error.
5. Additional context
Traceback (most recent call last):
File "/mnt/d/computer vision code/models/research/object_detection/model_main_tf2.py", line 31, in
❌ Training failed for ssd_mobilenet
6. System information
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
- Mobile device name if the issue happens on a mobile device:
- TensorFlow installed from (source or binary):
- TensorFlow version (use command below):
- Python version:
- Bazel version (if compiling from source):
- GCC/Compiler version (if compiling from source):
- CUDA/cuDNN version:
- GPU model and memory:
same issue
Switch to newer frameworks? Or research through the web.
Switch to newer frameworks? Or research through the web.
in my case, i want to train image with ssdmobilenetv2. The framework library was deprecated in google collabs environment. cause it's only work in python 10 but gc env has updated into python 11, and if it can running we can't use GPU for it.
I've trained this network several years before with TF 1.15. The installation was a bit tricky, but with information from issues, youtube etc. I managed to create a running setup.
I wouldn't use the provided google colabs from TensorFlow team, instead use directly the python scripts. I used Python 3.7 or 3.8 with TF 1.15 and it worked fine.