ImportError: cannot import name 'string_int_label_map_pb2' from 'object_detection.protos' (/usr/local/lib/python3.10/dist-packages/object_detection/protos/__init__.py)

Hello I want to try

that example at Colab but

3. Set Up Training Configuration

Set file locations and get number of classes for config file

pipeline_fname = ‘/content/models/mymodel/’ + base_pipeline_file
fine_tune_checkpoint = ‘/content/models/mymodel/’ + model_name + ‘/model.ckpt’

def get_num_classes(pbtxt_fname):
from object_detection.utils import label_map_util
label_map = label_map_util.load_labelmap(pbtxt_fname)
categories = label_map_util.convert_label_map_to_categories(
label_map, max_num_classes=90, use_display_name=True)
category_index = label_map_util.create_category_index(categories)
return len(category_index.keys())
num_classes = get_num_classes(label_map_pbtxt_fname)
print(‘Total classes:’, num_classes)

that code not run throw exception at below:

ImportError: cannot import name ‘string_int_label_map_pb2’ from ‘object_detection.protos’ (/usr/local/lib/python3.10/dist-packages/object_detection/protos/init.py)

how can I fix please could you help me?

Hi @Beyza_BOZ,

Sorry for the delay in response.
This import error is due to string_int_label_map_pb2 is missing from the object_detection.protos module. I recommend installing protoc and running the command protoc object_detection/protos/*.proto --python_out=. as of installation instructions. Additionally, place this file into the object_detection/protos directory.

Thank You.