数据量不够时val为空debug
This commit is contained in:
parent
9818a1d488
commit
2b522c32cf
@ -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)
|
train_len = ceil(train_len_all * r_v_rate)
|
||||||
# t_files: 训练集, val_files:验证集
|
# t_files: 训练集, val_files:验证集
|
||||||
t_files = train_img_files[0:train_len]
|
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]
|
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 = []
|
test_files = []
|
||||||
# 训练、测试比例强制9:1
|
# 训练、测试比例强制9:1
|
||||||
for img in imgs[0:1]:
|
for img in imgs[0:1]:
|
||||||
path = ori_path + '/images/' +img #'/images/'
|
path = ori_path + '/images/' +img #'./ori/images/xxx.jpg'
|
||||||
# print(os.path.exists(path))
|
|
||||||
print('图像路径',path)
|
print('图像路径',path)
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
test_files.append(path)
|
test_files.append(path)
|
||||||
print('1111')
|
print('1111')
|
||||||
#label = ori_path + 'labels/' + os.path.split(path)[1]
|
|
||||||
(filename1, extension) = os.path.splitext(img) # 文件名与后缀名分开
|
(filename1, extension) = os.path.splitext(img) # 文件名与后缀名分开
|
||||||
label = ori_path + '/labels/' + filename1 + '.json' #'/labels/'
|
label = ori_path + '/labels/' + filename1 + '.json' #'/labels/'
|
||||||
print('标签',label)
|
print('标签',label)
|
||||||
if label is not None:
|
if label is not None:
|
||||||
#train_files.append(label)
|
|
||||||
test_files.append(label)
|
test_files.append(label)
|
||||||
print('2222')
|
print('2222')
|
||||||
for img in imgs[1:]:
|
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)
|
# 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)
|
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}
|
type_dict = {'classes': type_list}
|
||||||
str_json = json.dumps(type_dict)
|
str_json = json.dumps(type_dict)
|
||||||
path = os.path.dirname(ori_path) + '/img_label_type'
|
path = os.path.dirname(ori_path) + '/img_label_type'
|
||||||
|
Loading…
Reference in New Issue
Block a user