tensorflow / tensorflow/models
cannot import name 'estimator' from 'tensorflow.compat.v1'
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.7k
- Forks
- 44.8k
- PR merge metrics
- No merged PRs in 30d
Description
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
from object_detection import model_lib_v2
File "/mnt/d/computer vision code/models/research/object_detection/model_lib_v2.py", line 30, in
from object_detection import inputs
File "/mnt/d/computer vision code/models/research/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' (/home/administrator/miniconda3/envs/object/lib/python3.10/site-packages/tensorflow/_api/v2/compat/v1/init.py)
❌ 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:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with research/object_detection/inputs.py and the import traceback, then run models/research/object_detection/model_main_tf2.py with the reported pipeline and checkpoint arguments under TensorFlow 2.19. Check how the TensorFlow estimator dependency is handled and verify that training starts without the ImportError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, tensorflow
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100