Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

tensorflow - ValueError: Protocol message StringIntLabelMapItem has no field frequency

I'm trying to build an object detector using tensorflow from a YouTube tutorial. I have created a conda environment and installed all the required packages. Now when I try to run its script in VScode, it shows this error.

Traceback (most recent call last):
File "updated_old_example.py", line 79, in <module>
categories = label_map_util.convert_label_map_to_categories(label_map,max_num_classes=NUM_CLASSES, use_display_name=True)
File "/Users/Home/Desktop/Project/Object_Detection/models/research/object_detection/utils/label_map_util.py", line 133, in convert_label_map_to_categories
if item.HasField('frequency'):
ValueError: Protocol message StringIntLabelMapItem has no field frequency.

This is the first time I'm encountering this error. Some fix would be really appreciated.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I have never find this kind of issue before, but after downloading new models from tensorflow API this error just comes out. Then i tried to compare the file that written on error message with the old version of tensorflow api models, that's where the Error comes out. all you need to do is find this file:

Object_Detection/models/research/object_detection/utils/label_map_util.py", line 133

then delete this code

  if item.HasField('frequency'):
    if item.frequency == string_int_label_map_pb2.LVISFrequency.Value(
        'FREQUENT'):
      category['frequency'] = 'f'
    elif item.frequency == string_int_label_map_pb2.LVISFrequency.Value(
        'COMMON'):
      category['frequency'] = 'c'
    elif item.frequency == string_int_label_map_pb2.LVISFrequency.Value(
        'RARE'):
      category['frequency'] = 'r'
  if item.HasField('instance_count'):
    category['instance_count'] = item.instance_count

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...