【SOP】使用MMDeploy将MMAction2的模型转换为TensorRT

配置环境

执行一个MMAction2的Demo

执行 demo/demo.py ,并使用 tsm 配置文件。

bash 复制代码
python demo/demo.py "configs/recognition/tsm/tsm_imagenet-pretrained-r50_8xb16-1x1x16-50e_kinetics400-rgb.py" "../mmaction2 Ckpt/tsm_imagenet-pretrained-r50_8xb16-1x1x16-50e_kinetics400-rgb_20220831-042b1748.pth" "demo/demo.mp4" "tools/data/kinetics/label_map_k400.txt"

将Demo转为TensorRT

Clone the mmdeploy repo: git clone -b main https://github.com/open-mmlab/mmdeploy.git

假设当前路径是:

其中 Ckpt 存放了 .pth 文件,将要生成的 .onnx.engine 也会放在 Ckpt 中。.engine 就是转换好的 TensorRT 文件。

执行下面的指令完成TensorRT转换:

bash 复制代码
cd mmdeploy
python tools/deploy.py "configs/mmaction/video-recognition/video-recognition_2d_tensorrt_static-224x224.py" "../mmaction2/configs/recognition/tsm/tsm_imagenet-pretrained-r50_8xb16-1x1x16-50e_kinetics400-rgb.py" "../Ckpt/tsm_imagenet-pretrained-r50_8xb16-1x1x16-50e_kinetics400-rgb_20220831-042b1748.pth" "tests/data/arm_wrestling.mp4" --work-dir "../Ckpt/tsm_trt" --device cuda:0 --show --dump-info

会遇到报错:

Error Code 4: Internal Error (input: kMIN dimensions in profile 0 are 1,250,3,224,224 but input has static dimensions 1,160,3,224,224.)

Because the shape in mmdeploy/configs/mmaction/video-recognition/video-recognition_2d_tensorrt_static-224x224.py is default as [1, 250, 3, 224, 224], while the shape of tests/data/arm_wrestling.mp4 is [1, 160, 3, 224, 224]. The shapes should be the same.

修改 [1, 250, 3, 224, 224][1, 160, 3, 224, 224] 后即可。

相关推荐
mftang2 分钟前
基于TiTan(RA8P1) BLDC电机运行状态缺陷AI监测系统
人工智能
今天AI了吗4 分钟前
大模型技术全景(一):AI、机器学习、深度学习,三者的关系到底是什么?一文搞懂
数据库·人工智能·python·sql·深度学习·机器学习·rust
长江后浪博客5 分钟前
农业无人机管理平台:构建“无人机巡检 + AI识虫 + GIS地块 + 精准作业”的智慧农业系统
人工智能·无人机·智慧农业·无人机巡检·农业无人机管理平台·ai识虫·gis地块
故七月7 分钟前
GEO服务不是一锤子买卖:万域智瞰售后保障体系如何为企业AI认知资产“保驾护航”
大数据·人工智能
luckystar513~13 分钟前
Hermes实战 :skill编写 + skill治理
人工智能·agent·智能体·hermes·实战专栏
IT古董17 分钟前
AI资讯日报 | 2026年8月31日:政策持续加码,大模型密集更新,开源生态快速扩张,AI智能体加速从实验室走向真实业务场景
人工智能
仙女修炼史20 分钟前
gradcam在yolo中的应用
人工智能·python·yolo
亚川楼宇自控系统数据中心厂家33 分钟前
金融数据中心:能碳一体化管理的技术逻辑
人工智能·金融
代码方舟41 分钟前
零信任架构实战:基于天远车辆过户详版查询构建自动化车辆估值网关
运维·人工智能·架构·自动化
沈管家AI数字员工42 分钟前
集团多组织AI怎么上?多子公司统一AI管理的架构与路径
人工智能·架构