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

相关推荐
温九味闻醉几秒前
八股-大语言模型基础
人工智能·语言模型·自然语言处理
EasyGBS几秒前
从“后厨黑箱”到“透明厨房”:国标GB28181视频平台EasyGBS平台AI视频分析如何守护舌尖上的安全
人工智能·安全·音视频
澹锦汐6 分钟前
Serverless 云端架构:独立开发者的单兵作战服务器搭建路线图
人工智能
金融Tech趋势派13 分钟前
2026企业微信SCRM与获客系统选型指南:功能矩阵、场景适配与避坑清单
大数据·人工智能·企业微信
ihsdfhs14 分钟前
多模型不用来回切换?实测一款通用的 AI 聚合工具
人工智能
圣殿骑士-Khtangc19 分钟前
大模型量化技术深度对比:GPTQ vs AWQ vs GGUF全解析
人工智能
电子科技圈23 分钟前
CXL连接全面赋能AI与车载算力提升,SmartDV CXL全栈IP加速相关芯片设计
人工智能·网络协议·tcp/ip·机器学习·自动驾驶·边缘计算
深蓝电商API30 分钟前
AI自动识别网页结构:零规则提取任意网站数据
人工智能·爬虫
下班走回家31 分钟前
LoRA 微调:用少量数据定制自己的 AI 模型
人工智能
宸津-代码粉碎机34 分钟前
Spring AI企业级Agent实战|多工具自动规划+并行调度落地,彻底解决复杂业务AI任务编排问题
java·大数据·人工智能·spring boot·python·spring