赞
踩
# !usr/bin/env python3 # -*- coding:utf-8 -*- """ author :24nemo date :2021年07月12日 """ import os root_dir = "TuDui/src/dataset/train" # train: path from contend root target_dir = "ants_image" # ants_image: copy file name img_path = os.listdir(os.path.join(root_dir, target_dir)) label = target_dir.split('_')[0] out_dir = "ants_label" for i in img_path: file_name = i.split('.jpg')[0] with open(os.path.join(root_dir, target_dir, "{}.txt".format(file_name)), "w") as f: f.write(label)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。