whl.md 20.6 KB
Newer Older
WenmuZhou's avatar
WenmuZhou committed
1
2
# paddleocr package使用说明

WenmuZhou's avatar
WenmuZhou committed
3
## 1 快速上手
WenmuZhou's avatar
WenmuZhou committed
4

WenmuZhou's avatar
WenmuZhou committed
5
### 1.1 安装whl包
WenmuZhou's avatar
WenmuZhou committed
6
7

pip安装
8

WenmuZhou's avatar
WenmuZhou committed
9
```bash
WenmuZhou's avatar
WenmuZhou committed
10
pip install "paddleocr>=2.0.1" # 推荐使用2.0.1+版本
WenmuZhou's avatar
WenmuZhou committed
11
12
13
```

本地构建并安装
14

WenmuZhou's avatar
WenmuZhou committed
15
```bash
WenmuZhou's avatar
WenmuZhou committed
16
17
python3 setup.py bdist_wheel
pip3 install dist/paddleocr-x.x.x-py3-none-any.whl # x.x.x是paddleocr的版本号
WenmuZhou's avatar
WenmuZhou committed
18
19
```

WenmuZhou's avatar
WenmuZhou committed
20
## 2 使用
21

WenmuZhou's avatar
WenmuZhou committed
22
### 2.1 代码使用
23

WenmuZhou's avatar
WenmuZhou committed
24
25
26
paddleocr whl包会自动下载ppocr轻量级模型作为默认模型,可以根据第3节**自定义模型**进行自定义更换。

* 检测+方向分类器+识别全流程
27

WenmuZhou's avatar
WenmuZhou committed
28
29
```python
from paddleocr import PaddleOCR, draw_ocr
30

WenmuZhou's avatar
WenmuZhou committed
31
32
# Paddleocr目前支持中英文、英文、法语、德语、韩语、日语,可以通过修改lang参数进行切换
# 参数依次为`ch`, `en`, `french`, `german`, `korean`, `japan`。
33
ocr = PaddleOCR(use_angle_cls=True, lang="ch")  # need to run only once to download and load model into memory
WenmuZhou's avatar
WenmuZhou committed
34
35
36
37
38
39
40
img_path = 'PaddleOCR/doc/imgs/11.jpg'
result = ocr.ocr(img_path, cls=True)
for line in result:
    print(line)

# 显示结果
from PIL import Image
41

WenmuZhou's avatar
WenmuZhou committed
42
43
44
45
image = Image.open(img_path).convert('RGB')
boxes = [line[0] for line in result]
txts = [line[1][0] for line in result]
scores = [line[1][1] for line in result]
WenmuZhou's avatar
WenmuZhou committed
46
im_show = draw_ocr(image, boxes, txts, scores, font_path='/path/to/PaddleOCR/doc/fonts/simfang.ttf')
WenmuZhou's avatar
WenmuZhou committed
47
48
49
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')
```
50

WenmuZhou's avatar
WenmuZhou committed
51
结果是一个list,每个item包含了文本框,文字和识别置信度
52

WenmuZhou's avatar
WenmuZhou committed
53
54
55
56
57
58
```bash
[[[24.0, 36.0], [304.0, 34.0], [304.0, 72.0], [24.0, 74.0]], ['纯臻营养护发素', 0.964739]]
[[[24.0, 80.0], [172.0, 80.0], [172.0, 104.0], [24.0, 104.0]], ['产品信息/参数', 0.98069626]]
[[[24.0, 109.0], [333.0, 109.0], [333.0, 136.0], [24.0, 136.0]], ['(45元/每公斤,100公斤起订)', 0.9676722]]
......
```
59

WenmuZhou's avatar
WenmuZhou committed
60
61
62
63
64
65
66
结果可视化

<div align="center">
    <img src="../imgs_results/whl/11_det_rec.jpg" width="800">
</div>

* 检测+识别
67

WenmuZhou's avatar
WenmuZhou committed
68
69
```python
from paddleocr import PaddleOCR, draw_ocr
70
71

ocr = PaddleOCR()  # need to run only once to download and load model into memory
WenmuZhou's avatar
WenmuZhou committed
72
img_path = 'PaddleOCR/doc/imgs/11.jpg'
73
result = ocr.ocr(img_path, cls=False)
WenmuZhou's avatar
WenmuZhou committed
74
75
76
77
78
for line in result:
    print(line)

# 显示结果
from PIL import Image
79

WenmuZhou's avatar
WenmuZhou committed
80
81
82
83
image = Image.open(img_path).convert('RGB')
boxes = [line[0] for line in result]
txts = [line[1][0] for line in result]
scores = [line[1][1] for line in result]
WenmuZhou's avatar
WenmuZhou committed
84
im_show = draw_ocr(image, boxes, txts, scores, font_path='/path/to/PaddleOCR/doc/fonts/simfang.ttf')
WenmuZhou's avatar
WenmuZhou committed
85
86
87
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')
```
88

WenmuZhou's avatar
WenmuZhou committed
89
结果是一个list,每个item包含了文本框,文字和识别置信度
90

WenmuZhou's avatar
WenmuZhou committed
91
92
93
94
```bash
[[[24.0, 36.0], [304.0, 34.0], [304.0, 72.0], [24.0, 74.0]], ['纯臻营养护发素', 0.964739]]
[[[24.0, 80.0], [172.0, 80.0], [172.0, 104.0], [24.0, 104.0]], ['产品信息/参数', 0.98069626]]
[[[24.0, 109.0], [333.0, 109.0], [333.0, 136.0], [24.0, 136.0]], ['(45元/每公斤,100公斤起订)', 0.9676722]]
WenmuZhou's avatar
WenmuZhou committed
95
......
WenmuZhou's avatar
WenmuZhou committed
96
```
97

WenmuZhou's avatar
WenmuZhou committed
98
99
100
101
102
103
结果可视化

<div align="center">
    <img src="../imgs_results/whl/11_det_rec.jpg" width="800">
</div>

WenmuZhou's avatar
WenmuZhou committed
104
* 方向分类器+识别
105

WenmuZhou's avatar
WenmuZhou committed
106
107
```python
from paddleocr import PaddleOCR
108
109

ocr = PaddleOCR(use_angle_cls=True)  # need to run only once to download and load model into memory
WenmuZhou's avatar
WenmuZhou committed
110
111
112
113
114
img_path = 'PaddleOCR/doc/imgs_words/ch/word_1.jpg'
result = ocr.ocr(img_path, det=False, cls=True)
for line in result:
    print(line)
```
115

WenmuZhou's avatar
WenmuZhou committed
116
结果是一个list,每个item只包含识别结果和识别置信度
117

WenmuZhou's avatar
WenmuZhou committed
118
119
120
121
```bash
['韩国小馆', 0.9907421]
```

WenmuZhou's avatar
WenmuZhou committed
122
* 单独执行检测
123

WenmuZhou's avatar
WenmuZhou committed
124
125
```python
from paddleocr import PaddleOCR, draw_ocr
126
127

ocr = PaddleOCR()  # need to run only once to download and load model into memory
WenmuZhou's avatar
WenmuZhou committed
128
img_path = 'PaddleOCR/doc/imgs/11.jpg'
WenmuZhou's avatar
WenmuZhou committed
129
result = ocr.ocr(img_path, rec=False)
WenmuZhou's avatar
WenmuZhou committed
130
131
132
133
134
135
136
for line in result:
    print(line)

# 显示结果
from PIL import Image

image = Image.open(img_path).convert('RGB')
WenmuZhou's avatar
WenmuZhou committed
137
im_show = draw_ocr(image, result, txts=None, scores=None, font_path='/path/to/PaddleOCR/doc/fonts/simfang.ttf')
WenmuZhou's avatar
WenmuZhou committed
138
139
140
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')
```
141

WenmuZhou's avatar
WenmuZhou committed
142
结果是一个list,每个item只包含文本框
143

WenmuZhou's avatar
WenmuZhou committed
144
145
146
147
```bash
[[26.0, 457.0], [137.0, 457.0], [137.0, 477.0], [26.0, 477.0]]
[[25.0, 425.0], [372.0, 425.0], [372.0, 448.0], [25.0, 448.0]]
[[128.0, 397.0], [273.0, 397.0], [273.0, 414.0], [128.0, 414.0]]
WenmuZhou's avatar
WenmuZhou committed
148
......
WenmuZhou's avatar
WenmuZhou committed
149
```
150

WenmuZhou's avatar
WenmuZhou committed
151
152
153
154
155
156
157
158
结果可视化


<div align="center">
    <img src="../imgs_results/whl/11_det.jpg" width="800">
</div>

* 单独执行识别
159

WenmuZhou's avatar
WenmuZhou committed
160
161
```python
from paddleocr import PaddleOCR
162
163

ocr = PaddleOCR()  # need to run only once to download and load model into memory
WenmuZhou's avatar
WenmuZhou committed
164
img_path = 'PaddleOCR/doc/imgs_words/ch/word_1.jpg'
WenmuZhou's avatar
WenmuZhou committed
165
result = ocr.ocr(img_path, det=False)
WenmuZhou's avatar
WenmuZhou committed
166
167
168
for line in result:
    print(line)
```
169

WenmuZhou's avatar
WenmuZhou committed
170
结果是一个list,每个item只包含识别结果和识别置信度
171

WenmuZhou's avatar
WenmuZhou committed
172
173
174
175
```bash
['韩国小馆', 0.9907421]
```

WenmuZhou's avatar
WenmuZhou committed
176
* 单独执行方向分类器
177

WenmuZhou's avatar
WenmuZhou committed
178
179
```python
from paddleocr import PaddleOCR
180
181

ocr = PaddleOCR(use_angle_cls=True)  # need to run only once to download and load model into memory
WenmuZhou's avatar
WenmuZhou committed
182
183
184
185
186
img_path = 'PaddleOCR/doc/imgs_words/ch/word_1.jpg'
result = ocr.ocr(img_path, det=False, rec=False, cls=True)
for line in result:
    print(line)
```
187

WenmuZhou's avatar
WenmuZhou committed
188
结果是一个list,每个item只包含分类结果和分类置信度
189

WenmuZhou's avatar
WenmuZhou committed
190
191
192
193
```bash
['0', 0.9999924]
```

WenmuZhou's avatar
WenmuZhou committed
194
### 2.2 通过命令行使用
WenmuZhou's avatar
WenmuZhou committed
195
196

查看帮助信息
197

WenmuZhou's avatar
WenmuZhou committed
198
199
200
201
```bash
paddleocr -h
```

202
203
**注意** whl包默认使用`PP-OCRv3`模型,识别模型使用的输入shape为`3,48,320`, 因此如果使用识别功能,需要添加参数`--rec_image_shape 3,48,320`,如果不使用默认的`PP-OCRv3`模型,则无需设置该参数。

WenmuZhou's avatar
WenmuZhou committed
204
* 检测+方向分类器+识别全流程
205

WenmuZhou's avatar
WenmuZhou committed
206
```bash
207
paddleocr --image_dir PaddleOCR/doc/imgs/11.jpg --use_angle_cls true --rec_image_shape 3,48,320
WenmuZhou's avatar
WenmuZhou committed
208
```
209

WenmuZhou's avatar
WenmuZhou committed
210
结果是一个list,每个item包含了文本框,文字和识别置信度
211

WenmuZhou's avatar
WenmuZhou committed
212
```bash
213
[[[28.0, 37.0], [302.0, 39.0], [302.0, 72.0], [27.0, 70.0]], ('纯臻营养护发素', 0.9658738374710083)]
WenmuZhou's avatar
WenmuZhou committed
214
215
216
217
......
```

* 检测+识别
218

WenmuZhou's avatar
WenmuZhou committed
219
```bash
220
paddleocr --image_dir PaddleOCR/doc/imgs/11.jpg --rec_image_shape 3,48,320
WenmuZhou's avatar
WenmuZhou committed
221
```
222

WenmuZhou's avatar
WenmuZhou committed
223
结果是一个list,每个item包含了文本框,文字和识别置信度
224

WenmuZhou's avatar
WenmuZhou committed
225
```bash
226
[[[28.0, 37.0], [302.0, 39.0], [302.0, 72.0], [27.0, 70.0]], ('纯臻营养护发素', 0.9658738374710083)]
WenmuZhou's avatar
WenmuZhou committed
227
......
WenmuZhou's avatar
WenmuZhou committed
228
229
```

WenmuZhou's avatar
WenmuZhou committed
230
* 方向分类器+识别
231

WenmuZhou's avatar
WenmuZhou committed
232
```bash
233
paddleocr --image_dir PaddleOCR/doc/imgs_words/ch/word_1.jpg --use_angle_cls true --det false --rec_image_shape 3,48,320
WenmuZhou's avatar
WenmuZhou committed
234
235
236
```

结果是一个list,每个item只包含识别结果和识别置信度
237

WenmuZhou's avatar
WenmuZhou committed
238
```bash
239
['韩国小馆', 0.994467]
WenmuZhou's avatar
WenmuZhou committed
240
241
```

WenmuZhou's avatar
WenmuZhou committed
242
* 单独执行检测
243

WenmuZhou's avatar
WenmuZhou committed
244
245
246
```bash
paddleocr --image_dir PaddleOCR/doc/imgs/11.jpg --rec false
```
247

WenmuZhou's avatar
WenmuZhou committed
248
结果是一个list,每个item只包含文本框
249

WenmuZhou's avatar
WenmuZhou committed
250
```bash
251
252
[[27.0, 459.0], [136.0, 459.0], [136.0, 479.0], [27.0, 479.0]]
[[28.0, 429.0], [372.0, 429.0], [372.0, 445.0], [28.0, 445.0]]
WenmuZhou's avatar
WenmuZhou committed
253
......
WenmuZhou's avatar
WenmuZhou committed
254
255
256
```

* 单独执行识别
257

WenmuZhou's avatar
WenmuZhou committed
258
```bash
259
paddleocr --image_dir PaddleOCR/doc/imgs_words/ch/word_1.jpg --det false --rec_image_shape 3,48,320
WenmuZhou's avatar
WenmuZhou committed
260
261
262
```

结果是一个list,每个item只包含识别结果和识别置信度
263

WenmuZhou's avatar
WenmuZhou committed
264
```bash
265
['韩国小馆', 0.994467]
WenmuZhou's avatar
WenmuZhou committed
266
267
```

WenmuZhou's avatar
WenmuZhou committed
268
* 单独执行方向分类器
269

WenmuZhou's avatar
WenmuZhou committed
270
```bash
WenmuZhou's avatar
WenmuZhou committed
271
paddleocr --image_dir PaddleOCR/doc/imgs_words/ch/word_1.jpg --use_angle_cls true --det false --rec false
WenmuZhou's avatar
WenmuZhou committed
272
273
274
```

结果是一个list,每个item只包含分类结果和分类置信度
275

WenmuZhou's avatar
WenmuZhou committed
276
277
278
279
```bash
['0', 0.9999924]
```

WenmuZhou's avatar
WenmuZhou committed
280
## 3 自定义模型
281
282

当内置模型无法满足需求时,需要使用到自己训练的模型。 首先,参照[inference.md](./inference.md) 第一节转换将检测、分类和识别模型转换为inference模型,然后按照如下方式使用
WenmuZhou's avatar
WenmuZhou committed
283

WenmuZhou's avatar
WenmuZhou committed
284
### 3.1 代码使用
285

WenmuZhou's avatar
WenmuZhou committed
286
287
```python
from paddleocr import PaddleOCR, draw_ocr
288

WenmuZhou's avatar
WenmuZhou committed
289
# 模型路径下必须含有model和params文件
290
291
292
ocr = PaddleOCR(det_model_dir='{your_det_model_dir}', rec_model_dir='{your_rec_model_dir}',
                rec_char_dict_path='{your_rec_char_dict_path}', cls_model_dir='{your_cls_model_dir}',
                use_angle_cls=True)
WenmuZhou's avatar
WenmuZhou committed
293
img_path = 'PaddleOCR/doc/imgs/11.jpg'
WenmuZhou's avatar
WenmuZhou committed
294
result = ocr.ocr(img_path, cls=True)
WenmuZhou's avatar
WenmuZhou committed
295
296
297
298
299
for line in result:
    print(line)

# 显示结果
from PIL import Image
300

WenmuZhou's avatar
WenmuZhou committed
301
302
303
304
image = Image.open(img_path).convert('RGB')
boxes = [line[0] for line in result]
txts = [line[1][0] for line in result]
scores = [line[1][1] for line in result]
WenmuZhou's avatar
WenmuZhou committed
305
im_show = draw_ocr(image, boxes, txts, scores, font_path='/path/to/PaddleOCR/doc/fonts/simfang.ttf')
WenmuZhou's avatar
WenmuZhou committed
306
307
308
309
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')
```

WenmuZhou's avatar
WenmuZhou committed
310
### 3.2 通过命令行使用
WenmuZhou's avatar
WenmuZhou committed
311
312

```bash
WenmuZhou's avatar
WenmuZhou committed
313
paddleocr --image_dir PaddleOCR/doc/imgs/11.jpg --det_model_dir {your_det_model_dir} --rec_model_dir {your_rec_model_dir} --rec_char_dict_path {your_rec_char_dict_path} --cls_model_dir {your_cls_model_dir} --use_angle_cls true
WenmuZhou's avatar
WenmuZhou committed
314
315
```

WenmuZhou's avatar
WenmuZhou committed
316
## 4 使用网络图片或者numpy数组作为输入
WenmuZhou's avatar
WenmuZhou committed
317

WenmuZhou's avatar
WenmuZhou committed
318
### 4.1 网络图片
WenmuZhou's avatar
WenmuZhou committed
319

WenmuZhou's avatar
WenmuZhou committed
320
- 代码使用
321

WenmuZhou's avatar
WenmuZhou committed
322
```python
323
324
from paddleocr import PaddleOCR, draw_ocr, download_with_progressbar

WenmuZhou's avatar
WenmuZhou committed
325
326
# Paddleocr目前支持中英文、英文、法语、德语、韩语、日语,可以通过修改lang参数进行切换
# 参数依次为`ch`, `en`, `french`, `german`, `korean`, `japan`。
327
ocr = PaddleOCR(use_angle_cls=True, lang="ch")  # need to run only once to download and load model into memory
WenmuZhou's avatar
WenmuZhou committed
328
329
330
331
332
333
334
img_path = 'http://n.sinaimg.cn/ent/transform/w630h933/20171222/o111-fypvuqf1838418.jpg'
result = ocr.ocr(img_path, cls=True)
for line in result:
    print(line)

# 显示结果
from PIL import Image
335
336
337

download_with_progressbar(img_path, 'tmp.jpg')
image = Image.open('tmp.jpg').convert('RGB')
WenmuZhou's avatar
WenmuZhou committed
338
339
340
boxes = [line[0] for line in result]
txts = [line[1][0] for line in result]
scores = [line[1][1] for line in result]
WenmuZhou's avatar
WenmuZhou committed
341
im_show = draw_ocr(image, boxes, txts, scores, font_path='/path/to/PaddleOCR/doc/fonts/simfang.ttf')
WenmuZhou's avatar
WenmuZhou committed
342
343
344
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')
```
345

WenmuZhou's avatar
WenmuZhou committed
346
- 命令行模式
347

WenmuZhou's avatar
WenmuZhou committed
348
349
350
351
```bash
paddleocr --image_dir http://n.sinaimg.cn/ent/transform/w630h933/20171222/o111-fypvuqf1838418.jpg --use_angle_cls=true
```

