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

相关推荐
Raink老师4 小时前
【AI面试临阵磨枪-48】GraphRAG、多模态 RAG、自适应 RAG 原理
人工智能·ai 面试题
波动几何4 小时前
模式驱动的学术选题方法论——四种AI模式处理能力的系统建构与论证
人工智能
飞哥数智坊4 小时前
我为我的龙虾斩分身:OpenClaw 多智能体实操
人工智能·agent
七牛开发者4 小时前
HTML is the new Markdown:来自 Claude Code 团队的实践
前端·人工智能·语言模型·html
飞哥数智坊4 小时前
在二线城市做AI社群,我的五一节后到底有多疯狂?
人工智能
视***间4 小时前
智启边缘,魔盒藏锋——视程空间Pandora系列魔盒,解锁边缘计算普惠新范式
人工智能·区块链·边缘计算·ai算力·视程空间
蛐蛐蛐5 小时前
昇腾910B4上安装新版本CANN的正确流程
人工智能·python·昇腾
沪漂阿龙5 小时前
AI大模型面试题:线性回归是什么?最小二乘法、平方误差、正规方程、Ridge、Lasso 一文讲透
人工智能·机器学习·线性回归·最小二乘法
Lyon198505285 小时前
《文字定律》让AI体验,汉字逻辑与字母逻辑的差异——ChatGPT
人工智能·ai·chatgpt·ai写作
2601_957780846 小时前
Claude 4.6 对阵 GPT-5.4:2026 开发者大模型 API 选型深度解析
人工智能·python·gpt·ai·claude