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

相关推荐
老兵发新帖1 分钟前
X-AnyLabeling实现自动预标注可行性方案分析
人工智能·计算机视觉·目标跟踪
WLJT1231231232 分钟前
接插件:电子系统的连接核心与产业赋能
大数据·人工智能·科技·安全·生活
如梦@_@7 分钟前
midscene智能体实现AI自动化测试环境搭建及demo演示
人工智能
翱翔的苍鹰8 分钟前
基于 Transformer 架构的中英机器翻译(汉译英)实现
深度学习·transformer·机器翻译
摆烂咸鱼~8 分钟前
机器学习(13-1)
人工智能·机器学习
skywalk81639 分钟前
用opencode为opencode写了一个类似planning-with-files的插件codecraft
人工智能·opencode
信创天地11 分钟前
AI + 信创双轮驱动:从自主可控到智能引领,重塑数字经济新范式
运维·人工智能·网络安全·系统架构·系统安全·运维开发
xindoo18 分钟前
最近AI领域爆火的 Agent Skills 是什么?
大数据·人工智能
图生生29 分钟前
跨境电商图片翻译痛点解决:AI工具实现多语言适配一键生成
人工智能·ai
码农三叔29 分钟前
(7-3)自动驾驶中的动态环境路径重规划:实战案例:探险家的行进路线
人工智能·算法·机器学习·机器人·自动驾驶