结论
- 道路病害检测数据集RDD2022、RDD2020的标签映射关系都如下所示
Label ID: 1, Label Name: D00
Label ID: 2, Label Name: D10
Label ID: 3, Label Name: D20
Label ID: 4, Label Name: D40
链接地址
查看代码
def read_label_map(file_path):
label_map = {}
with open(file_path, 'r') as f:
lines = f.readlines()
current_label_id = None
for line in lines:
line = line.strip()
if line.startswith('id:'):
current_label_id = int(line.split(':')[-1].strip())
elif line.startswith('name:'):
label_name = line.split(':')[-1].strip().replace("'", "")
label_map[current_label_id] = label_name
return label_map
file_path = 'F:\ChromeDown\label_map.pbtxt'
label_map = read_label_map(file_path)
for label_id, label_name in label_map.items():
print(f'Label ID: {label_id}, Label Name: {label_name}')