How to resolve the error "cannot import name 'string_int_label_map_pb2' from 'object_detection.protos'"

Question:

My friends and I are partaking in a hackathon and are stuck on this one tutorial on training an object detection model:

https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html

But after three people have tried to follow the above tutorial to the letter, we are all stuck on the creating TfRecord step:

https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html#create-tensorflow-records

We get the error message:

ImportError: cannot import name ‘string_int_label_map_pb2’ from ‘object_detection.protos’

We are three different people, with three different machines, getting this result, and have spent in total 20+ person-hours googling, retrying, sacrificing things to eldritch gods and nothing gets us passed this hurdle.

Is there a better way of achieving the result, or a fix for the issue? We are inexperienced with Tensorflow and are just wanting to use it to train a model that can be converted to an onnx model that will be consumed by ml.net.

Asked By: Frank R. Haugen

||

Answers:

Thanks to @EdwinCheong for pointing us in the correct direction.

The issue was resolved by basically downloading the Windows 10 SDK and a bunch of c++ -related packages in the Visual Studio Installer before following this linked tutorial:
https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html#tf-models-install related to installing object detection. CUDA seems to be required regardless of what the tutorial says

Answered By: Frank R. Haugen

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:Usersx04xx18Anaconda3envstfod1.xlibsprotos

This should fix the error for you!

Answered By: Ramy AbdAllah