I was trying to convert the custom trained model into wts file but it is not working. using the below command
python3 gen_wts.py -w yolov5s.pt -o yolov5s.wts
It is showing following error
Traceback (most recent call last):
File "gen_wts.py", line 43, in
delattr(model.model[-1], 'anchor_grid') # model.model[-1] is detect layer
File "/home/cnhi/models/TRT/TRT_env_2/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1685, in delattr
super().delattr(name)
AttributeError: anchor_grid
If we comment out the line it shows the next error
delattr(model.model[-1], 'anchor_grid') # model.model[-1] is detect layer
Traceback (most recent call last):
File "gen_wts.py", line 46, in
model.model[-1].register_buffer("strides", model.model[-1].stride)
File "/home/cnhi/models/TRT/TRT_env_2/lib/python3.8/site-packages/torch/nn/modules/module.py", line 523, in register_buffer
raise KeyError("attribute '{}' already exists".format(name))
KeyError: "attribute 'strides' already exists"
If comment this line also it is generating wts file but while converting wts to engine it is showing error
missing strides
But when I tried to converted the pretrained coco yolov5n model it get converted into wts and in engine and working fine.
I was trying to convert the custom trained model into wts file but it is not working. using the below command python3 gen_wts.py -w yolov5s.pt -o yolov5s.wts It is showing following error
Traceback (most recent call last): File "gen_wts.py", line 43, in delattr(model.model[-1], 'anchor_grid') # model.model[-1] is detect layer File "/home/cnhi/models/TRT/TRT_env_2/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1685, in delattr super().delattr(name) AttributeError: anchor_grid
If we comment out the line it shows the next error delattr(model.model[-1], 'anchor_grid') # model.model[-1] is detect layer Traceback (most recent call last): File "gen_wts.py", line 46, in model.model[-1].register_buffer("strides", model.model[-1].stride) File "/home/cnhi/models/TRT/TRT_env_2/lib/python3.8/site-packages/torch/nn/modules/module.py", line 523, in register_buffer raise KeyError("attribute '{}' already exists".format(name)) KeyError: "attribute 'strides' already exists"
If comment this line also it is generating wts file but while converting wts to engine it is showing error missing strides
But when I tried to converted the pretrained coco yolov5n model it get converted into wts and in engine and working fine.