【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 分钟前
什么是skills? 如何使用skills?如何创建skills?
人工智能·skills
nebula-AI5 分钟前
人工智能导论:模型与算法(未来发展与趋势)
人工智能·神经网络·算法·机器学习·量子计算·automl·类脑计算
动物园猫6 分钟前
桥梁损伤目标检测数据集分享(适用于YOLO系列深度学习分类检测任务)
深度学习·yolo·目标检测
灵机一物8 分钟前
灵机一物AI原生电商小程序、PC端(已上线)-OpenAI 模型推翻离散几何核心猜想:AI 首次证明人类错了
人工智能
Tony Bai8 分钟前
AI 编码胜率榜:Go 与 Rust 完胜 C++
人工智能
数字时代全景窗8 分钟前
从OpenClaw、Palantir、SpaceX,看颠覆式创新的四个层次(5)传统财务模型的局限
大数据·人工智能·架构·软件工程
code_pgf9 分钟前
sVLM在资源受限环境中的应用案例
人工智能·深度学习·架构
灰灰勇闯IT9 分钟前
ops-math 的 ReduceSum:Tensor 归约为什么是计算热点
深度学习
多年小白10 分钟前
复盘】2026年5月21日(周四)
大数据·人工智能·ai·金融·区块链
南屹川10 分钟前
【并发编程】Python异步编程实战:从协程到异步框架
人工智能