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 ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
tensorflow/models のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
tensorflow/models#13653 ·
-
object_detection_tutorial.ipynb pretrained model "resnet50 imagenet"再び着手できるかも @laxmareddyp が 202 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンtype:support
tensorflow/models#13634 · コメント 2 件 · リアクション 1 件 · 担当者 1 名 ·
-
Tag version compatible with Tensorflow 2.20再び着手できるかも @bharatjetti が 276 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンmodels:official type:bug
tensorflow/models#13607 · コメント 1 件 · 担当者 1 名 ·
-
models:research type:feature
難易度 5/5 1週間以上 初心者へのやさしさ 10/100
tensorflow/models#13600 ·
-
Installation Issues on Python 3.13再び着手できるかも @bharatjetti が 245 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンmodels:official type:bug
tensorflow/models#13587 · コメント 9 件 · 担当者 1 名 ·
tensorflow/models の issue をすべて見る
似ている issue
-
`destroy` sans terminal répond « Aborted. » au lieu de réclamer `--yes` comme `clean` et `reset`オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
stephrobert/dsoxlab#354 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
jasonacox/pypowerwall#472 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: DoubleMLRDDData accepts a score_col that is no data column (as in its docstring example); the running variable then becomes a covariate and RDFlex fails対応中かも @vrjdev が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
DoubleML/doubleml-for-py#455 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: Python mod.Box[T] annotation gets a false generic_arg edge that replaces the parameter_type one ('is' on tree-sitter nodes)対応中かも @rohit-jsfreaky が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
Graphify-Labs/graphify#5110 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
assafelovic/gpt-researcher#2277 ·
メンテナーはふだん 10 日以内に返信