dlxj commited on
Commit ·
af83f0b
1
Parent(s): cfc1b20
# 单独保存预处理各阶段的图片(均为 BGR 格式)
Browse files- main_v6.py +8 -1
main_v6.py
CHANGED
|
@@ -44,7 +44,6 @@ if __name__ == '__main__':
|
|
| 44 |
text_recognition_model_dir="./PPv6/PP-OCRv6_medium_rec_safetensors",
|
| 45 |
lang='chinese_cht', # 繁体字典
|
| 46 |
return_word_box=True, # 返回每个字符的坐标
|
| 47 |
-
return_char=True, # 返回字符级四角坐标
|
| 48 |
use_doc_orientation_classify=True, # 整页方向(横/倒)
|
| 49 |
# use_doc_unwarping=True, # 弯曲矫正,扫描古籍有用
|
| 50 |
use_textline_orientation=True, # 文本行方向分类,竖排靠它
|
|
@@ -52,10 +51,18 @@ if __name__ == '__main__':
|
|
| 52 |
text_det_box_thresh=0.1, # 同上
|
| 53 |
text_rec_score_thresh=0.3, # 过滤低置信,古籍可放低
|
| 54 |
)
|
|
|
|
|
|
|
| 55 |
result = ocr.predict("./data/SWX0005_00000_00001.webp")
|
| 56 |
for res in result:
|
| 57 |
res.print()
|
| 58 |
res.save_to_img("output")
|
| 59 |
res.save_to_json("output")
|
| 60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
pass
|
|
|
|
| 44 |
text_recognition_model_dir="./PPv6/PP-OCRv6_medium_rec_safetensors",
|
| 45 |
lang='chinese_cht', # 繁体字典
|
| 46 |
return_word_box=True, # 返回每个字符的坐标
|
|
|
|
| 47 |
use_doc_orientation_classify=True, # 整页方向(横/倒)
|
| 48 |
# use_doc_unwarping=True, # 弯曲矫正,扫描古籍有用
|
| 49 |
use_textline_orientation=True, # 文本行方向分类,竖排靠它
|
|
|
|
| 51 |
text_det_box_thresh=0.1, # 同上
|
| 52 |
text_rec_score_thresh=0.3, # 过滤低置信,古籍可放低
|
| 53 |
)
|
| 54 |
+
import cv2
|
| 55 |
+
|
| 56 |
result = ocr.predict("./data/SWX0005_00000_00001.webp")
|
| 57 |
for res in result:
|
| 58 |
res.print()
|
| 59 |
res.save_to_img("output")
|
| 60 |
res.save_to_json("output")
|
| 61 |
|
| 62 |
+
# 单独保存预处理各阶段的图片(均为 BGR 格式)
|
| 63 |
+
pre = res['doc_preprocessor_res']
|
| 64 |
+
cv2.imwrite("output/SWX0005_00000_00001_input_img.png", pre['input_img'])
|
| 65 |
+
cv2.imwrite("output/SWX0005_00000_00001_rot_img.png", pre['rot_img'])
|
| 66 |
+
cv2.imwrite("output/SWX0005_00000_00001_output_img.png", pre['output_img'])
|
| 67 |
+
|
| 68 |
pass
|