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

相关推荐
AIsoft_8688几秒前
可以把会议内容整理成摘要的APP推荐:AI总结功能实测
人工智能
Eloudy3 分钟前
全文 - OpenROAD README.md
人工智能·ic agent·ai eda agent
HiDev_12 分钟前
【非标自动化】2、认识元器件(液压泵和液压阀)
大数据·人工智能·自动化
这张生成的图像能检测吗16 分钟前
即插即用模块 + 改进思路汇总目录
图像处理·人工智能·深度学习·目标检测·机器学习
Geek-Chow17 分钟前
12 开源 vs 闭源:同一份权重,两种交付
人工智能·llm·大语言模型
一个处女座的程序猿28 分钟前
Agent之Tool:MoneyPrinterTurbo(一站式 AI 短视频生成工具)的简介、安装和使用方法、案例应用之详细攻略
人工智能·音视频·moneyprinter
港股研究社35 分钟前
物理AI临界点:智驾Tier 1越过规模效应拐点
人工智能
m4Rk_36 分钟前
【论文阅读】Agent 记忆机制(48):Fine-Mem——用细粒度奖励解决长期记忆管理中的奖励稀疏与信用分配
论文阅读·人工智能·学习·开源·github
IanSkunk41 分钟前
眼视光设备全周期台账:从验收入库到使用效果数据化的管理闭环
大数据·网络·人工智能
拓人间精准客44 分钟前
2025–2026 ToB 精准拓客实战手册:用“企业数据画像 + 动态筛选“击穿七大行业获客内卷
大数据·数据库·人工智能