mmdetection-to-tensorrt 使用教程
mmdetection-to-tensorrt项目地址:https://gitcode.com/gh_mirrors/mm/mmdetection-to-tensorrt
项目介绍
mmdetection-to-tensorrt
是一个开源项目,旨在支持将 MMDetection 模型通过 TensorRT 进行端到端部署。该项目跳过了通常的 pth -> onnx -> tensorrt 的转换步骤,直接从 pth 文件转换成 TensorRT 模型,支持多种模型和模块,如 Faster R-CNN、Cascade R-CNN 等。
项目快速启动
环境配置
-
安装 MMDetection:
pip install openmim mim install mmdet==3.3.0
-
安装 torch2trt_dynamic:
git clone https://github.com/grimoire/torch2trt_dynamic cd torch2trt_dynamic pip install -e .
-
安装 amirstan_plugin:
git clone --depth=1 https://github.com/grimoire/amirstan_plugin cd amirstan_plugin git submodule update --init --progress --depth=1 mkdir build && cd build cmake .. && make
模型转换
-
克隆项目:
git clone https://github.com/grimoire/mmdetection-to-tensorrt.git cd mmdetection-to-tensorrt
-
运行转换脚本:
python demo/inference.py --img <测试图像路径> --config <mmdetection 的模型配置文件> --checkpoint <模型 pth 文件路径> --save_path <tensorrt 模型存放路径> --score-thr <检测有效阈值>
应用案例和最佳实践
案例一:实时物体检测
使用 mmdetection-to-tensorrt
将训练好的 MMDetection 模型转换为 TensorRT 模型,部署在边缘设备上进行实时物体检测。通过优化后的模型,可以显著提高检测速度和准确性。
案例二:多模态融合
结合不同传感器数据,使用 mmdetection-to-tensorrt
支持的模型进行多模态融合,提高复杂场景下的物体检测和分割性能。
典型生态项目
MMDetection
MMDetection 是一个基于 PyTorch 的目标检测工具箱,提供了丰富的模型和训练策略,是 mmdetection-to-tensorrt
的基础项目。
TensorRT
TensorRT 是 NVIDIA 推出的高性能深度学习推理引擎,支持多种优化技术,如 fp16、int8 和动态输入形状,与 mmdetection-to-tensorrt
结合使用可以进一步提升模型性能。
通过以上步骤和案例,您可以快速上手并应用 mmdetection-to-tensorrt
项目,实现高效的模型部署和推理。
mmdetection-to-tensorrt项目地址:https://gitcode.com/gh_mirrors/mm/mmdetection-to-tensorrt