AI开发平台ModelArts-使用算法套件快速完成水表读数识别:Step4 部署为在线服务

时间:2023-11-01 16:25:50

Step4 部署为在线服务

本次展示仅部署OCR服务, 包括本地部署和线上部署, 部署上线后调用部署服务进行本地图片的推理,获取水表的预测读数。部署在线服务,需要指定OBS桶以便保存部署所需要的文件。

1.在“algorithms/mmocr/config/textrecog/config.py”文件中配置OBS桶。

修改./algorithms/mmocr/algorithm/configs/textrecog/robust_scanner/config.py

# 替换为用户自己的OBS桶信息obs_bucket = 'obs://{your_obs_bucket_path}'

2.依次执行下述命令:

python manage.py export --cfg algorithms/mmocr/config/textrecog/config.py --is_deploy  # 导出部署模型所需文件python manage.py deploy --cfg algorithms/mmocr/config/textrecog/config.py  # 本地部署调试 

本地部署成功后的输出结果

# ...[Conda environment created successfully.]local_service_port is 127.0.0.1:42153Deploying the local service ...Successfully deployed the local service. You can check the log in /home/ma-user/work/water_meter/export/robustscanner_r31_academic/Linux_x86_64_GPU_PyTorch_Common_py/log.txt[07/05 09:40:14][INFO][ma_cau-deployer.py 49]: { "text": "00326", "score": 0.9999999046325684}[07/05 09:40:14][INFO][ma_cau-deployer.py 59]: ************************ End Deployer ************************

python manage.py deploy --cfg algorithms/mmocr/config/textrecog/config.py --launch_remote本地部署成功后可直接进行在线部署,大约需要12分钟。

图10 部署为在线服务
support.huaweicloud.com/bestpractice-modelarts/devtool-modelarts_0195.html