import os
label_path = r"C:\Users\DELL\Desktop\huanghe"
label_path_new = r"C:\Users\DELL\Desktop\huanghe_new"
label_list = os.listdir(label_path)
count = 0
for label_file in label_list:
if label_file.endswith(".txt"):
with open(os.path.join(label_path, label_file), "r", encoding="utf-8") as f1, open(os.path.join(label_path_new, label_file), "w", encoding="utf-8") as f2:
for line in f1:
items = line.split(" ")
if items[0] == "0":
items[0] = "0"
elif items[0] == "1":
items[0] = "2"
elif items[0] == "2":
items[0] = "6"
line = " ".join(items)
f2.write(line)
Python 修改yolo标注文件的类别编号
最新推荐文章于 2023-02-23 12:00:01 发布