mirror of
				https://github.com/PaddlePaddle/FastDeploy.git
				synced 2025-10-31 20:02:53 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			42 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			42 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
| 
 | ||
| # PP-OCRv3 微信小程序部署示例
 | ||
| 
 | ||
| 本节介绍部署PaddleOCR的PP-OCRv3模型在微信小程序中运行,以及@paddle-js-models/ocr npm包中的js接口。
 | ||
| 
 | ||
| 
 | ||
| ## 微信小程序部署PP-OCRv3模型
 | ||
| 
 | ||
| PP-OCRv3模型部署到微信小程序[**参考文档**](../../../../application/js/mini_program)
 | ||
| 
 | ||
| 
 | ||
| ## 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模型转换方式参考[文档](../../../../application/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-OCR 系列模型介绍](../../)
 | ||
| - [PP-OCRv3 C++部署](../cpp)
 | ||
| - [模型预测结果说明](../../../../../docs/api/vision_results/)
 | ||
| - [如何切换模型推理后端引擎](../../../../../docs/cn/faq/how_to_change_backend.md)
 | ||
| - [PP-OCRv3模型web demo文档](../../../../application/web_demo/README.md)
 | ||
| 
 | 
