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

相关推荐
阿里云大数据AI技术几秒前
从三个月到两周:DataWorks Data Agent 重构信飞科技多国数仓交付链路
人工智能·agent
2601_9494999411 分钟前
芯瑞科技 DT‑1414完全兼容HFBR‑1414TZ光模块国产化优选方案深度解析(工程师视角)
运维·网络·人工智能·科技·光模块
BSD_HY15 分钟前
薄膜开关矩阵扫描电路设计中的防鬼键措施
人工智能·算法·矩阵·人机交互·薄膜开关·源头工厂·深圳工厂
2601_9556624617 分钟前
实测6款AI配音工具:从环境部署到本地运行,零成本搭建配音系统
人工智能
单友人18 分钟前
HMHA-RYST 算法技能包 + 聊天记录导出器
人工智能·神经网络·机器学习·语言模型·自动化
sel_922 分钟前
【多轮对话论文导读(七)】多轮对话论文阅读笔记:从数据生成、用户模拟到上下文重构与长期记忆
论文阅读·人工智能·笔记·深度学习·算法·语言模型·自然语言处理
Zach_菠萝侠23 分钟前
【deepseek harness研究】进化方向10:对外编程接口面 思考、设计与实现
人工智能·深度学习·deepseek
甲维斯28 分钟前
GLM5.3Flash 我“忍”你很久,今天“曝光”你!
人工智能
宣宣猪的小花园.33 分钟前
【控制理论】系统为什么会“有记忆”:从输入输出理解动态过程
人工智能·嵌入式硬件·机器学习
cui_ruicheng36 分钟前
LangChain 应用开发(十二):Agent 中间件与内置中间件
人工智能·python·中间件·langchain