在这里插入import os, glob
if __name__ == '__main__':
root='/home/yohoo/yolov5/runs/detect/exp/labels/'
imagelist=os.listdir(root)
for i in range(len(imagelist)):
txt_list = glob.glob(root+imagelist[i])
for txt_item in txt_list:
with open(txt_item) as f:
lines = f.readlines()
with open(txt_item, 'w') as f:
for line in lines:
line_split = line.strip().split()
if line_split[0] == 'gg':
line_split[0] = "UU"
f.write(
line_split[0] + ' ' +
line_split[1] + " " +
line_split[2] + " " +
line_split[3] + " " +
line_split[4]+'\n')
else:
f.write(
line_split[0] + ' ' +
line_split[1] + ' ' +
line_split[2] + ' ' +
line_split[3] + ' ' +
line_split[4] + '\n' )
代码片
asafasfasfa
最新推荐文章于 2024-10-18 11:21:51 发布