参考:
https://github.com/open-mmlab/mmdeploy/blob/main/README_zh-CN.md
MMDeploy安装指导
MMDeploy 是 OpenMMLab 模型部署工具箱,为各算法库提供统一的部署体验。基于 MMDeploy,开发者可以轻松从训练 repo 生成指定硬件所需 SDK,省去大量适配时间。
一、MMDeploy安装
前置安装:MMPose安装指导
conda activate mmpose
cd E:\pythonproject\
(1) MMDeploy
1、安装 MMDeploy 模型转换工具(含trt/ort自定义算子)
pip install mmdeploy==1.0.0
2、安装 MMDeploy SDK推理工具,根据是否需要GPU推理可任选其一进行下载安装,以下为支持 onnxruntime-gpu tensorrt 推理:不过我只需要转ONNX,因此不会在后续安装tensorrt相关。
pip install mmdeploy-runtime-gpu==1.0.0
3、下载mmdeploy文件夹到E:\pythonproject\
git clone https://github.com/open-mmlab/mmdeploy.git
cd mmdeploy
(2) onnxruntime
pip install onnxruntime-gpu==1.8.1
(3) 打印安装信息
python tools\check_env.py
二、测试安装是否成功
参考RTMPose的部署文档,尝试用RTMPose中的hand-keypoint模型测试MMDeploy是否正常运行。
1、手部检测模型
python tools/deploy.py configs/mmdet/detection/detection_onnxruntime_static.py \
../mmpose/projects/rtmpose/rtmdet/hand/rtmdet_nano_320-8xb32_hand.py \
https://download.openmmlab.com/mmpose/v1/projects/rtmposev1/rtmdet_nano_8xb32-300e_hand-267f9c8f.pth \
demo/resources/hand.jpg \
--work-dir rtmpose-ort/rtmdet-nano \
--device cuda \
--show \
--dump-info
2、手部关键点模型
python tools/deploy.py configs/mmpose/pose-detection_simcc_onnxruntime_dynamic.py \
../mmpose/projects/rtmpose/rtmpose/hand_2d_keypoint/rtmpose-m_8xb32-210e_coco-wholebody-hand-256x256.py \
https://download.openmmlab.com/mmpose/v1/projects/rtmposev1/rtmpose-m_simcc-hand5_pt-aic-coco_210e-256x256-74fb594_20230320.pth \
demo/resources/hand.jpg \
--work-dir rtmpose-ort/rtmpose-m \
--device cuda \
--dump-info
# 手部模型关键点,mobilenet
python tools/deploy.py configs/mmpose/pose-detection_onnxruntime_static.py \
../mmpose/configs/hand_2d_keypoint/topdown_heatmap/onehand10k/td-hm_mobilenetv2_8xb64-210e_onehand10k-256x256.py \
https://download.openmmlab.com/mmpose/hand/mobilenetv2/mobilenetv2_onehand10k_256x256-f3a3d90e_20210330.pth \
demo/resources/0.bmp \
--work-dir rtmpose-ort/rtmpose-mbnet \
--device cuda \
--dump-info
三、问题解决
1、在mmdeploy做可视化时会报错:把--show去掉,不影响onnx导出。