From 2b522c32cf983865d2b4fb26e0f4afb60f58ef18 Mon Sep 17 00:00:00 2001 From: JIAKUNHAO Date: Wed, 23 Nov 2022 19:51:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=87=8F=E4=B8=8D=E5=A4=9F?= =?UTF-8?q?=E6=97=B6val=E4=B8=BA=E7=A9=BAdebug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/file_tool.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/app/file_tool.py b/app/file_tool.py index c5a32d6..e26e0e4 100644 --- a/app/file_tool.py +++ b/app/file_tool.py @@ -107,6 +107,8 @@ def mv_file(train_files: List[str], test_files: List[str], r_v_rate: Optional[fl train_len = ceil(train_len_all * r_v_rate) # t_files: 训练集, val_files:验证集 t_files = train_img_files[0:train_len] + if train_len==train_len_all: + train_len = 0 val_files = train_img_files[train_len:train_len_all] # 判断目标文件夹是否存在, 存在则删除目录下文件 @@ -179,18 +181,15 @@ def get_file(ori_path: str, type_list: Union[object,str]): test_files = [] # 训练、测试比例强制9:1 for img in imgs[0:1]: - path = ori_path + '/images/' +img #'/images/' - # print(os.path.exists(path)) + path = ori_path + '/images/' +img #'./ori/images/xxx.jpg' print('图像路径',path) if os.path.exists(path): test_files.append(path) print('1111') - #label = ori_path + 'labels/' + os.path.split(path)[1] (filename1, extension) = os.path.splitext(img) # 文件名与后缀名分开 label = ori_path + '/labels/' + filename1 + '.json' #'/labels/' print('标签',label) if label is not None: - #train_files.append(label) test_files.append(label) print('2222') for img in imgs[1:]: @@ -209,10 +208,6 @@ def get_file(ori_path: str, type_list: Union[object,str]): # proj = plc.get_proj_by_proj_no(proj_no=proj_no, db=db) target_path = mv_file(train_files=train_files, test_files=test_files) # 生成标签 - # img_types = ilc.get_label_by_proj_no(proj_no=proj_no, db=db) - # type_list = [] - # for img_type in img_types: - # type_list.append(img_type.lebel_type) type_dict = {'classes': type_list} str_json = json.dumps(type_dict) path = os.path.dirname(ori_path) + '/img_label_type'