Tingquan commited on
Commit
9e25080
·
verified ·
1 Parent(s): 1a2fecb

Upload folder using huggingface_hub

Browse files
Files changed (5) hide show
  1. README.md +169 -0
  2. config.json +2 -1
  3. inference.json +0 -0
  4. inference.pdiparams +2 -2
  5. inference.yml +2 -1
README.md ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: PaddleOCR
4
+ language:
5
+ - en
6
+ pipeline_tag: image-to-text
7
+ tags:
8
+ - OCR
9
+ - PaddlePaddle
10
+ - PaddleOCR
11
+ - textline_recognition
12
+ ---
13
+
14
+ # th_PP-OCRv5_mobile_rec
15
+
16
+ ## Introduction
17
+
18
+ th_PP-OCRv5_mobile_rec is one of the PP-OCRv5_rec that are the latest generation text line recognition models developed by PaddleOCR team. It aims to efficiently and accurately support the recognition of Thai. The key accuracy metrics are as follow:
19
+
20
+ | Model | Accuracy (%) |
21
+ |-|-|
22
+ | th_PP-OCRv5_mobile_rec | 82.68|
23
+
24
+
25
+
26
+ **Note**: If any character (including punctuation) in a line was incorrect, the entire line was marked as wrong. This ensures higher accuracy in practical applications.
27
+
28
+ ## Quick Start
29
+
30
+ ### Installation
31
+
32
+ 1. PaddlePaddle
33
+
34
+ Please refer to the following commands to install PaddlePaddle using pip:
35
+
36
+ ```bash
37
+ # for CUDA11.8
38
+ python -m pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/
39
+
40
+ # for CUDA12.6
41
+ python -m pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu126/
42
+
43
+ # for CPU
44
+ python -m pip install paddlepaddle==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cpu/
45
+ ```
46
+
47
+ For details about PaddlePaddle installation, please refer to the [PaddlePaddle official website](https://www.paddlepaddle.org.cn/en/install/quick).
48
+
49
+ 2. PaddleOCR
50
+
51
+ Install the latest version of the PaddleOCR inference package from PyPI:
52
+
53
+ ```bash
54
+ python -m pip install paddleocr
55
+ ```
56
+
57
+ ### Model Usage
58
+
59
+ You can quickly experience the functionality with a single command:
60
+
61
+ ```bash
62
+ paddleocr text_recognition \
63
+ --model_name th_PP-OCRv5_mobile_rec \
64
+ -i https://cdn-uploads.huggingface.co/production/uploads/681c1ecd9539bdde5ae1733c/nPx7FrH1VfkHSdVJMRnhT.png
65
+ ```
66
+
67
+ You can also integrate the model inference of the text recognition module into your project. Before running the following code, please download the sample image to your local machine.
68
+
69
+ ```python
70
+ from paddleocr import TextRecognition
71
+ model = TextRecognition(model_name="th_PP-OCRv5_mobile_rec")
72
+ output = model.predict(input="nPx7FrH1VfkHSdVJMRnhT.png", batch_size=1)
73
+ for res in output:
74
+ res.print()
75
+ res.save_to_img(save_path="./output/")
76
+ res.save_to_json(save_path="./output/res.json")
77
+ ```
78
+
79
+ After running, the obtained result is as follows:
80
+
81
+ ```json
82
+ {'res': {'input_path': '/root/.paddlex/predict_input/nPx7FrH1VfkHSdVJMRnhT.png', 'page_index': None, 'rec_text': 'อานุภาพทำลายล้างสูง', 'rec_score': 0.9737655520439148}}
83
+ ```
84
+
85
+ The visualized image is as follows:
86
+
87
+ ![image/jpeg](https://cdn-uploads.huggingface.co/production/uploads/681c1ecd9539bdde5ae1733c/ENalRsZmBVtRVNXTA_dAa.png)
88
+
89
+ For details about usage command and descriptions of parameters, please refer to the [Document](https://paddlepaddle.github.io/PaddleOCR/latest/en/version3.x/module_usage/text_recognition.html#iii-quick-start).
90
+
91
+ ### Pipeline Usage
92
+
93
+ The ability of a single model is limited. But the pipeline consists of several models can provide more capacity to resolve difficult problems in real-world scenarios.
94
+
95
+ #### PP-OCRv5
96
+
97
+ The general OCR pipeline is used to solve text recognition tasks by extracting text information from images and outputting it in string format. And there are 5 modules in the pipeline:
98
+ * Document Image Orientation Classification Module (Optional)
99
+ * Text Image Unwarping Module (Optional)
100
+ * Text Line Orientation Classification Module (Optional)
101
+ * Text Detection Module
102
+ * Text Recognition Module
103
+
104
+ Run a single command to quickly experience the OCR pipeline:
105
+
106
+ ```bash
107
+ paddleocr ocr -i https://cdn-uploads.huggingface.co/production/uploads/681c1ecd9539bdde5ae1733c/pnVch3hcwm6CiIkr_GT0t.png \
108
+ --text_recognition_model_name th_PP-OCRv5_mobile_rec \
109
+ --use_doc_orientation_classify False \
110
+ --use_doc_unwarping False \
111
+ --use_textline_orientation True \
112
+ --save_path ./output \
113
+ --device gpu:0
114
+ ```
115
+
116
+ Results are printed to the terminal:
117
+
118
+ ```json
119
+ {'res': {'input_path': '/root/.paddlex/predict_input/pnVch3hcwm6CiIkr_GT0t.png', 'page_index': None, 'model_settings': {'use_doc_preprocessor': True, 'use_textline_orientation': True}, 'doc_preprocessor_res': {'input_path': None, 'page_index': None, 'model_settings': {'use_doc_orientation_classify': False, 'use_doc_unwarping': False}, 'angle': -1}, 'dt_polys': array([[[340, 12],
120
+ ...,
121
+ [344, 234]],
122
+
123
+ ...,
124
+
125
+ [[783, 759],
126
+ ...,
127
+ [782, 816]]], shape=(5, 4, 2), dtype=int16), 'text_det_params': {'limit_side_len': 64, 'limit_type': 'min', 'thresh': 0.3, 'max_side_limit': 4000, 'box_thresh': 0.6, 'unclip_ratio': 1.5}, 'text_type': 'general', 'textline_orientation_angles': array([1, ..., 0], shape=(5,)), 'text_rec_score_thresh': 0.0, 'return_word_box': False, 'rec_texts': ['นระเeเBรMาา', 'ดดเอBเeเนmเบทเe', 'พ.ศ.', '๒๕๕๙', 'ฉบับล่าสุด'], 'rec_scores': array([0.7450521 , ..., 0.99287319], shape=(5,)), 'rec_polys': array([[[340, 12],
128
+ ...,
129
+ [344, 234]],
130
+
131
+ ...,
132
+
133
+ [[783, 759],
134
+ ...,
135
+ [782, 816]]], shape=(5, 4, 2), dtype=int16), 'rec_boxes': array([[340, ..., 234],
136
+ ...,
137
+ [782, ..., 818]], shape=(5, 4), dtype=int16)}}
138
+ ```
139
+
140
+ If save_path is specified, the visualization results will be saved under `save_path`. The visualization output is shown below:
141
+
142
+ ![image/jpeg](https://cdn-uploads.huggingface.co/production/uploads/681c1ecd9539bdde5ae1733c/O8odbCLKLZmZXlZcVg_Qi.png)
143
+
144
+ The command-line method is for quick experience. For project integration, also only a few codes are needed as well:
145
+
146
+ ```python
147
+ from paddleocr import PaddleOCR
148
+
149
+ ocr = PaddleOCR(
150
+ text_recognition_model_name="th_PP-OCRv5_mobile_rec",
151
+ use_doc_orientation_classify=False, # Use use_doc_orientation_classify to enable/disable document orientation classification model
152
+ use_doc_unwarping=False, # Use use_doc_unwarping to enable/disable document unwarping module
153
+ use_textline_orientation=True, # Use use_textline_orientation to enable/disable textline orientation classification model
154
+ device="gpu:0", # Use device to specify GPU for model inference
155
+ )
156
+ result = ocr.predict("https://cdn-uploads.huggingface.co/production/uploads/681c1ecd9539bdde5ae1733c/pnVch3hcwm6CiIkr_GT0t.png")
157
+ for res in result:
158
+ res.print()
159
+ res.save_to_img("output")
160
+ res.save_to_json("output")
161
+ ```
162
+
163
+ The default model used in pipeline is `PP-OCRv5_server_rec`, so it is needed that specifing to `th_PP-OCRv5_mobile_rec` by argument `text_recognition_model_name`. And you can also use the local model file by argument `text_recognition_model_dir`. For details about usage command and descriptions of parameters, please refer to the [Document](https://paddlepaddle.github.io/PaddleOCR/latest/en/version3.x/pipeline_usage/OCR.html#2-quick-start).
164
+
165
+ ## Links
166
+
167
+ [PaddleOCR Repo](https://github.com/paddlepaddle/paddleocr)
168
+
169
+ [PaddleOCR Documentation](https://paddlepaddle.github.io/PaddleOCR/latest/en/index.html)
config.json CHANGED
@@ -532,7 +532,8 @@
532
  "χ",
533
  "Ψ",
534
  "ψ",
535
- "ωก",
 
536
  "ข",
537
  "ค",
538
  "ฅ",
 
532
  "χ",
533
  "Ψ",
534
  "ψ",
535
+ "ω",
536
+ "ก",
537
  "ข",
538
  "ค",
539
  "ฅ",
inference.json CHANGED
The diff for this file is too large to render. See raw diff
 
inference.pdiparams CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:34be25ee32ba23ff2cb5c93e3be7588d218ddb9fb39d7f9475b8f24081887be6
3
- size 7814423
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:45ec91f2322b58b8d30ba27d18fcfdbb8bf388b918dd978162d2af91e0c66d4b
3
+ size 7814907
inference.yml CHANGED
@@ -481,7 +481,8 @@ PostProcess:
481
  - χ
482
  - Ψ
483
  - ψ
484
- - ωก
 
485
  - ข
486
  - ค
487
  - ฅ
 
481
  - χ
482
  - Ψ
483
  - ψ
484
+ - ω
485
+ - ก
486
  - ข
487
  - ค
488
  - ฅ