Models: label_map_util.load_labelmap(PATH_TO_LABELS) error

Created on 29 Jun 2017  路  6Comments  路  Source: tensorflow/models

When I run 'Loading label map' section in the 'object_detection_tutorial' on jupyter notebook, some error comes out. google.protobuf version is 3.3.0. tensorflow version is 1.0.0. Any help?

Loading label map

label_map = label_map_util.load_labelmap(PATH_TO_LABELS)
categories = label_map_util.convert_label_map_to_categories(label_map, max_num_classes=NUM_CLASSES, use_display_name=True)
category_index = label_map_util.create_category_index(categories)

And the information as follows:

TypeError                                 Traceback (most recent call last)
<ipython-input-7-caec6fd59338> in <module>()
----> 1 label_map = label_map_util.load_labelmap(PATH_TO_LABELS)
      2 categories = label_map_util.convert_label_map_to_categories(label_map, max_num_classes=NUM_CLASSES, use_display_name=True)
      3 category_index = label_map_util.create_category_index(categories)

~/Desktop/models/object_detection/utils/label_map_util.py in load_labelmap(path)
    105     label_map = string_int_label_map_pb2.StringIntLabelMap()
    106     try:
--> 107       text_format.Merge(label_map_string, label_map)
    108     except text_format.ParseError:
    109       label_map.ParseFromString(label_map_string)

~/anaconda/envs/py35/lib/python3.5/site-packages/google/protobuf/text_format.py in Merge(text, message, allow_unknown_extension, allow_field_number, descriptor_pool)
    475   """
    476   return MergeLines(
--> 477       text.split('\n'),
    478       message,
    479       allow_unknown_extension,

TypeError: a bytes-like object is required, not 'str'

Most helpful comment

Solving this problem by updating my tensorflow from 1.0.0 to 1.1.0~

All 6 comments

Solving this problem by updating my tensorflow from 1.0.0 to 1.1.0~

I had the same problem a hour ago. Try to changing the "PATH_TO_LABELS" .

Example for me it's :
PATH_TO_LABELS = os.path.join('/usr/local/lib/python3.5/dist-packages/tensorflow/models/object_detection/data', 'mscoco_label_map.pbtxt')

How to get -rid of this problem? Should I use newer version of tensorflow ?

After I change the default mscoco_label_map.pbtxt file to only 2 classes, the error can not be fix even I change the default file back, why is that?

Was this page helpful?
0 / 5 - 0 ratings