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

相关推荐
就是一顿骚操作5 分钟前
VGG:用小卷积块把 CNN 做深的经典解读
人工智能·深度学习·神经网络·cnn·论文解读
奈斯先生Vector10 分钟前
AI 视频不是会动的图片:用 Shot Contract、时间码与音画质检构建可交付流水线
人工智能·重构·架构·prompt·aigc·音视频
男孩李19 分钟前
浅谈JiuwenSwarm安装
人工智能·语言模型·自然语言处理
anscos20 分钟前
案例分享| Latitude AI × Parasoft:搭建 L2-L3 自动驾驶量产验证与功能安全完整链路
人工智能·安全·自动驾驶
深念Y20 分钟前
基于 NapCat 与本地 RAG 的群聊 AI 机器人方案(ARM64 部署)
人工智能·ai·机器人·node.js·自动化·情感陪伴·bot
工业HMI实战笔记20 分钟前
解放双手,声控未来:抗噪语音交互如何革新嘈杂车间的HMI操作体验
人工智能·学习·自动化·制造
ai产品老杨21 分钟前
AI视频分析并发优化参数配置说明
人工智能·音视频
怪奇云呼军25 分钟前
G.711、Opus 和重采样会拖慢识别吗?闪电智能VoiceAgent 的音频入口怎么选
java·人工智能·python·算法·云计算·音视频
星空彼岸00728 分钟前
AI大模型的能力边界
人工智能
chen_zn9532 分钟前
《VLA 系列》π0 | Flow Matching 动作专家 | 跨本体机器人策略 | 论文与源码解析
人工智能·具身智能·vla