ImportError: cannot import name 'eval_pb2' from 'object_detection.protos'
@laxmareddyp 已经在做这个了。
开始于 2024年2月23日。
评估
这个 Issue 还没有评估数据。
描述
Prerequisites
Please answer the following questions for yourself before submitting an issue.
- I am using the latest TensorFlow Model Garden release and TensorFlow 2.
- I am reporting the issue to the correct repository. (Model Garden official or research directory)
- 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
2. Describe the bug
ImportError Traceback (most recent call last)
Cell In[27], line 3
1 import tensorflow as tf
2 from google.protobuf import text_format
----> 3 from object_detection.utils import config_util
4 from object_detection.protos import pipeline_pb2
File ~\anaconda3\Lib\site-packages\object_detection\utils\config_util.py:24
20 from google.protobuf import text_format
22 from tensorflow.python.lib.io import file_io
---> 24 from object_detection.protos import eval_pb2
25 from object_detection.protos import graph_rewriter_pb2
26 from object_detection.protos import input_reader_pb2
ImportError: cannot import name 'eval_pb2' from 'object_detection.protos' (C:\Users\RAVI\anaconda3\Lib\site-packages\object_detection\protos_init_.py)
3. Steps to reproduce
WORKSPACE_PATH = 'Tensorflow/workspace'
SCRIPTS_PATH = 'Tensorflow/scripts'
APIMODEL_PATH = 'Tensorflow/models'
ANNOTATION_PATH = WORKSPACE_PATH+'/annotations'
IMAGE_PATH = WORKSPACE_PATH+'/images'
MODEL_PATH = WORKSPACE_PATH+'/models'
PRETRAINED_MODEL_PATH = WORKSPACE_PATH+'/pre-trained-models'
CONFIG_PATH = MODEL_PATH+'/my_ssd_mobnet/pipeline.config'
CHECKPOINT_PATH = MODEL_PATH+'/my_ssd_mobnet/'
-
Create Label Map
labels = [{'name':'Hello', 'id':1},
{'name':'Yes', 'id':2},
{'name':'No', 'id':3},
{'name':'Thanks', 'id':4},
{'name':'I Love You', 'id':5},
]
with open(ANNOTATION_PATH + '\label_map.pbtxt', 'w') as f:
for label in labels:
f.write('item { \n')
f.write('\tname:'{}'\n'.format(label['name']))
f.write('\tid:{}\n'.format(label['id']))
f.write('}\n') -
Create TF records
import os
def create_tf_record(image_dir, annotation_path, output_path):
os.system(f"python {SCRIPTS_PATH}/generate_tfrecord.py -x {image_dir} -l {annotation_path}/label_map.pbtxt -o {output_path}")
print(f"Successfully created the TFRecord file: {output_path}")
Example usage:
train_image_dir = os.path.join(IMAGE_PATH, 'train')
test_image_dir = os.path.join(IMAGE_PATH, 'test')
train_output_path = os.path.join(ANNOTATION_PATH, 'train.record')
test_output_path = os.path.join(ANNOTATION_PATH, 'test.record')
create_tf_record(train_image_dir, ANNOTATION_PATH, train_output_path)
create_tf_record(test_image_dir, ANNOTATION_PATH, test_output_path)
import os
import urllib.request
import tarfile
def download_pretrained_model(model_name, model_dir):
model_url = f'http://download.tensorflow.org/models/object_detection/tf2/20200711/{model_name}.tar.gz'
model_path = os.path.join(model_dir, f"{model_name}.tar.gz")
# Download the model
urllib.request.urlretrieve(model_url, model_path)
# Extract the downloaded file
with tarfile.open(model_path, 'r:gz') as tar:
tar.extractall(model_dir)
# Remove the compressed file
os.remove(model_path)
print(f"Download and extraction of {model_name} complete.")
Example usage:
pretrained_model_name = 'ssd_mobilenet_v2_fpnlite_320x320_coco17_tpu-8'
PRETRAINED_MODEL_PATH = 'Tensorflow/workspace/pre-trained-models' # Assuming this is your predefined path
download_pretrained_model(pretrained_model_name, PRETRAINED_MODEL_PATH)
-
Copy Model Config to Training Folder
CUSTOM_MODEL_NAME = 'my_ssd_mobnet'
!mkdir {'Tensorflow\workspace\models\'+CUSTOM_MODEL_NAME} -
Update Config For Transfer Learning
import tensorflow as tf
from google.protobuf import text_format
from object_detection.utils import config_util
from object_detection.protos import pipeline_pb2
4. Expected behavior
Expected Behavior:
I expected to import the config_util module from object_detection.utils without encountering an ImportError.
Context:
I am working on setting up an object detection pipeline using TensorFlow Object Detection API version 2.15.0
5. Additional context
ImportError: cannot import name 'eval_pb2' from 'object_detection.protos' (C:\Users\RAVI\anaconda3\Lib\site-packages\object_detection\protos_init_.py)
6. System information
-
OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 11
-
Mobile device name if the issue happens on a mobile device:
-
TensorFlow installed from (source or binary): Official website
-
TensorFlow version (use command below): v2.15.0-rc1-8-g6887368d6d4 2.15.0
-
Python version: 3.8.0
-
Bazel version (if compiling from source):
-
GCC/Compiler version (if compiling from source):
-
CUDA/cuDNN version: CUDA Toolkit v11.2 / CuDNN 8.1.0
-
GPU model and memory: AMD Radeon(TM) Graphics
Collect system information using our environment capture script.
https://github.com/tensorflow/tensorflow/tree/master/tools/tf_env_collect.sh
You can also obtain the TensorFlow version with:
- TensorFlow 2.0
python -c "import tensorflow as tf; print(tf.version.GIT_VERSION, tf.version.VERSION)"
--> v2.15.0-rc1-8-g6887368d6d4 2.15.0
- 主要语言
- Python
- 星标
- 77.6k
- 派生
- 44.8k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
tensorflow/models 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 72/100
tensorflow/models#13653 ·
-
object_detection_tutorial.ipynb pretrained model "resnet50 imagenet"可能重新可做 @laxmareddyp 于 202 天前认领,目前没有进行中的 PR。 未关闭type:support
tensorflow/models#13634 · 2 条评论 · 1 个 reaction · 已指派 1 人 ·
-
Tag version compatible with Tensorflow 2.20可能重新可做 @bharatjetti 于 277 天前认领,目前没有进行中的 PR。 未关闭models:official type:bug
tensorflow/models#13607 · 1 条评论 · 已指派 1 人 ·
-
models:research type:feature
难度 5/5 一周以上 新手友好度 10/100
tensorflow/models#13600 ·
-
Installation Issues on Python 3.13可能重新可做 @bharatjetti 于 246 天前认领,目前没有进行中的 PR。 未关闭models:official type:bug
tensorflow/models#13587 · 9 条评论 · 已指派 1 人 ·
查看 tensorflow/models 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
bytedance/agentkit-samples#277 ·
-
ai-driven-fuzzing bug claude Minor
难度 2/5 1-3 小时 新手友好度 83/100
维护者通常 2 天内回复
-
channels:edit check:passed
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
aws-samples/sample-aws-genai-db-modernizer#2097 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复