@TOC
结论
Label ID: 1, Label Name: D00
Label ID: 2, Label Name: D10
Label ID: 3, Label Name: D20
Label ID: 4, Label Name: D40
链接地址
- https://github.com/sekilab/RoadDamageDetector/
查看代码
# 打开 label_map.pbtxt 文件
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
# 读取label_map.pbtxt文件
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}')