tensorrtx icon indicating copy to clipboard operation
tensorrtx copied to clipboard

YOLOV9 wts转换错误

Open hu874 opened this issue 1 year ago • 16 comments

Env

  • GPU, e.g. RTX2080
  • OS, e.g. Ubuntu20.04
  • Cuda version
  • TensorRT version 8.5.1

About this repo

  • which branch/tag/commit are you using?
  • which model? yolov5, retinaface?

Your problem

thon gen_wts.py -w yolov9-c.pt -o yolov9-c.wts Generating .wts for detect model Loading yolov9-c.pt YOLOv5 🚀 2024-3-4 Python-3.8.13 torch-1.8.1+cu111 CPU

Traceback (most recent call last): File "gen_wts.py", line 35, in model.model.float() AttributeError: 'dict' object has no attribute 'model' 使用官方yolov9-c进行的训练,.pt转.wts出现上面的问题

hu874 avatar Mar 21 '24 01:03 hu874

试下预训练的yolov9-c.pt?

wang-xinyu avatar Mar 21 '24 02:03 wang-xinyu

使用了官方下载的预训练权重yolov9-c.pt依然报上方的错误。

hu874 avatar Mar 21 '24 02:03 hu874

@WuxinrongY 看下呢

wang-xinyu avatar Mar 21 '24 03:03 wang-xinyu

35行修改为: model['model'].float(),随后我提交修改。

WuxinrongY avatar Mar 21 '24 03:03 WuxinrongY

还有42和50行是否是要同步更改?

hu874 avatar Mar 21 '24 03:03 hu874

Generating .wts for detect model Loading yolov9-c.pt YOLOv5 🚀 2024-3-4 Python-3.8.13 torch-1.8.1+cu111 CPU

Traceback (most recent call last): File "gen_wts.py", line 39, in anchor_grid = model.model[-1].anchors * model.model[-1].stride[..., None, None] AttributeError: 'dict' object has no attribute 'model'

hu874 avatar Mar 21 '24 03:03 hu874

修改为: model['model'],全部更改以后报错:Generating .wts for detect model Loading yolov9-c.pt YOLOv5 🚀 2024-3-4 Python-3.8.13 torch-1.8.1+cu111 CPU

Traceback (most recent call last): File "gen_wts.py", line 39, in anchor_grid = model['model'][-1].anchors * model.model[-1].stride[..., None, None] TypeError: 'DetectionModel' object is not subscriptable

hu874 avatar Mar 21 '24 03:03 hu874

不好意思,写错了:35行:model = model['model'].float()

WuxinrongY avatar Mar 21 '24 03:03 WuxinrongY

其他位置不修改。

WuxinrongY avatar Mar 21 '24 03:03 WuxinrongY

使用最新版本tensorrtx进行engine转换时出现错误,并没有生成engine文件3/21/2024-14:21:36] [E] [TRT] 1: Unexpected exception _Map_base::at [03/21/2024-14:21:36] [E] [TRT] 2: [builder.cpp::buildSerializedNetwork::751] Error Code 2: Internal Error (Assertion engine != nullptr failed. ) Build engine successfully! yolov9: /home/tfboys/ws_usharing_102/TrafficLight/tensorrtx-master/yolov9/demo.cpp:31: void serialize_engine(unsigned int, std::__cxx11::string&, std::__cxx11::string&, std::__cxx11::string&): Assertion `serialized_engine != nullptr' failed.

hu874 avatar Mar 21 '24 06:03 hu874

使用官方预训练模型也是同样的报错

hu874 avatar Mar 21 '24 06:03 hu874

@WuxinrongY yolov9是不是最近有更新? 最好能固定用一个他的分支

wang-xinyu avatar Mar 21 '24 07:03 wang-xinyu

我测试中使用的是YOLOv9发布的0.1版本,你可以把错误发送到我的邮箱我看一下,[email protected]

WuxinrongY avatar Mar 22 '24 03:03 WuxinrongY

已发送,请查收

hu874 avatar Mar 22 '24 05:03 hu874

在int8模型中需要设置量化数据集路径,确认一下config.h中量化数据集路径设置是否正确,量化数据集需要设置为目录,末尾要加"/",如"./calib/"。

WuxinrongY avatar Mar 22 '24 08:03 WuxinrongY

Ok了

WuxinrongY @.***>于2024年3月22日 周五下午4:10写道:

在int8模型中需要设置量化数据集路径,确认一下config.h中量化数据集路径设置是否正确,量化数据集需要设置为目录,末尾要加"/",如"./calib/"。

— Reply to this email directly, view it on GitHub https://github.com/wang-xinyu/tensorrtx/issues/1463#issuecomment-2014552324, or unsubscribe https://github.com/notifications/unsubscribe-auth/AR6FIIEMXPBLZU4S45BXHYDYZPRPZAVCNFSM6AAAAABFARLKV2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJUGU2TEMZSGQ . You are receiving this because you authored the thread.Message ID: @.***>

hu874 avatar Mar 23 '24 17:03 hu874

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 04 '24 02:06 stale[bot]