Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YOLOV9 wts转换错误 #1463

Open
hu874 opened this issue Mar 21, 2024 · 16 comments
Open

YOLOV9 wts转换错误 #1463

hu874 opened this issue Mar 21, 2024 · 16 comments

Comments

@hu874
Copy link

hu874 commented Mar 21, 2024

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出现上面的问题

@wang-xinyu
Copy link
Owner

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

@hu874
Copy link
Author

hu874 commented Mar 21, 2024

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

@wang-xinyu
Copy link
Owner

@WuxinrongY 看下呢

@WuxinrongY
Copy link
Contributor

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

@hu874
Copy link
Author

hu874 commented Mar 21, 2024

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

@hu874
Copy link
Author

hu874 commented Mar 21, 2024

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
Copy link
Author

hu874 commented Mar 21, 2024

修改为: 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

@WuxinrongY
Copy link
Contributor

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

@WuxinrongY
Copy link
Contributor

其他位置不修改。

@hu874
Copy link
Author

hu874 commented Mar 21, 2024

使用最新版本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
Copy link
Author

hu874 commented Mar 21, 2024

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

@wang-xinyu
Copy link
Owner

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

@WuxinrongY
Copy link
Contributor

我测试中使用的是YOLOv9发布的0.1版本,你可以把错误发送到我的邮箱我看一下,w845756@qq.com

@hu874
Copy link
Author

hu874 commented Mar 22, 2024

已发送,请查收

@WuxinrongY
Copy link
Contributor

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

@hu874
Copy link
Author

hu874 commented Mar 23, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants