whl.md 23.2 KB
Newer Older
W
WenmuZhou 已提交
1 2
# paddleocr package使用说明

W
WenmuZhou 已提交
3
## 1 快速上手
W
WenmuZhou 已提交
4

W
WenmuZhou 已提交
5
### 1.1 安装whl包
W
WenmuZhou 已提交
6 7

pip安装
8

W
WenmuZhou 已提交
9
```bash
W
WenmuZhou 已提交
10
pip install "paddleocr>=2.0.1" # 推荐使用2.0.1+版本
W
WenmuZhou 已提交
11 12 13
```

本地构建并安装
14

W
WenmuZhou 已提交
15
```bash
W
WenmuZhou 已提交
16 17
python3 setup.py bdist_wheel
pip3 install dist/paddleocr-x.x.x-py3-none-any.whl # x.x.x是paddleocr的版本号
W
WenmuZhou 已提交
18 19
```

W
WenmuZhou 已提交
20
## 2 使用
21

W
WenmuZhou 已提交
22
### 2.1 代码使用
23

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

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

W
WenmuZhou 已提交
28 29
```python
from paddleocr import PaddleOCR, draw_ocr
30

W
WenmuZhou 已提交
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
W
WenmuZhou 已提交
34 35
img_path = 'PaddleOCR/doc/imgs/11.jpg'
result = ocr.ocr(img_path, cls=True)
A
andyjpaddle 已提交
36 37 38 39
for idx in range(len(result)):
    res = result[idx]
    for line in res:
        print(line)
W
WenmuZhou 已提交
40 41 42

# 显示结果
from PIL import Image
A
andyjpaddle 已提交
43
result = result[0]
W
WenmuZhou 已提交
44 45 46 47
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]
W
WenmuZhou 已提交
48
im_show = draw_ocr(image, boxes, txts, scores, font_path='/path/to/PaddleOCR/doc/fonts/simfang.ttf')
W
WenmuZhou 已提交
49 50 51
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')
```
52

W
WenmuZhou 已提交
53
结果是一个list,每个item包含了文本框,文字和识别置信度
54

W
WenmuZhou 已提交
55 56 57 58 59 60
```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]]
......
```
61

W
WenmuZhou 已提交
62 63 64 65 66 67 68
结果可视化

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

* 检测+识别
69

W
WenmuZhou 已提交
70 71
```python
from paddleocr import PaddleOCR, draw_ocr
72 73

ocr = PaddleOCR()  # need to run only once to download and load model into memory
W
WenmuZhou 已提交
74
img_path = 'PaddleOCR/doc/imgs/11.jpg'
75
result = ocr.ocr(img_path, cls=False)
A
andyjpaddle 已提交
76 77 78 79
for idx in range(len(result)):
    res = result[idx]
    for line in res:
        print(line)
W
WenmuZhou 已提交
80 81 82

# 显示结果
from PIL import Image
A
andyjpaddle 已提交
83
result = result[0]
W
WenmuZhou 已提交
84 85 86 87
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]
W
WenmuZhou 已提交
88
im_show = draw_ocr(image, boxes, txts, scores, font_path='/path/to/PaddleOCR/doc/fonts/simfang.ttf')
W
WenmuZhou 已提交
89 90 91
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')
```
92

W
WenmuZhou 已提交
93
结果是一个list,每个item包含了文本框,文字和识别置信度
94

W
WenmuZhou 已提交
95 96 97 98
```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]]
W
WenmuZhou 已提交
99
......
W
WenmuZhou 已提交
100
```
101

W
WenmuZhou 已提交
102 103 104 105 106 107
结果可视化

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

W
WenmuZhou 已提交
108
* 方向分类器+识别
109

W
WenmuZhou 已提交
110 111
```python
from paddleocr import PaddleOCR
112 113

ocr = PaddleOCR(use_angle_cls=True)  # need to run only once to download and load model into memory
W
WenmuZhou 已提交
114 115
img_path = 'PaddleOCR/doc/imgs_words/ch/word_1.jpg'
result = ocr.ocr(img_path, det=False, cls=True)
A
andyjpaddle 已提交
116 117 118 119
for idx in range(len(result)):
    res = result[idx]
    for line in res:
        print(line)
W
WenmuZhou 已提交
120
```
121

W
WenmuZhou 已提交
122
结果是一个list,每个item只包含识别结果和识别置信度
123

W
WenmuZhou 已提交
124 125 126 127
```bash
['韩国小馆', 0.9907421]
```

W
WenmuZhou 已提交
128
* 单独执行检测
129

W
WenmuZhou 已提交
130 131
```python
from paddleocr import PaddleOCR, draw_ocr
132 133

ocr = PaddleOCR()  # need to run only once to download and load model into memory
W
WenmuZhou 已提交
134
img_path = 'PaddleOCR/doc/imgs/11.jpg'
W
WenmuZhou 已提交
135
result = ocr.ocr(img_path, rec=False)
A
andyjpaddle 已提交
136 137 138 139
for idx in range(len(result)):
    res = result[idx]
    for line in res:
        print(line)
W
WenmuZhou 已提交
140 141 142

# 显示结果
from PIL import Image
A
andyjpaddle 已提交
143
result = result[0]
W
WenmuZhou 已提交
144
image = Image.open(img_path).convert('RGB')
W
WenmuZhou 已提交
145
im_show = draw_ocr(image, result, txts=None, scores=None, font_path='/path/to/PaddleOCR/doc/fonts/simfang.ttf')
W
WenmuZhou 已提交
146 147 148
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')
```
149

W
WenmuZhou 已提交
150
结果是一个list,每个item只包含文本框
151

W
WenmuZhou 已提交
152 153 154 155
```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]]
W
WenmuZhou 已提交
156
......
W
WenmuZhou 已提交
157
```
158

W
WenmuZhou 已提交
159 160 161 162 163 164 165 166
结果可视化


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

* 单独执行识别
167

W
WenmuZhou 已提交
168 169
```python
from paddleocr import PaddleOCR
170 171

ocr = PaddleOCR()  # need to run only once to download and load model into memory
W
WenmuZhou 已提交
172
img_path = 'PaddleOCR/doc/imgs_words/ch/word_1.jpg'
W
WenmuZhou 已提交
173
result = ocr.ocr(img_path, det=False)
A
andyjpaddle 已提交
174 175 176 177
for idx in range(len(result)):
    res = result[idx]
    for line in res:
        print(line)
W
WenmuZhou 已提交
178
```
179

W
WenmuZhou 已提交
180
结果是一个list,每个item只包含识别结果和识别置信度
181

W
WenmuZhou 已提交
182 183 184 185
```bash
['韩国小馆', 0.9907421]
```

W
WenmuZhou 已提交
186
* 单独执行方向分类器
187

W
WenmuZhou 已提交
188 189
```python
from paddleocr import PaddleOCR
190 191

ocr = PaddleOCR(use_angle_cls=True)  # need to run only once to download and load model into memory
W
WenmuZhou 已提交
192 193
img_path = 'PaddleOCR/doc/imgs_words/ch/word_1.jpg'
result = ocr.ocr(img_path, det=False, rec=False, cls=True)
A
andyjpaddle 已提交
194 195 196 197
for idx in range(len(result)):
    res = result[idx]
    for line in res:
        print(line)
W
WenmuZhou 已提交
198
```
199

W
WenmuZhou 已提交
200
结果是一个list,每个item只包含分类结果和分类置信度
201

W
WenmuZhou 已提交
202 203 204 205
```bash
['0', 0.9999924]
```

W
WenmuZhou 已提交
206
### 2.2 通过命令行使用
W
WenmuZhou 已提交
207 208

查看帮助信息
209

W
WenmuZhou 已提交
210 211 212 213
```bash
paddleocr -h
```

W
WenmuZhou 已提交
214
* 检测+方向分类器+识别全流程
215

W
WenmuZhou 已提交
216
```bash
A
andyjpaddle 已提交
217
paddleocr --image_dir PaddleOCR/doc/imgs/11.jpg --use_angle_cls true
W
WenmuZhou 已提交
218
```
219

W
WenmuZhou 已提交
220
结果是一个list,每个item包含了文本框,文字和识别置信度
221

W
WenmuZhou 已提交
222
```bash
223
[[[28.0, 37.0], [302.0, 39.0], [302.0, 72.0], [27.0, 70.0]], ('纯臻营养护发素', 0.9658738374710083)]
W
WenmuZhou 已提交
224 225 226
......
```

A
andyjpaddle 已提交
227 228 229 230 231
此外,paddleocr也支持输入pdf文件,并且可以通过指定参数`page_num`来控制推理前面几页,默认为0,表示推理所有页。
```bash
paddleocr --image_dir ./xxx.pdf --use_angle_cls true --use_gpu false --page_num 2
```

W
WenmuZhou 已提交
232
* 检测+识别
233

W
WenmuZhou 已提交
234
```bash
A
andyjpaddle 已提交
235
paddleocr --image_dir PaddleOCR/doc/imgs/11.jpg
W
WenmuZhou 已提交
236
```
237

W
WenmuZhou 已提交
238
结果是一个list,每个item包含了文本框,文字和识别置信度
239

W
WenmuZhou 已提交
240
```bash
241
[[[28.0, 37.0], [302.0, 39.0], [302.0, 72.0], [27.0, 70.0]], ('纯臻营养护发素', 0.9658738374710083)]
W
WenmuZhou 已提交
242
......
W
WenmuZhou 已提交
243 244
```

W
WenmuZhou 已提交
245
* 方向分类器+识别
246

W
WenmuZhou 已提交
247
```bash
A
andyjpaddle 已提交
248
paddleocr --image_dir PaddleOCR/doc/imgs_words/ch/word_1.jpg --use_angle_cls true --det false
W
WenmuZhou 已提交
249 250 251
```

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

W
WenmuZhou 已提交
253
```bash
254
['韩国小馆', 0.994467]
W
WenmuZhou 已提交
255 256
```

W
WenmuZhou 已提交
257
* 单独执行检测
258

W
WenmuZhou 已提交
259 260 261
```bash
paddleocr --image_dir PaddleOCR/doc/imgs/11.jpg --rec false
```
262

W
WenmuZhou 已提交
263
结果是一个list,每个item只包含文本框
264

W
WenmuZhou 已提交
265
```bash
266 267
[[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]]
W
WenmuZhou 已提交
268
......
W
WenmuZhou 已提交
269 270 271
```

* 单独执行识别
272

W
WenmuZhou 已提交
273
```bash
A
andyjpaddle 已提交
274
paddleocr --image_dir PaddleOCR/doc/imgs_words/ch/word_1.jpg --det false
W
WenmuZhou 已提交
275 276 277
```

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

W
WenmuZhou 已提交
279
```bash
280
['韩国小馆', 0.994467]
W
WenmuZhou 已提交
281 282
```

W
WenmuZhou 已提交
283
* 单独执行方向分类器
284

W
WenmuZhou 已提交
285
```bash
W
WenmuZhou 已提交
286
paddleocr --image_dir PaddleOCR/doc/imgs_words/ch/word_1.jpg --use_angle_cls true --det false --rec false
W
WenmuZhou 已提交
287 288 289
```

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

W
WenmuZhou 已提交
291 292 293 294
```bash
['0', 0.9999924]
```

W
WenmuZhou 已提交
295
## 3 自定义模型
296 297

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

W
WenmuZhou 已提交
299
### 3.1 代码使用
300

W
WenmuZhou 已提交
301 302
```python
from paddleocr import PaddleOCR, draw_ocr
303

W
WenmuZhou 已提交
304
# 模型路径下必须含有model和params文件
305 306 307
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)
W
WenmuZhou 已提交
308
img_path = 'PaddleOCR/doc/imgs/11.jpg'
W
WenmuZhou 已提交
309
result = ocr.ocr(img_path, cls=True)
A
andyjpaddle 已提交
310 311 312 313
for idx in range(len(result)):
    res = result[idx]
    for line in res:
        print(line)
W
WenmuZhou 已提交
314 315 316

# 显示结果
from PIL import Image
A
andyjpaddle 已提交
317
result = result[0]
W
WenmuZhou 已提交
318 319 320 321
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]
W
WenmuZhou 已提交
322
im_show = draw_ocr(image, boxes, txts, scores, font_path='/path/to/PaddleOCR/doc/fonts/simfang.ttf')
W
WenmuZhou 已提交
323 324 325 326
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')
```

W
WenmuZhou 已提交
327
### 3.2 通过命令行使用
W
WenmuZhou 已提交
328 329

```bash
W
WenmuZhou 已提交
330
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
W
WenmuZhou 已提交
331 332
```

W
WenmuZhou 已提交
333
## 4 使用网络图片或者numpy数组作为输入
W
WenmuZhou 已提交
334

W
WenmuZhou 已提交
335
### 4.1 网络图片
W
WenmuZhou 已提交
336

W
WenmuZhou 已提交
337
- 代码使用
338

W
WenmuZhou 已提交
339
```python
340 341
from paddleocr import PaddleOCR, draw_ocr, download_with_progressbar

W
WenmuZhou 已提交
342 343
# Paddleocr目前支持中英文、英文、法语、德语、韩语、日语,可以通过修改lang参数进行切换
# 参数依次为`ch`, `en`, `french`, `german`, `korean`, `japan`。
344
ocr = PaddleOCR(use_angle_cls=True, lang="ch")  # need to run only once to download and load model into memory
W
WenmuZhou 已提交
345 346
img_path = 'http://n.sinaimg.cn/ent/transform/w630h933/20171222/o111-fypvuqf1838418.jpg'
result = ocr.ocr(img_path, cls=True)
A
andyjpaddle 已提交
347 348 349 350
for idx in range(len(result)):
    res = result[idx]
    for line in res:
        print(line)
W
WenmuZhou 已提交
351 352 353

# 显示结果
from PIL import Image
A
andyjpaddle 已提交
354
result = result[0]
355 356
download_with_progressbar(img_path, 'tmp.jpg')
image = Image.open('tmp.jpg').convert('RGB')
W
WenmuZhou 已提交
357 358 359
boxes = [line[0] for line in result]
txts = [line[1][0] for line in result]
scores = [line[1][1] for line in result]
W
WenmuZhou 已提交
360
im_show = draw_ocr(image, boxes, txts, scores, font_path='/path/to/PaddleOCR/doc/fonts/simfang.ttf')
W
WenmuZhou 已提交
361 362 363
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')
```
364

W
WenmuZhou 已提交
365
- 命令行模式
366

W
WenmuZhou 已提交
367 368 369 370
```bash
paddleocr --image_dir http://n.sinaimg.cn/ent/transform/w630h933/20171222/o111-fypvuqf1838418.jpg --use_angle_cls=true
```

W
WenmuZhou 已提交
371
### 4.2 numpy数组
372

W
WenmuZhou 已提交
373
仅通过代码使用时支持numpy数组作为输入
374

W
WenmuZhou 已提交
375
```python
W
WenmuZhou 已提交
376
import cv2
W
WenmuZhou 已提交
377
from paddleocr import PaddleOCR, draw_ocr
378

W
WenmuZhou 已提交
379 380
# Paddleocr目前支持中英文、英文、法语、德语、韩语、日语,可以通过修改lang参数进行切换
# 参数依次为`ch`, `en`, `french`, `german`, `korean`, `japan`。
381
ocr = PaddleOCR(use_angle_cls=True, lang="ch")  # need to run only once to download and load model into memory
W
WenmuZhou 已提交
382 383 384
img_path = 'PaddleOCR/doc/imgs/11.jpg'
img = cv2.imread(img_path)
# img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY), 如果你自己训练的模型支持灰度图,可以将这句话的注释取消
W
WenmuZhou 已提交
385
result = ocr.ocr(img, cls=True)
A
andyjpaddle 已提交
386 387 388 389
for idx in range(len(result)):
    res = result[idx]
    for line in res:
        print(line)
W
WenmuZhou 已提交
390 391 392

# 显示结果
from PIL import Image
A
andyjpaddle 已提交
393
result = result[0]
W
WenmuZhou 已提交
394 395 396 397
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]
W
WenmuZhou 已提交
398
im_show = draw_ocr(image, boxes, txts, scores, font_path='/path/to/PaddleOCR/doc/fonts/simfang.ttf')
W
WenmuZhou 已提交
399 400 401
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')
```
A
andyjpaddle 已提交
402 403 404 405 406 407 408 409 410 411 412
## 5 PDF文件作为输入
- 命令行模式

可以通过指定参数`page_num`来控制推理前面几页,默认为0,表示推理所有页。
```bash
paddleocr --image_dir ./xxx.pdf --use_angle_cls true --use_gpu false --page_num 2
```
- 代码使用

```python
from paddleocr import PaddleOCR, draw_ocr
W
WenmuZhou 已提交
413

A
andyjpaddle 已提交
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453
# Paddleocr目前支持的多语言语种可以通过修改lang参数进行切换
# 例如`ch`, `en`, `fr`, `german`, `korean`, `japan`
ocr = PaddleOCR(use_angle_cls=True, lang="ch" page_num=2)  # need to run only once to download and load model into memory
img_path = './xxx.pdf'
result = ocr.ocr(img_path, cls=True)
for idx in range(len(result)):
    res = result[idx]
    for line in res:
        print(line)

# 显示结果
import fitz
from PIL import Image
import cv2
import numpy as np
imgs = []
with fitz.open(img_path) as pdf:
    for pg in range(0, pdf.pageCount):
        page = pdf[pg]
        mat = fitz.Matrix(2, 2)
        pm = page.getPixmap(matrix=mat, alpha=False)
        # if width or height > 2000 pixels, don't enlarge the image
        if pm.width > 2000 or pm.height > 2000:
            pm = page.getPixmap(matrix=fitz.Matrix(1, 1), alpha=False)

        img = Image.frombytes("RGB", [pm.width, pm.height], pm.samples)
        img = cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR)
        imgs.append(img)
for idx in range(len(result)):
    res = result[idx]
    image = imgs[idx]
    boxes = [line[0] for line in res]
    txts = [line[1][0] for line in res]
    scores = [line[1][1] for line in res]
    im_show = draw_ocr(image, boxes, txts, scores, font_path='doc/fonts/simfang.ttf')
    im_show = Image.fromarray(im_show)
    im_show.save('result_page_{}.jpg'.format(idx))
```

## 6 参数说明
W
WenmuZhou 已提交
454 455 456 457 458

