PaddleServing搭建
PaddleServing搭建

PaddleServing搭建

https://github.com/PaddlePaddle/PaddleOCR/tree/release/2.4/deploy/hubserving

1.安装python3.8

https://www.python.org/ftp/python/3.8.10/python-3.8.10-amd64.exe

2.安装git

https://git-scm.com/download/win

3.安装wget

https://phoenixnap.dl.sourceforge.net/project/gnuwin32/wget/1.11.4-1/wget-1.11.4-1-setup.exe

下载运行,默认路径安装

添加环境变量 C:\Program Files (x86)\GnuWin32\bin

4.clone PaddleServing 和 下载模型

//clone 源码
git clone https://github.com/PaddlePaddle/Serving.git

或使用镜像站
git clone https://api.mtr.pub/PaddlePaddle/Serving.git
git clone https://ghproxy.fsofso.com/https://github.com/PaddlePaddle/Serving.git
git clone https://hub.fastgit.xyz/PaddlePaddle/Serving.git

//下载模型,参考  .\Serving\examples\C++\PaddleOCR\ocr\README_CN.md  的  ## 获取模型
//可自行下载解压
wget https://paddle-serving.bj.bcebos.com/paddle_hub_models/image/OCR/ocr_rec.tar.gz --no-check-certificate
wget https://paddle-serving.bj.bcebos.com/ocr/ocr_det.tar.gz

//解压后需存在以下路径
.\Serving\examples\C++\PaddleOCR\ocr\ocr_rec_model
.\Serving\examples\C++\PaddleOCR\ocr\ocr_rec_client
.\Serving\examples\C++\PaddleOCR\ocr\ocr_det_model
.\Serving\examples\C++\PaddleOCR\ocr\ocr_det_client

4.pip安装环境

pip install -r requirements.txt

5.运行

#启动OCR服务,其他启动方式参考↓
#.\Serving\examples\C++\PaddleOCR\ocr\README_CN.md

#for cpu user
python ocr_debugger_server.py cpu 
#for gpu user
python ocr_debugger_server.py gpu 

附按键对接代码

Import "Cjson.lua"
Import "zm.luae"
Dim data="{""feed"": [{""image"": """&zm.FileReadBinaryBase64("/sdcard/pictures/1.png")&"""}], ""fetch"": [""res""]}"
Dim t={"url":"http://你的显示的ip:9292/ocr/prediction","data":data, "header":{"Content-Type":"application/json"}}
dim 返回值 = Url.HttpPost(t)
TracePrint 返回值
Dim ta=Cjson.Decode(返回值)
Dim tt=ta["result"]["res"]
TracePrint Cjson.Encode(tt)
For Each v In tt
    TracePrint v
Next

PS:

1.WinServer2012 R2遇到的

ImportError: DLL load failed while importing cv2: 找不到指定的模块。

解决方案:

https://blog.csdn.net/XHW___001/article/details/85783582

服务管理器->”添加角色和功能”->”用户界面和基础结构”->”桌面体验”->安装

image-20220914032748904

image-20220914032813121

2.无法建立SSL连接

解决方案:

1.打开服务器出网443端口

2.wget后面加上参数 –no-check-certificate