【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] 后即可。

相关推荐
SunShaoLu2 分钟前
AI 思维导图工具横向评测:5 款主流产品的生成链路、编辑手感与协作能力对比(2026 版)
人工智能
小禾everyday10 分钟前
RINO:让AI用物理结构自学,1%标注数据实现全监督效果
人工智能
GlobalInfo12 分钟前
无人机机巢机库 行业地位与成长性研究报告:占有率跃升路径、收入增速与销量趋势
人工智能·ai·无人机
zw_onemaker_ai18 分钟前
让 Agent 自己收钱:72 小时搭出 x402 Agent 经济体(附八个真实踩过的坑)
人工智能·ai编程
科技看点说19 分钟前
2026年AI安全上市公司梳理:产品、认证与商业化进展
大数据·人工智能
用户0807759078519 分钟前
昇腾 NPU 从零部署推理模型 · 完整决策与操作指南
深度学习
HaipengYu22 分钟前
从 Config Hook 到 Server/TUI:OpenCode 插件 V1 到 V2 的架构演进
人工智能·架构
李元_霸29 分钟前
基于 AI 的 Web 与 App 端到端测试实践
前端·人工智能
橘饴30 分钟前
当我把 SRC 挖洞交给一个自主 Agent:一天的失败实验记录
人工智能
砺能31 分钟前
team AI使用总结
人工智能