⭐️ ⭐️ ⭐️ 这个系列是一个随笔,是我走过的一些路,有些地方可能不太完善。如果有那个地方没看懂,评论区问就可以,我给补充。
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
0️⃣ mmdeploy源码安装 (转换faster rcnn r50/yolox为tensorrt,并进行推理)_gy77
内容:一文包含了在Linux系统下安装mmdeploy模型转换环境,模型转换为TensorRT,在Linux,Windows下模型推理,推理结果展示。
MMDeploy部署实战系列 :
1️⃣ MMDeploy部署实战系列【第一章】:Docker,Nvidia-docker安装_gy77
内容:docker/nvidia-docker安装,docker/nvidia-docker国内源,docker/nvidia-docker常用命令。
2️⃣ MMDeploy部署实战系列【第二章】:mmdeploy安装及环境搭建_gy77
内容:mmdeploy环境安装三种方法:源码安装,官方docker安装,自定义Dockerfile安装。
3️⃣ MMDeploy部署实战系列【第三章】:MMdeploy pytorch模型转换onnx,tensorrt_gy77
内容:如何查找pytorch模型对应的部署配置文件,模型转换示例:mmcls:resnext50,mmdet:yolox-s,faster rcnn50。
4️⃣ MMDeploy部署实战系列【第四章】:onnx,tensorrt模型推理_gy77
内容:在linux,windows环境下推理,Windows下推理环境安装,推理速度对比,显存对比,可视化展示。
5️⃣ MMDeploy部署实战系列【第五章】:Windows下Release x64编译mmdeploy(C++),对TensorRT模型进行推理_gy77
内容:Windows下环境安装编译环境,编译c++ mmdeploy,编译c++ mmdeploy demo,运行实例。
6️⃣ MMDeploy部署实战系列【第六章】:将编译好的MMdeploy导入到自己的项目中 (C++)_gy77
内容:Windows下环境导入我们编译好的mmdeploy 静态/动态库。
下面是正文:
MMdeploy官方教程:如何转换模型 — mmdeploy 0.5.0 文档
我要用到的是mmclassification转换到tensorrt。
python ./tools/deploy.py \
${DEPLOY_CFG_PATH} \
${MODEL_CFG_PATH} \
${MODEL_CHECKPOINT_PATH} \
${INPUT_IMG} \
--test-img ${TEST_IMG} \
--work-dir ${WORK_DIR} \
--calib-dataset-cfg ${CALIB_DATA_CFG} \
--device ${DEVICE} \
--log-level INFO \
--show \
--dump-info
参数描述:
python ./tools/deploy.py \
configs/mmdet/detection/detection_tensorrt_dynamic-320x320-1344x1344.py \
$PATH_TO_MMDET/configs/yolo/yolov3_d53_mstrain-608_273e_coco.py \
$PATH_TO_MMDET/checkpoints/yolo/yolov3_d53_mstrain-608_273e_coco.pth \
$PATH_TO_MMDET/demo/demo.jpg \
--work-dir work_dir \
--show \
--device cuda:0
进入mmdeploy docker容器
docker run --gpus all -it -p 8080:8080 -v /home/xbsj/gaoying/mmdeploy_out/:/root/workspace/mmdeploy_out mmdeploy:2104
脚本:转换为onnx文件和tensorrt文件
git clone https://gitee.com/monkeycc/mmclassification.git
cd mmclassification
pip install -e .
mkdir checkpoints
cd checkpoints
wget https://download.openmmlab.com/mmclassification/v0/resnext/resnext50_32x4d_b32x8_imagenet_20210429-56066e27.pth -O resnext50_32x4d_b32x8_imagenet.pth
cd ../../mmdeploy
python tools/deploy.py configs/mmcls/classification_tensorrt_dynamic-224x224-224x224.py ../mmclassification/configs/resnext/resnext50_32x4d_b32x8_imagenet.py ../mmclassification/checkpoints/resnext50_32x4d_b32x8_imagenet.pth ../mmclassification/demo/demo.JPEG --work-dir ../mmdeploy_out/mmcls/resnext50_trt --device cuda:0 --dump-info
进入mmdeploy docker容器
docker run --gpus all -it -p 8080:8080 -v /home/xbsj/gaoying/mmdeploy_out/:/root/workspace/mmdeploy_out mmdeploy:2104
脚本:转换为onnx文件和tensorrt文件
cd mmdetection/checkpoints
wget https://download.openmmlab.com/mmdetection/v2.0/yolox/yolox_s_8x8_300e_coco/yolox_s_8x8_300e_coco_20211121_095711-4592a793.pth -O yolox_s_8x8_300e_coco.pth
cd ../../mmdeploy
python tools/deploy.py configs/mmdet/detection/detection_tensorrt_dynamic-320x320-1344x1344.py ../mmdetection/configs/yolox/yolox_s_8x8_300e_coco.py ../mmdetection/checkpoints/yolox_s_8x8_300e_coco.pth ../mmdetection/demo/demo.jpg --work-dir ../mmdeploy_out/mmdet/yolox_l_tensorrt/ --device cuda:0 --dump-info
进入mmdeploy docker容器
docker run --gpus all -it -p 8080:8080 -v /home/xbsj/gaoying/mmdeploy_out/:/root/workspace/mmdeploy_out mmdeploy:2104
脚本:转换为onnx文件和tensorrt文件
git clone https://gitee.com/open-mmlab/mmdetection.git
cd mmdetection
pip install -e .
mkdir checkpoints
cd checkpoints
wget https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth
mv faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth faster_rcnn_r50_fpn_1x_coco.pth
cd ../../mmdeploy
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pycuda
python tools/deploy.py configs/mmdet/detection/detection_tensorrt_dynamic-320x320-1344x1344.py ../mmdetection/configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py ../mmdetection/checkpoints/faster_rcnn_r50_fpn_1x_coco.pth ../mmdetection/demo/demo.jpg --work-dir ../mmdeploy_out/mmdet/faster_rcnn_r50_trt/ --device cuda:0 --dump-info