Closed xiaodongxi121 closed 3 weeks ago
`from doclayout_yolo import YOLOv10 model=YOLOv10("/DocLayout-YOLO-main/unidoc1/yolov10yolov10_layout_0710_epoch500_imgsz1600_bs12_pretrain_unknown/weights/best.pt")
model.export(format='onnx')
This is my conversion code,hope you can help me solve it. Thank you!
This is due to the GL_CRM
module uses a weight-shared convolution, which uses a torch.nn.Conv2D
(do not have attribute bn
) rather than Conv
below in nn/modules/conv.py
(have attribute bn
)
To fix this, you can disable fuse
parameter in model initialization, example is shown in engine/validator.py
:
Currently I did not test the onnx
, maybe a few days later, if you succeed you can submit a PR, much appreciated!
no, it does not work even if fuse is False
no, it does not work even if fuse is False
Thanks for your reply, I will fix this in these two days
Yesterday I tried the fuse method and found that it didn't solve the problem, thanks for the reply, I will continue to try to solve this problem in the coming days as well, if there is any progress, I will write back to you, thank you for your help!
---- Replied Message ---- | From | @.> | | Date | 10/30/2024 09:48 | | To | @.> | | Cc | @.> , @.> | | Subject | Re: [opendatalab/DocLayout-YOLO] onnx bug (Issue #23) |
no, it does not work even if fuse is False
Thanks for your reply, I will fix this in these two days
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
remove this line:
https://github.com/opendatalab/DocLayout-YOLO/blob/5fbc138175099c98a42381d0753ff50ebc5fe494/doclayout_yolo/engine/exporter.py#L226
then export model to onnx
format:
from doclayout_yolo import YOLOv10
model=YOLOv10("./doclayout_yolo_docstructbench_imgsz1024.pt")
model.export(format='onnx')
then you are good to go! just replace model with your onnx
model in demo.py
onnx-related versions:
onnx 1.14.0 pypi_0 pypi
onnxruntime 1.15.1 pypi_0 pypi
onnxruntime-gpu 1.16.3 pypi_0 pypi
onnxslim 0.1.31 pypi_0 pypi
If there are any other bugs, please let me know! @xiaodongxi121 @arthursunbao
Thank you for providing me with your help. I have tried the method you provided and successfully solved the onnx problem. In my actual exploration, I have also found that take https://github.com/opendatalab/DocLayout-YOLO/blob/5fbc138175099c98a42381d0753ff50ebc5fe494/doclayout_yolo/nn/modules/g2l_crm.py#L36 Change to bn = nn.Identity() can also solve this problem. I will test onnx in the future and ask you for advice if you have any questions. Thank you for your help! | lfy | |
---|---|---|
@. | ---- Replied Message ---- | From | @.> | | Date | 10/30/2024 11:21 | | To | @.> | | Cc | @.> , @.***> | | Subject | Re: [opendatalab/DocLayout-YOLO] onnx bug (Issue #23) |
remove this line: https://github.com/opendatalab/DocLayout-YOLO/blob/5fbc138175099c98a42381d0753ff50ebc5fe494/doclayout_yolo/engine/exporter.py#L226 then export model to onnx format:
fromdoclayout_yoloimportYOLOv10model=YOLOv10("./doclayout_yolo_docstructbench_imgsz1024.pt") model.export(format='onnx')
then you are good to go! just replace model with your onnx model in demo.py
onnx-related versions:
onnx 1.14.0 pypi_0 pypi onnxruntime 1.15.1 pypi_0 pypi onnxruntime-gpu 1.16.3 pypi_0 pypi onnxslim 0.1.31 pypi_0 pypi
If there are any other bugs, please let me know! @@.***
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
Glad to see problem solved, I will close this now, for any further questions you can also post them here.
Yesterday I tried the fuse method and found that it didn't solve the problem, thanks for the reply, I will continue to try to solve this problem in the coming days as well, if there is any progress, I will write back to you, thank you for your help!
I'm a beginner with YOLO and would appreciate it if you could provide the ONNX inference code for learning purposes.
Yesterday I tried the fuse method and found that it didn't solve the problem, thanks for the reply, I will continue to try to solve this problem in the coming days as well, if there is any progress, I will write back to you, thank you for your help!
I'm a beginner with YOLO and would appreciate it if you could provide the ONNX inference code for learning purposes.
Thanks for your interest on our work! For inference you can still use demo.py
and just change model path to the exported onnx model.
Yesterday I tried the fuse method and found that it didn't solve the problem, thanks for the reply, I will continue to try to solve this problem in the coming days as well, if there is any progress, I will write back to you, thank you for your help!
I'm a beginner with YOLO and would appreciate it if you could provide the ONNX inference code for learning purposes.
Thanks for your interest on our work! For inference you can still use
demo.py
and just change model path to the exported onnx model.
That works, thanks a lot!
remove this line:
then export model to
onnx
format:from doclayout_yolo import YOLOv10 model=YOLOv10("./doclayout_yolo_docstructbench_imgsz1024.pt") model.export(format='onnx')
then you are good to go! just replace model with your
onnx
model indemo.py
onnx-related versions:
onnx 1.14.0 pypi_0 pypi onnxruntime 1.15.1 pypi_0 pypi onnxruntime-gpu 1.16.3 pypi_0 pypi onnxslim 0.1.31 pypi_0 pypi
If there are any other bugs, please let me know! @xiaodongxi121 @arthursunbao
I'm a beginner too.These days i want to take a progress on the finetune item.But i have confronted with the same errors:AttributeError: 'Conv' object has no attribute 'bn'
The whole error message below:
Traceback (most recent call last):
File "/nfs1/56dev/root/CG/DocLayout-YOLO/train.py", line 66, in
The terminal bash order is : python train.py --data /nfs1/56dev/root/CG/DocLayout-YOLO/finetune_datas/dataset --model m-doclayout --epoch 100 --image-size 1120 --batch-size 10 --project public_dataset/doclaynet --plot 1 --optimizer SGD --lr0 0.02 --pretrain doclayout_yolo_docsynth300k_imgsz1600.pt
The methods above this page i have tried ,but no working.If you can help me ,i'd appreciate it ~~
File "/nfs1/56dev/root/CG/DocLayout-YOLO/doclayout_yolo/engine/trainer.py", line 214, in train self._do_train(world_size) File "/nfs1/56dev/root/CG/DocLayout-YOLO/doclayout_yolo/engine/trainer.py", line 473, in _do_train self.final_eval()
Thanks for feedback! Your error also indicate that validation fail in the last evaluation:
File "/nfs1/56dev/root/CG/DocLayout-YOLO/doclayout_yolo/engine/trainer.py", line 214, in train
self._do_train(world_size)
File "/nfs1/56dev/root/CG/DocLayout-YOLO/doclayout_yolo/engine/trainer.py", line 473, in _do_train
self.final_eval()
can model evaluate perform well during training process? You can directly using val.py
to get the results of best.pt
File "/nfs1/56dev/root/CG/DocLayout-YOLO/doclayout_yolo/engine/trainer.py", line 214, in train self._do_train(world_size) File "/nfs1/56dev/root/CG/DocLayout-YOLO/doclayout_yolo/engine/trainer.py", line 473, in _do_train self.final_eval()
Thanks for feedback! Your error also indicate that validation fail in the last evaluation:
File "/nfs1/56dev/root/CG/DocLayout-YOLO/doclayout_yolo/engine/trainer.py", line 214, in train self._do_train(world_size) File "/nfs1/56dev/root/CG/DocLayout-YOLO/doclayout_yolo/engine/trainer.py", line 473, in _do_train self.final_eval()
can model evaluate perform well during training process? You can directly using
val.py
to get the results ofbest.pt
Thanks for reply . I can successfully run 50 epoch train process and get the best.pt and the last.pt.And i can directly run the val.py with the best.pt.But use the bash terminal i can not run the validated part.These are the all situations i have met~
@Scorpion-cg I don't quite understand your expression. Did you mean you specify --epochs 100
(train for 100 epochs) but evaluation fail at the 50th epoch? But the traceback indicates evaluation fail at self.final_eval()
.
@Scorpion-cg I don't quite understand your expression. Did you mean you specify
--epochs 100
(train for 100 epochs) but evaluation fail at the 50th epoch? But the traceback indicates evaluation fail atself.final_eval()
.
Sry for late reply.I have already gotten the best.pt of 100 train epoch.But use the terminal bash order ,the error appeared in the val part.So i take your advice of using best.pt with the val.py directly which can get the metrics.I mean the bash order only train successfully ,and fail in the val part.^.^
I encountered an error while trying to convert the training model into an onnx model.
AttributeError: 'Conv' object has no attribute 'bn'