Files
FastDeploy/examples/vision/ocr/PP-OCR/web/README.md
yunyaoXYY f36f9324de [Docs] Pick PPOCR fastdeploy docs from PaddleOCR (#1534)
* Pick PPOCR fastdeploy docs from PaddleOCR

* improve ppocr

* improve readme

* remove old PP-OCRv2 and PP-OCRv3 folfers

* rename kunlun to kunlunxin

* improve readme

* improve readme

* improve readme

---------

Co-authored-by: Jason <jiangjiajun@baidu.com>
Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com>
2023-03-23 13:11:19 +08:00

34 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[English](README.md) | 简体中文
# PP-OCRv3 前端部署示例
本节介绍部署PaddleOCR的PP-OCRv3模型在浏览器中运行以及@paddle-js-models/ocr npm包中的js接口。
## 1. 前端部署PP-OCRv3模型
PP-OCRv3模型web demo使用[**参考文档**](https://github.com/PaddlePaddle/FastDeploy/tree/develop/examples/application/js/web_demo)
## 2. PP-OCRv3 js接口
```
import * as ocr from "@paddle-js-models/ocr";
await ocr.init(detConfig, recConfig);
const res = await ocr.recognize(img, option, postConfig);
```
ocr模型加载和初始化其中模型为Paddle.js模型格式js模型转换方式参考[文档](https://github.com/PaddlePaddle/FastDeploy/tree/develop/examples/application/js/web_demo/README.md)
**init函数参数**
> * **detConfig**(dict): 文本检测模型配置参数,默认值为 {modelPath: 'https://js-models.bj.bcebos.com/PaddleOCR/PP-OCRv3/ch_PP-OCRv3_det_infer_js_960/model.json', fill: '#fff', mean: [0.485, 0.456, 0.406],std: [0.229, 0.224, 0.225]}; 其中modelPath为文本检测模型路径fill 为图像预处理padding的值mean和std分别为预处理的均值和标准差
> * **recConfig**(dict)): 文本识别模型配置参数,默认值为 {modelPath: 'https://js-models.bj.bcebos.com/PaddleOCR/PP-OCRv3/ch_PP-OCRv3_rec_infer_js/model.json', fill: '#000', mean: [0.5, 0.5, 0.5], std: [0.5, 0.5, 0.5]}; 其中modelPath为文本检测模型路径fill 为图像预处理padding的值mean和std分别为预处理的均值和标准差
**recognize函数参数**
> * **img**(HTMLImageElement): 输入图像参数类型为HTMLImageElement。
> * **option**(dict): 可视化文本检测框的canvas参数可不用设置。
> * **postConfig**(dict): 文本检测后处理参数,默认值为:{shape: 960, thresh: 0.3, box_thresh: 0.6, unclip_ratio:1.5}; thresh是输出预测图的二值化阈值box_thresh是输出框的阈值低于此值的预测框会被丢弃unclip_ratio是输出框扩大的比例。
## 其它文档
- [PP-OCRv3 微信小程序部署文档](https://github.com/PaddlePaddle/FastDeploy/tree/develop/examples/application/js/mini_program)