这是indexloc提供的服务,不要输入任何密码
Skip to content

cannot import name 'estimator' from 'tensorflow.compat.v1' #13575

@subodh7591

Description

@subodh7591

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    models:researchmodels that come under research directorytype:bugBug in the code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions