@@ -413,7 +413,7 @@ paddleocr text_recognition -i https://paddle-model-ecology.bj.bcebos.com/paddlex
413
413
414
414
``` python
415
415
from paddleocr import TextRecognition
416
- model = TextRecognition(model_name = " PP-OCRv4_mobile_rec " )
416
+ model = TextRecognition(model_name = " PP-OCRv5_server_rec " )
417
417
output = model.predict(input = " general_ocr_rec_001.png" , batch_size = 1 )
418
418
for res in output:
419
419
res.print()
@@ -423,7 +423,7 @@ for res in output:
423
423
424
424
运行后,得到的结果为:
425
425
``` bash
426
- {' res' : {' input_path' : ' general_ocr_rec_001.png' , ' page_index' : None, ' rec_text' : ' 绿洲仕格维花园公寓' , ' rec_score' : 0.9875142574310303 }}
426
+ {' res' : {' input_path' : ' general_ocr_rec_001.png' , ' page_index' : None, ' rec_text' : ' 绿洲仕格维花园公寓' , ' rec_score' : 0.9823867082595825 }}
427
427
```
428
428
429
429
运行结果参数含义如下:
@@ -439,7 +439,7 @@ for res in output:
439
439
440
440
相关方法、参数等说明如下:
441
441
442
- * ` TextRecognition ` 实例化文本识别模型(此处以` PP-OCRv4_mobile_rec ` 为例),具体说明如下:
442
+ * ` TextRecognition ` 实例化文本识别模型(此处以` PP-OCRv5_server_rec ` 为例),具体说明如下:
443
443
<table >
444
444
<thead >
445
445
<tr >
@@ -610,7 +610,7 @@ for res in output:
610
610
611
611
## 四、二次开发
612
612
613
- 如果以上模型在您的场景上效果仍然不理想,您可以尝试以下步骤进行二次开发,此处以训练 ` PP-OCRv5_server_rec ` 举例,其他模型替换对应配置文件即可。首先,您需要准备文本识别的数据集,可以参考[ 文本识别 Demo 数据] ( https://paddle-model-ecology.bj.bcebos.com/paddlex/data/ocr_rec_dataset_examples.tar ) 的格式准备,准备好后,即可按照以下步骤进行模型训练和导出,导出后,可以将模型快速集成到上述 API 中。此处以文本识别 Demo 数据示例。在训练模型之前,请确保已经按照[ 安装文档] ( xxx ) 安装了 PaddleOCR 所需要的依赖。
613
+ 如果以上模型在您的场景上效果仍然不理想,您可以尝试以下步骤进行二次开发,此处以训练 ` PP-OCRv5_server_rec ` 举例,其他模型替换对应配置文件即可。首先,您需要准备文本识别的数据集,可以参考[ 文本识别 Demo 数据] ( https://paddle-model-ecology.bj.bcebos.com/paddlex/data/ocr_rec_dataset_examples.tar ) 的格式准备,准备好后,即可按照以下步骤进行模型训练和导出,导出后,可以将模型快速集成到上述 API 中。此处以文本识别 Demo 数据示例。在训练模型之前,请确保已经按照[ 安装文档] ( ../installation.md ) 安装了 PaddleOCR 所需要的依赖。
614
614
615
615
616
616
## 4.1 数据集、预训练模型准备
@@ -649,21 +649,21 @@ python3 -m paddle.distributed.launch --gpus '0,1,2,3' tools/train.py -c configs
649
649
650
650
### 4.4 模型评估
651
651
652
- 您可以评估已经训练好的权重,如,` output/xxx/xxx.pdprams ` ,使用如下命令进行评估:
652
+ 您可以评估已经训练好的权重,如,` output/xxx/xxx.pdparams ` ,使用如下命令进行评估:
653
653
654
654
``` bash
655
655
# 注意将pretrained_model的路径设置为本地路径。若使用自行训练保存的模型,请注意修改路径和文件名为{path/to/weights}/{model_name}。
656
656
# demo 测试集评估
657
657
python3 tools/eval.py -c configs/rec/PP-OCRv5/PP-OCRv5_server_rec.yml -o \
658
- Global.pretrained_model=output/xxx/xxx.pdprams
658
+ Global.pretrained_model=output/xxx/xxx.pdparams
659
659
```
660
660
661
661
### 4.5 模型导出
662
662
663
663
``` bash
664
664
python3 tools/export_model.py -c configs/rec/PP-OCRv5/PP-OCRv5_server_rec.yml -o \
665
- Global.pretrained_model=output/xxx/xxx.pdprams \
666
- save_inference_dir=" ./PP-OCRv5_server_rec_infer/"
665
+ Global.pretrained_model=output/xxx/xxx.pdparams \
666
+ Global. save_inference_dir=" ./PP-OCRv5_server_rec_infer/"
667
667
```
668
668
669
669
导出模型后,静态图模型会存放于当前目录的` ./PP-OCRv5_server_rec_infer/ ` 中,在该目录下,您将看到如下文件:
0 commit comments