YOLOv6 Tensorrt Python部署教程

B站教学视频

https://www.bilibili.com/video/BV1ka411p7u4/

Github仓库地址

https://github.com/Monday-Leo/YOLOv6_Tensorrt

Introduction

YOLOv6是美团发布的Anchor-free目标检测模型,本仓库实现YOLOv6端到端的Tensorrt部署

Environment

  • Tensorrt 8.4.1.5
  • Cuda 10.2 Cudnn 8.4.1
  • onnx 1.8.0
  • onnx-simplifier 0.3.10
  • onnx-graphsurgeon 0.3.19
  • Torch 1.10.0

Benchmark

ModelSizemAPval 0.5:0.95GTX1650 FP16(ms)GTX1650 FP32(ms)
YOLOv6n64035.06.68.7
YOLOv6-tiny64041.310.616.7
YOLOv6s64043.111.618.4

说明:此处FP16,fp32预测时间包含preprocess+inference+nms,测速方法为warmup10次,预测100次取平均值,并未使用trtexec测速,与官方测速不同;mAPval为原始模型精度,转换后精度未测试。

Quick Start

下载YOLOv6仓库,并导出含有EfficientNMS的端到端ONNX模型。

git clone https://github.com/meituan/YOLOv6
cd YOLOv6
pip install -r requirements.txt

导出FP32 ONNX模型

python ./deploy/ONNX/export_onnx.py --weights yolov6s.pt --img 640 --batch 1 --end2end

导出FP16 ONNX模型

python ./deploy/ONNX/export_onnx.py --weights yolov6s.pt --img 640 --batch 1 --end2end --half

使用Tensorrt官方工具转换engine模型,FP32预测删除--fp16参数即可CUDA10.2+Tensorrt8.4.1存在BUG,需要指定--tacticSources=-cublasLt,+cublas,否则预测时报错,CUDA11+请忽略该参数

trtexec --onnx=./yolov6s_half.onnx --saveEngine=./yolov6s_half.engine --fp16 --workspace=30 --tacticSources=-cublasLt,+cublas

等待生成序列化模型后,修改本仓库infer.py模型路径和图片路径

trt_engine = TRT_engine("./trt_model/yolov6s_half.engine")
img1 = cv2.imread("./pictures/zidane.jpg")
python infer.py

Reference

https://github.com/meituan/YOLOv6

https://github.com/ultralytics/yolov5

https://github.com/Linaom1214/tensorrt-python

https://github.com/triple-Mu

  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值