[Bug]: AttributeError in YOLOv9 Model Export: 'AutoShape' object has no attribute 'fuse'
yaoandy107 opened this issue ยท 7 comments
Thanks for your great work! I'm trying to convert the gelan-c to tensorRT, but get the error below
Using cache found in /root/.cache/torch/hub/WongKinYiu_yolov9_main
YOLO ๐ 2024-3-15 Python-3.10.12 torch-2.1.0+cu121 CUDA:0 (Tesla T4, 14931MiB)
Fusing layers...
Model summary: 387 layers, 25288768 parameters, 0 gradients, 102.1 GFLOPs
Adding AutoShape...
Traceback (most recent call last):
File "/content/TensorRT-YOLO/python/export/yolov9/export.py", line 234, in <module>
Exporter(opt)(model)
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "/content/TensorRT-YOLO/python/export/yolov9/export.py", line 96, in __call__
model = model.fuse()
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1695, in __getattr__
raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
AttributeError: 'AutoShape' object has no attribute 'fuse'
This is the command I executed
python python/export/yolov9/export.py -w gelan-c.pt -o output -s --dynamic
@laugh12321 Thank you for your quick response! I create a Colab for you to reproduce
https://colab.research.google.com/drive/1QciXnx2nwHkFs2DWOhpTx_V6v1Rp57HX?usp=sharing
@laugh12321 Thank you very much! Commenting out the line worked! Besides, what is the line for? Will it affect the outcome?
@yaoandy107 You're welcome! I'm glad commenting out the line resolved the issue. Regarding your question, is the "line" you mentioned referring to the 4 warnings displayed in the log? If so, those warnings shouldn't affect the accuracy of the model; they're just notifications.
@laugh12321 Sorry for not making it clear earlier. I am asking about the line model = model.fuse()
.
@yaoandy107 Got it, thanks for clarifying! The fuse()
function is used to merge convolutional (conv) and batch normalization (bn) layers in order to speed up the model's inference time without affecting accuracy.
@laugh12321 Thank you for your quick response! I create a Colab for you to reproduce https://colab.research.google.com/drive/1QciXnx2nwHkFs2DWOhpTx_V6v1Rp57HX?usp=sharing