Skip to content

Commit

Permalink
解決recognition的train test分割程式執行後的文檔每行間多出一行空格 (#11280)
Browse files Browse the repository at this point in the history
使用gen_ocr_train_val_test.py分割recognition data後產生的train.txt、val.txt和test.txt每行label間多出一行空格,導致訓練時出現異常,移除換行\n後便可正常運行。

Co-authored-by: Wayne Huang <[email protected]>
  • Loading branch information
DingHsun and Wayne Huang authored Nov 22, 2023
1 parent 68b3842 commit 80459f5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions PPOCRLabel/gen_ocr_train_val_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))


# 删掉存在的文件
Expand Down

0 comments on commit 80459f5

Please sign in to comment.