关于制作数据集的label:
- 在P7视频的最后,写了这段,用来重新命名文件的label的
- img 和 label 的管理方法,有两种:
1、用img所在文件夹的名称,作为label;
2、img在一个文件夹,label在另一个文件夹,img文件夹中是图片,label文件夹中是txt文件,txt文件名跟对应img名称一致,而label,写在txt文件里面
可以运行的代码
"""
author :24nemo
date :2021年07月12日
"""
import os
root_dir = "TuDui/src/dataset/train"
target_dir = "ants_image"
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)
运行后的效果
- train 数据集中,img对应的label作为文件夹的目录存在,当前目录当中的数据内容,与文件夹名称保持一致
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)