yolov5模型转换为TensorRT模型时报错Your ONNX model has been generated with INT64 weights

1. 报错信息

今天在yolov5模型转换为TensorRT模型时报错:

Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64

详细报错信息如下:

----------------------------------------------------------------
Input filename:   ../models/yolov5s.onnx
ONNX IR version:  0.0.6
Opset version:    13
Producer name:    pytorch
Producer version: 1.9
Domain:           
Model version:    0
Doc string:       
----------------------------------------------------------------
[2023-03-08 07:33:55 WARNING] onnx2trt_utils.cpp:198: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.
[2023-03-08 07:33:55 WARNING] onnx2trt_utils.cpp:198: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.
[2023-03-08 07:33:55 WARNING] onnx2trt_utils.cpp:198: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.

 

2. 原因分析

根据提示,我们可以发现原因:

因为我们的onnx模型参数类型是INT64, 然后TensorRT是不支持 INT64的。这就需要我们先把ONNX模型的精度降到 INT32,然后再进行转换为 TensorRT模型。

3. 解决办法

具体操作如下:

先对onnx模型进行onnxsim 简化:

python -m onnxsim yolov5s.onnx yolov5s_sim.onnx
./trtexec --onnx=yolov5s_sim.onnx --saveEngine=yolov5s.engine

这样就解决了

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论
【资源说明】 1、该资源包括项目的全部源码,下载可以直接使用! 2、本项目适合作为计算机、数学、电子信息等专业的课程设计、期末大作业和毕设项目,作为参考资料学习借鉴。 3、本资源作为“参考资料”如果需要实现其他功能,需要能看懂代码,并且热爱钻研,自行调试。 基于yolov5+PyQt5开发的自定义区域入侵检测事件信息统计系统python源码+说明文档.zip **How to Use:** - Run `detect_logicwd.py` directly to enter the detection interface. ```shell script python detect_logicwd.py ``` ## Project Structure ``` . ├── README.md ├── README_EN.md ├── models/ # configuration files for yolov5 ├── output/ # target detection results of yolov5 for images ├── ruqin/ # JSON files for drawing polygonal areas ├── ui/ # generated UI files and PY files of PyQT5, the currently used interface file is detect_ui_new_v2.py ├── weights/ # storage folder for weights files of yolov5 and other training models ├── line_draw.py # includes the detection algorithm of area intrusion, control of displaying invading objects in detection area, drawing polygonal areas, etc. └── detect_logicwd.py # software main body and entry point of the project. It includes importing corresponding PY files of UI, logical implementation of various buttons, outputting information (detection frame, object information, coordinates, confidence level, video screen, etc.). ``` ......

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

liguiyuan112

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值