ImportError: cannot import name 'string_int_label_map_pb2'
Asked Answered
B

2

7

I compiled the files with the following command.

protoc object_detection/protos/*.proto --python_out=.

and as a result compiled into .py files.

However, I received the following error code.

~/Documents/imgmlreport/inception/classification_inception/models/research/object_detection/utils/label_map_util.py in ()

 20 import tensorflow as tf
 21 from google.protobuf import text_format
---> 22 from object_detection.protos import string_int_label_map_pb2
 23 
 24 

ImportError: cannot import name 'string_int_label_map_pb2'

so i checked utils and i already had a string_int_label_map_pb2.py

why can't import string_int_label_map_pb2.py ?

Blakney answered 25/4, 2018 at 4:33 Comment(3)
I have the same error when trying to run the training job in ML ENGINE. I followed the complete instructions given on github.com/tensorflow/models/blob/master/research/…Andromeda
Did you fix this?Anagrammatize
Yup, it definitely works. Follow the complete instructions. ThanksEncaustic
A
2

Are you using a conda environment?

In that case the protoc folder that is pointing is in C:\Users\xx\anaconda3\envs\xx\Lib\site-packages\protos

You should copy the content of protoc from Models\reserach into this one

Awakening answered 16/4, 2021 at 16:52 Comment(0)
M
0

The solution that works for me is as follows:

If you are creating a Virtual environment:

Run the command after you create the environment to change the Google file .protp to .py:

protoc object_detection/protos/*.proto --python_out=.

However, if you are still facing an error, you can simply run the code on a google colab notebook:

Protos Conversion to Python %%cd /content/drive/MyDrive/TFOD1.x/models/research

!protoc object_detection/protos/*.proto --python_out=.

get the file in protoc folder, then copy it into the >models>research>protoc And (import step): Copy the folder to your environment path:

For example:

C:\Users\x04xx18\Anaconda3\envs\tfod1.x\libs\protos

This should fix the error for you!

Mohur answered 29/1, 2023 at 23:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.