123456789101112131415161718192021222324 |
- import argparse
- import os
- def get_all_labels(img_fold):
- # 获取字体文件夹列表
- img_fold_list = os.listdir(img_fold)
- # label_list.txt文件
- fp_label = open(str(img_fold) + '/label_list.txt', 'w')
- cnt = 0
- for img_fold_in in img_fold_list:
- if img_fold_in.endswith('.txt'):
- continue
- # 字体名以及对应id写入label_list.txt
- fp_label.write(str(cnt) + ' ' + str(img_fold_in) + '\n')
- cnt += 1
- fp_label.close()
- if __name__ == '__main__':
- parser = argparse.ArgumentParser()
- parser.add_argument('--save_dir', type=str, default=r'C:\Users\KDAN\Desktop\workspace\字体分类数据集\windows_1\font_test_dataset')
- args = parser.parse_args()
- get_all_labels(args.save_dir)
|