| 字段                    | 说明                                                                                                                                                                                                                 | 默认值                  |
|-------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------|
| use_gpu                 | 是否使用GPU                                                                                                                                                                                                          | TRUE                    |
| gpu_mem                 | 初始化占用的GPU内存大小                                                                                                                                                                                              | 8000M                   |
A
andyjpaddle 已提交
459 460
| image_dir               | 通过命令行调用时执行预测的图片或文件夹路径                                                                                                                                                                           |  
| page_num               | 当输入类型为pdf文件时有效,指定预测前面page_num页,默认预测所有页                     |        0                 |
W
WenmuZhou 已提交
461
| det_algorithm           | 使用的检测算法类型                                                                                                                                                                                                   | DB                      |
W
WenmuZhou 已提交
462
| det_model_dir          |  检测模型所在文件夹。传参方式有两种,1. None: 自动下载内置模型到 `~/.paddleocr/det`;2.自己转换好的inference模型路径,模型路径下必须包含model和params文件 |   None        |
W
WenmuZhou 已提交
463 464 465 466
| 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                       |
L
LDOUBLEV 已提交
467
| det_db_score_mode |  计算检测框score的方式,有'fast'和'slow',如果要检测的文字有弯曲,建议用'slow','slow'模式计算的box的score偏大,box不容易被过滤掉  | 'fast' |
W
WenmuZhou 已提交
468 469 470 471
| 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                    |
W
WenmuZhou 已提交
472
| rec_model_dir          | 识别模型所在文件夹。传参方式有两种,1. None: 自动下载内置模型到 `~/.paddleocr/rec`;2.自己转换好的inference模型路径,模型路径下必须包含model和params文件 | None |
W
WenmuZhou 已提交
473 474
| rec_image_shape         | 识别算法的输入图片尺寸                                                                                                                                                                                             | "3,32,320"              |
| rec_batch_num           | 进行识别时,同时前向的图片数                                                                                                                                                                                         | 30                      |
W
WenmuZhou 已提交
475 476
| max_text_length         | 识别算法能识别的最大文字长度                                                                                                                                                                                         | 25                      |
| rec_char_dict_path      | 识别模型字典路径,当rec_model_dir使用方式2传参时需要修改为自己的字典路径                                                                                                                                                | ./ppocr/utils/ppocr_keys_v1.txt                        |
W
WenmuZhou 已提交
477
| use_space_char          | 是否识别空格                                                                                                                                                                                                         | TRUE                    |
W
WenmuZhou 已提交
478
| drop_score          | 对输出按照分数(来自于识别模型)进行过滤,低于此分数的不返回                                                                                                                                                                                                         | 0.5                    |
W
WenmuZhou 已提交
479 480 481 482 483
| 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                 |
W
WenmuZhou 已提交
484
| enable_mkldnn           | 是否启用mkldnn                                                                                                                                                                                                       | FALSE                   |
W
WenmuZhou 已提交
485
| use_zero_copy_run           | 是否通过zero_copy_run的方式进行前向                                                                                                                                                                               | FALSE                   |
W
WenmuZhou 已提交
486
| lang                     | 模型语言类型,目前支持 目前支持中英文(ch)、英文(en)、法语(french)、德语(german)、韩语(korean)、日语(japan)                                                                                                                                                                                               | ch                    |
W
WenmuZhou 已提交
487 488
| det                     | 前向时使用启动检测                                                                                                                                                                                                   | TRUE                    |
| rec                     | 前向时是否启动识别                                                                                                                                                                                                   | TRUE                    |
W
WenmuZhou 已提交
489
| cls                     | 前向时是否启动分类 (命令行模式下使用use_angle_cls控制前向是否启动分类)                                                                                                                                                                                                | FALSE                    |
文幕地方's avatar
文幕地方 已提交
490
| show_log                     | 是否打印logger信息                                                                                                                                               | FALSE                    |
W
WenmuZhou 已提交
491
| type                     | 执行ocr或者表格结构化, 值可选['ocr','structure']                                                                                                                                                                                             | ocr                    |
A
andyjpaddle 已提交
492
| ocr_version                     | OCR模型版本,可选PP-OCRv3, PP-OCRv2, PP-OCR。PP-OCRv3 支持中、英文的检测、识别、多语种识别,方向分类器等模型;PP-OCRv2 目前仅支持中文的检测和识别模型;PP-OCR支持中文的检测,识别,多语种识别,方向分类器等模型                                                                                                                                        | PP-OCRv3                   |