|
楼主 |
发表于 2023-10-18 09:33:55
|
显示全部楼层
如何给yolo训练模型取编:数字编号从小到大
import os
from os import listdir, getcwd
from os.path import join
if __name__ == '__main__':
source_folder='/home/yolo_v2_tinydarknet/darknet/infrared/image/dout/
dest='/home/yolo_v2_tinydarknet/darknet/infrared/train.txt'
dest2='/home/yolo_v2_tinydarknet/darknet/infrared/val.txt'
file_list=os.listdir(source_folder)
train_file=open(dest,'a')
val_file=open(dest2,'a')
for file_obj in file_list:
file_path=os.path.join(source_folder,file_obj)
file_name,file_extend=os.path.splitext(file_obj)
file_num=int(file_name)
if(file_num<900):
#print file_num
train_file.write(file_name+'\n')
else :
val_file.write(file_name+'\n')
train_file.close()
val_file.close()
|
|