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

相关推荐
林深现海4 小时前
【刘二大人】PyTorch深度学习实践笔记 —— 第一集:深度学习全景概述(凝练版)
pytorch·笔记·深度学习
火山引擎开发者社区4 小时前
火山引擎正式上线 102.4T 自研交换机,构建 AI 网络新底座
网络·人工智能·火山引擎
庄周迷蝴蝶4 小时前
CNN的底层实现方式
人工智能·神经网络·cnn
落雨盛夏4 小时前
深度学习|李哥考研——transformer
人工智能·深度学习·transformer
凤希AI伴侣4 小时前
凤希AI伴侣V1.3.5.0发布:从“功能堆砌”到“体验重塑”的思考
人工智能·凤希ai伴侣
catchadmin4 小时前
Laravel AI SDK 在 Laracon India 2026 首次亮相
人工智能·php·laravel
love530love4 小时前
Windows 11 配置 CUDA 版 llama.cpp 并实现系统全局调用(GGUF 模型本地快速聊天)
人工智能·windows·大模型·llama·llama.cpp·gguf·cuda 加速
一招定胜负4 小时前
从RNN到LSTM:循环神经网络的进化之路
人工智能·rnn·深度学习
阿杰学AI4 小时前
AI核心知识81——大语言模型之MaaS(简洁且通俗易懂版)
人工智能·ai·语言模型·自然语言处理·aigc·maas·模型即服务
CodeCaptain4 小时前
【一】dify的知识库上传过相关的文件作为待引用的文档,这样已经与[原始语料 → 按“一文档一份 PDF”存 ObjectStore]同样的概念吗
人工智能·pdf·dify