Tingquan commited on
Commit
7cac3c9
·
verified ·
1 Parent(s): 27184dc

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. README.md +169 -0
  2. config.json +1 -1
  3. inference.pdiparams +1 -1
  4. inference.yml +1 -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
+ # el_PP-OCRv5_mobile_rec
15
+
16
+ ## Introduction
17
+
18
+ el_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
+ | el_PP-OCRv5_mobile_rec | 89.28|
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 el_PP-OCRv5_mobile_rec \
64
+ -i https://cdn-uploads.huggingface.co/production/uploads/681c1ecd9539bdde5ae1733c/MGeBVIwRWCE_CzK2nnCo1.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="el_PP-OCRv5_mobile_rec")
72
+ output = model.predict(input="MGeBVIwRWCE_CzK2nnCo1.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/MGeBVIwRWCE_CzK2nnCo1.png', 'page_index': None, 'rec_text': 'Γεια σας! Ελπίζω να έχετε μια υπέροχη μέρα.', 'rec_score': 0.9820859432220459}}
83
+ ```
84
+
85
+ The visualized image is as follows:
86
+
87
+ ![image/jpeg](https://cdn-uploads.huggingface.co/production/uploads/681c1ecd9539bdde5ae1733c/A9zIsXsYWxQWwujqGP-sI.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/fQsoDVY6IMM8rk8tQKVBt.png \
108
+ --text_recognition_model_name el_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/fQsoDVY6IMM8rk8tQKVBt.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([[[ 151, 165],
120
+ ...,
121
+ [ 151, 223]],
122
+
123
+ ...,
124
+
125
+ [[ 111, 1284],
126
+ ...,
127
+ [ 111, 1308]]], shape=(23, 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([0, ..., 0], shape=(23,)), 'text_rec_score_thresh': 0.0, 'return_word_box': False, 'rec_texts': ['ΑΘΛΗΤΙΣΜΟΣ', 'ΚΑΙ ΚΟΙΝΩΝΙΚΕΣ', 'ΕΠΙΣΤΗΜΕΣ', 'Greek', 'Journal', 'of', 'Sport', 'and', 'Social', 'Sciences', 'Τεύχος', 'Φεβρουάριος', '2024', 'ISSN:', '2945-0608', 'ΠΕΡΙΟΔΙΚΗΕΚΔΟΣΗΤΩΝ.', '', 'Εργαστηρίου Κοινωνικής Ανάλυσης και Εφαρμοσμένης Κοινωνικής', 'Ερευνας, Τμήμα Κοινωνιολογίας του Πανεπιστημίου Κρήτής', 'Τομέα Νεοελληνικής Κοινωνίας, Τμήμα Κοινωνιολογίας του Πάντειου', 'Πανεπιστημίου', 'Μεταπτυχιακού Προγράμματος Αθλιητικές Σπουδές: Κοινωνιολογία,', 'Ιστορία, Ανθρωπολογία», Ελληνικ Ανοικτ Πανεπιστήμιο'], 'rec_scores': array([0.99981022, ..., 0.95862782], shape=(23,)), 'rec_polys': array([[[ 151, 165],
128
+ ...,
129
+ [ 151, 223]],
130
+
131
+ ...,
132
+
133
+ [[ 111, 1284],
134
+ ...,
135
+ [ 111, 1308]]], shape=(23, 4, 2), dtype=int16), 'rec_boxes': array([[ 151, ..., 223],
136
+ ...,
137
+ [ 111, ..., 1309]], shape=(23, 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/p81w0gR5Wlf1fvY1q0E0r.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="el_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/fQsoDVY6IMM8rk8tQKVBt.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 `el_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
@@ -364,7 +364,7 @@
364
  "έ",
365
  "ή",
366
  "ί",
367
- "Ό",
368
  "ύ",
369
  "ώ",
370
  "Ϊ",
 
364
  "έ",
365
  "ή",
366
  "ί",
367
+ "ό",
368
  "ύ",
369
  "ώ",
370
  "Ϊ",
inference.pdiparams CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:34749e1517520dbef741e507c8c8665c301d586bbb041b469a3433dc2eec18c7
3
  size 7732627
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4d69bbb8ed9f84373631d121ab459f8583cd978df813b5fb9b139b7783b05fbd
3
  size 7732627
inference.yml CHANGED
@@ -313,7 +313,7 @@ PostProcess:
313
  - έ
314
  - ή
315
  - ί
316
- - Ό
317
  - ύ
318
  - ώ
319
  - Ϊ
 
313
  - έ
314
  - ή
315
  - ί
316
+ - ό
317
  - ύ
318
  - ώ
319
  - Ϊ