解決recognition的train test分割程式執行後的文檔每行間多出一行空格 (#11280)
使用gen_ocr_train_val_test.py分割recognition data後產生的train.txt、val.txt和test.txt每行label間多出一行空格,導致訓練時出現異常,移除換行\n後便可正常運行。 Co-authored-by: Wayne Huang <dinghsun@gmail.com>pull/11299/head
parent
68b384292b
commit
80459f59fe
|
@ -45,15 +45,15 @@ def splitTrainVal(root, abs_train_root_path, abs_val_root_path, abs_test_root_pa
|
|||
if cur_ratio < train_ratio:
|
||||
image_copy_path = os.path.join(abs_train_root_path, image_name)
|
||||
shutil.copy(image_path, image_copy_path)
|
||||
train_txt.write("{}\t{}\n".format(image_copy_path, image_label))
|
||||
train_txt.write("{}\t{}".format(image_copy_path, image_label))
|
||||
elif cur_ratio >= train_ratio and cur_ratio < val_ratio:
|
||||
image_copy_path = os.path.join(abs_val_root_path, image_name)
|
||||
shutil.copy(image_path, image_copy_path)
|
||||
val_txt.write("{}\t{}\n".format(image_copy_path, image_label))
|
||||
val_txt.write("{}\t{}".format(image_copy_path, image_label))
|
||||
else:
|
||||
image_copy_path = os.path.join(abs_test_root_path, image_name)
|
||||
shutil.copy(image_path, image_copy_path)
|
||||
test_txt.write("{}\t{}\n".format(image_copy_path, image_label))
|
||||
test_txt.write("{}\t{}".format(image_copy_path, image_label))
|
||||
|
||||
|
||||
# 删掉存在的文件
|
||||
|
|
Loading…
Reference in New Issue