add ppv6
Browse files- .gitignore +1 -0
- .vscode/launch.json +12 -0
- data/SWX0005_00000_00001.webp +3 -0
- data/SWX0005_00000_00002.webp +3 -0
- data/SWX0005_00000_00003.webp +3 -0
- main.py +2 -0
- main_v6.py +44 -0
.gitignore
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
|
|
| 1 |
out.json
|
| 2 |
.vscode/settings.json
|
|
|
|
| 1 |
+
PPv6/
|
| 2 |
out.json
|
| 3 |
.vscode/settings.json
|
.vscode/launch.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"version": "0.2.0",
|
| 3 |
+
"configurations": [
|
| 4 |
+
{
|
| 5 |
+
"name": "Python Debugger: Current File",
|
| 6 |
+
"type": "debugpy",
|
| 7 |
+
"request": "launch",
|
| 8 |
+
"program": "${file}",
|
| 9 |
+
"console": "integratedTerminal"
|
| 10 |
+
}
|
| 11 |
+
]
|
| 12 |
+
}
|
data/SWX0005_00000_00001.webp
ADDED
|
Git LFS Details
|
data/SWX0005_00000_00002.webp
ADDED
|
Git LFS Details
|
data/SWX0005_00000_00003.webp
ADDED
|
Git LFS Details
|
main.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
| 1 |
|
| 2 |
# see huggingface/project/flask_auto_selection.py
|
| 3 |
|
|
|
|
|
|
|
| 4 |
# C:\Users\echod\.paddlex\official_models\PP-OCRv5_server_det
|
| 5 |
# c:\Users\echod\.conda\envs\ppv5\lib\site-packages\paddle\utils\cpp_extension\extension_utils.py 看模型加载的代码在哪
|
| 6 |
# PP-OCRv5_server_det PP-OCRv5_server_det.yaml 搜这两个
|
|
|
|
| 1 |
|
| 2 |
# see huggingface/project/flask_auto_selection.py
|
| 3 |
|
| 4 |
+
# see huggingface_echodict/typst-app-clone/tools/extract_pdf_images.py
|
| 5 |
+
|
| 6 |
# C:\Users\echod\.paddlex\official_models\PP-OCRv5_server_det
|
| 7 |
# c:\Users\echod\.conda\envs\ppv5\lib\site-packages\paddle\utils\cpp_extension\extension_utils.py 看模型加载的代码在哪
|
| 8 |
# PP-OCRv5_server_det PP-OCRv5_server_det.yaml 搜这两个
|
main_v6.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
# see huggingface_echodict/typst-app-clone/tools/extract_pdf_images.py
|
| 3 |
+
|
| 4 |
+
# see https://huggingface.co/PaddlePaddle/PP-OCRv6_medium_det_safetensors
|
| 5 |
+
# see https://huggingface.co/PaddlePaddle/PP-OCRv6_medium_rec_safetensors
|
| 6 |
+
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
| 10 |
+
# On Windows.
|
| 11 |
+
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
|
| 12 |
+
|
| 13 |
+
uv venv --python 3.10 --seed --clear
|
| 14 |
+
|
| 15 |
+
.venv\Scripts\pip.exe install "paddleocr[all]"
|
| 16 |
+
|
| 17 |
+
.venv\Scripts\pip.exe install transformers torch
|
| 18 |
+
|
| 19 |
+
.venv\Scripts\pip.exe install paddlepaddle -i https://www.paddlepaddle.org.cn/packages/stable/cpu/
|
| 20 |
+
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
if __name__ == '__main__':
|
| 24 |
+
|
| 25 |
+
from paddleocr import PaddleOCR
|
| 26 |
+
|
| 27 |
+
ocr = PaddleOCR(
|
| 28 |
+
text_detection_model_dir="./PPv6/PP-OCRv6_medium_det_safetensors",
|
| 29 |
+
text_recognition_model_dir="./PPv6/PP-OCRv6_medium_rec_safetensors",
|
| 30 |
+
lang='chinese_cht', # 繁体字典
|
| 31 |
+
use_doc_orientation_classify=True, # 整页方向(横/倒)
|
| 32 |
+
use_doc_unwarping=True, # 弯曲矫正,扫描古籍有用
|
| 33 |
+
use_textline_orientation=True, # 文本行方向分类,竖排靠它
|
| 34 |
+
text_det_thresh=0.1, # 默认 0.3 对古籍太高,漏淡墨
|
| 35 |
+
text_det_box_thresh=0.1, # 同上
|
| 36 |
+
text_rec_score_thresh=0.3, # 过滤低置信,古籍可放低
|
| 37 |
+
)
|
| 38 |
+
result = ocr.predict("./data/SWX0005_00000_00001.webp")
|
| 39 |
+
for res in result:
|
| 40 |
+
res.print()
|
| 41 |
+
res.save_to_img("output")
|
| 42 |
+
res.save_to_json("output")
|
| 43 |
+
|
| 44 |
+
pass
|