WenmuZhou's avatar
WenmuZhou committed
352
### 4.2 numpy数组
353

WenmuZhou's avatar
WenmuZhou committed
354
仅通过代码使用时支持numpy数组作为输入
355

WenmuZhou's avatar
WenmuZhou committed
356
```python
WenmuZhou's avatar
WenmuZhou committed
357
import cv2
WenmuZhou's avatar
WenmuZhou committed
358
from paddleocr import PaddleOCR, draw_ocr
359

WenmuZhou's avatar
WenmuZhou committed
360
361
# Paddleocr目前支持中英文、英文、法语、德语、韩语、日语,可以通过修改lang参数进行切换
# 参数依次为`ch`, `en`, `french`, `german`, `korean`, `japan`。
362
ocr = PaddleOCR(use_angle_cls=True, lang="ch")  # need to run only once to download and load model into memory
WenmuZhou's avatar
WenmuZhou committed
363
364
365
img_path = 'PaddleOCR/doc/imgs/11.jpg'
img = cv2.imread(img_path)
# img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY), 如果你自己训练的模型支持灰度图,可以将这句话的注释取消
WenmuZhou's avatar
WenmuZhou committed
366
result = ocr.ocr(img, cls=True)
WenmuZhou's avatar
WenmuZhou committed
367
368
369
370
371
for line in result:
    print(line)

# 显示结果
from PIL import Image
372

WenmuZhou's avatar
WenmuZhou committed
373
374
375
376
image = Image.open(img_path).convert('RGB')
boxes = [line[0] for line in result]
txts = [line[1][0] for line in result]
scores = [line[1][1] for line in result]
WenmuZhou's avatar
WenmuZhou committed
377
im_show = draw_ocr(image, boxes, txts, scores, font_path='/path/to/PaddleOCR/doc/fonts/simfang.ttf')
WenmuZhou's avatar
WenmuZhou committed
378
379
380
381
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')
```

WenmuZhou's avatar
WenmuZhou committed
382
## 5 参数说明
WenmuZhou's avatar
WenmuZhou committed
383
384
385
386
387
388
389

| 字段                    | 说明                                                                                                                                                                                                                 | 默认值                  |
|-------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------|
| use_gpu                 | 是否使用GPU                                                                                                                                                                                                          | TRUE                    |
| gpu_mem                 | 初始化占用的GPU内存大小                                                                                                                                                                                              | 8000M                   |
| image_dir               | 通过命令行调用时执行预测的图片或文件夹路径                                                                                                                                                                           |                         |
| det_algorithm           | 使用的检测算法类型                                                                                                                                                                                                   | DB                      |
WenmuZhou's avatar
WenmuZhou committed
390
| det_model_dir          |  检测模型所在文件夹。传参方式有两种,1. None: 自动下载内置模型到 `~/.paddleocr/det`;2.自己转换好的inference模型路径,模型路径下必须包含model和params文件 |   None        |
WenmuZhou's avatar
WenmuZhou committed
391
392
393
394
395
396
397
398
| det_max_side_len        | 检测算法前向时图片长边的最大尺寸,当长边超出这个值时会将长边resize到这个大小,短边等比例缩放                                                                                                                         | 960                     |
| det_db_thresh           | DB模型输出预测图的二值化阈值                                                                                                                                                                                         | 0.3                     |
| det_db_box_thresh       | DB模型输出框的阈值,低于此值的预测框会被丢弃                                                                                                                                                                           | 0.5                     |
| det_db_unclip_ratio     | DB模型输出框扩大的比例                                                                                                                                                                                               | 2                       |
| det_east_score_thresh   | EAST模型输出预测图的二值化阈值                                                                                                                                                                                       | 0.8                     |
| det_east_cover_thresh   | EAST模型输出框的阈值,低于此值的预测框会被丢弃                                                                                                                                                                         | 0.1                     |
| det_east_nms_thresh     | EAST模型输出框NMS的阈值                                                                                                                                                                                              | 0.2                     |
| rec_algorithm           | 使用的识别算法类型                                                                                                                                                                                                   | CRNN                    |
WenmuZhou's avatar
WenmuZhou committed
399
| rec_model_dir          | 识别模型所在文件夹。传参方式有两种,1. None: 自动下载内置模型到 `~/.paddleocr/rec`;2.自己转换好的inference模型路径,模型路径下必须包含model和params文件 | None |
WenmuZhou's avatar
WenmuZhou committed
400
401
| rec_image_shape         | 识别算法的输入图片尺寸                                                                                                                                                                                             | "3,32,320"              |
| rec_batch_num           | 进行识别时,同时前向的图片数                                                                                                                                                                                         | 30                      |
WenmuZhou's avatar
WenmuZhou committed
402
403
| max_text_length         | 识别算法能识别的最大文字长度                                                                                                                                                                                         | 25                      |
| rec_char_dict_path      | 识别模型字典路径,当rec_model_dir使用方式2传参时需要修改为自己的字典路径                                                                                                                                                | ./ppocr/utils/ppocr_keys_v1.txt                        |
WenmuZhou's avatar
WenmuZhou committed
404
| use_space_char          | 是否识别空格                                                                                                                                                                                                         | TRUE                    |
WenmuZhou's avatar
WenmuZhou committed
405
| drop_score          | 对输出按照分数(来自于识别模型)进行过滤,低于此分数的不返回                                                                                                                                                                                                         | 0.5                    |
WenmuZhou's avatar
WenmuZhou committed
406
407
408
409
410
| use_angle_cls          | 是否加载分类模型                                                                                                                                                                                                         | FALSE                    |
| cls_model_dir          | 分类模型所在文件夹。传参方式有两种,1. None: 自动下载内置模型到 `~/.paddleocr/cls`;2.自己转换好的inference模型路径,模型路径下必须包含model和params文件                                                                                 | None                    |
| cls_image_shape          | 分类算法的输入图片尺寸                                                                           | "3, 48, 192"                    |
| label_list          | 分类算法的标签列表                                                                           | ['0', '180']                  |
| cls_batch_num          | 进行分类时,同时前向的图片数                                                                          |30                 |
WenmuZhou's avatar
WenmuZhou committed
411
| enable_mkldnn           | 是否启用mkldnn                                                                                                                                                                                                       | FALSE                   |
WenmuZhou's avatar
WenmuZhou committed
412
| use_zero_copy_run           | 是否通过zero_copy_run的方式进行前向                                                                                                                                                                               | FALSE                   |
WenmuZhou's avatar
WenmuZhou committed
413
| lang                     | 模型语言类型,目前支持 目前支持中英文(ch)、英文(en)、法语(french)、德语(german)、韩语(korean)、日语(japan)                                                                                                                                                                                               | ch                    |
WenmuZhou's avatar
WenmuZhou committed
414
415
| det                     | 前向时使用启动检测                                                                                                                                                                                                   | TRUE                    |
| rec                     | 前向时是否启动识别                                                                                                                                                                                                   | TRUE                    |
WenmuZhou's avatar
WenmuZhou committed
416
| cls                     | 前向时是否启动分类 (命令行模式下使用use_angle_cls控制前向是否启动分类)                                                                                                                                                                                                | FALSE                    |
WenmuZhou's avatar
WenmuZhou committed
417
| show_log                     | 是否打印logger信息                                                                                                                                               | FALSE                    |
WenmuZhou's avatar
WenmuZhou committed
418
| type                     | 执行ocr或者表格结构化, 值可选['ocr','structure']                                                                                                                                                                                             | ocr                    |
andyjpaddle's avatar
andyjpaddle committed
419
| ocr_version                     | OCR模型版本,可选PP-OCRv3, PP-OCRv2, PP-OCR。PP-OCRv3 支持中、英文的检测、识别、多语种识别,方向分类器等模型;PP-OCRv2 目前仅支持中文的检测和识别模型;PP-OCR支持中文的检测,识别,多语种识别,方向分类器等模型                                                                                                                                        | PP-OCRv3                   |