64 Star 376 Fork 174

PaddlePaddle/PaddleNLP

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

基于PaddleNLP SimpleServing 的服务化部署

目录

环境准备

使用有SimpleServing功能的PaddleNLP版本(或者最新的develop版本)

pip install paddlenlp >= 2.4.4

Server服务启动

paddlenlp server server:app --workers 1 --host 0.0.0.0 --port 8189

Client请求启动

python client.py

服务化自定义参数

Server 自定义参数

schema替换

# Default schema
schema = ['开票日期', '名称', '纳税人识别号', '开户行及账号', '金额', '价税合计', 'No', '税率', '地址、电话', '税额']

设置模型路径

# Default task_path
uie = Taskflow('information_extraction', task_path='../../checkpoint/model_best/', schema=schema)

多卡服务化预测

PaddleNLP SimpleServing 支持多卡负载均衡预测,主要在服务化注册的时候,注册两个Taskflow的task即可,下面是示例代码

uie1 = Taskflow('information_extraction', task_path='../../checkpoint/model_best/', schema=schema, device_id=0)
uie2 = Taskflow('information_extraction', task_path='../../checkpoint/model_best/', schema=schema, device_id=1)
service.register_taskflow('uie', [uie1, uie2])

Client 自定义参数

# Changed to image paths you wanted
image_paths = ['../../data/images/b1.jpg']
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/paddlepaddle/PaddleNLP.git
git@gitee.com:paddlepaddle/PaddleNLP.git
paddlepaddle
PaddleNLP
PaddleNLP
v2.5.2

搜索帮助