I cannot export best.pt to best.onnx because of below errors.
Can you tell me how to resolve below errors?
I have used your yolov5 repository to export .onnx file.
(base) aiserver@aiserver-H110-D3:~/coding/GitHub/tonnx/yolov5$ export PYTHONPATH="$PWD" && python3 models/export_onnx.py --weights /home/aiserver/coding/frame_work/yolov5/runs/train/mscoco_result_448_600epoch3/weights/best.pt --img 448 --batch 1
Namespace(batch_size=1, img_size=[448, 448], weights='/home/aiserver/coding/frame_work/yolov5/runs/train/mscoco_result_448_600epoch3/weights/best.pt')
Traceback (most recent call last):
File "models/export_onnx.py", line 31, in
model = attempt_load(opt.weights, map_location=torch.device('cpu')) # load FP32 model
File "/home/aiserver/coding/GitHub/tonnx/yolov5/models/experimental.py", line 118, in attempt_load
model.append(torch.load(w, map_location=map_location)['model'].float().fuse().eval()) # load FP32 model
File "/home/aiserver/anaconda3/lib/python3.8/site-packages/torch/serialization.py", line 607, in load
return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
File "/home/aiserver/anaconda3/lib/python3.8/site-packages/torch/serialization.py", line 882, in _load
result = unpickler.load()
File "/home/aiserver/anaconda3/lib/python3.8/site-packages/torch/serialization.py", line 875, in find_class
return super().find_class(mod_name, name)
AttributeError: Can't get attribute 'SPPF' on <module 'models.common' from '/home/aiserver/coding/GitHub/tonnx/yolov5/models/common.py'>
Hello, @linghu8812 @jenhaoyang
I cannot export best.pt to best.onnx because of below errors. Can you tell me how to resolve below errors? I have used your yolov5 repository to export .onnx file.
(base) aiserver@aiserver-H110-D3:~/coding/GitHub/tonnx/yolov5$ export PYTHONPATH="$PWD" && python3 models/export_onnx.py --weights /home/aiserver/coding/frame_work/yolov5/runs/train/mscoco_result_448_600epoch3/weights/best.pt --img 448 --batch 1 Namespace(batch_size=1, img_size=[448, 448], weights='/home/aiserver/coding/frame_work/yolov5/runs/train/mscoco_result_448_600epoch3/weights/best.pt') Traceback (most recent call last): File "models/export_onnx.py", line 31, in
model = attempt_load(opt.weights, map_location=torch.device('cpu')) # load FP32 model
File "/home/aiserver/coding/GitHub/tonnx/yolov5/models/experimental.py", line 118, in attempt_load
model.append(torch.load(w, map_location=map_location)['model'].float().fuse().eval()) # load FP32 model
File "/home/aiserver/anaconda3/lib/python3.8/site-packages/torch/serialization.py", line 607, in load
return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
File "/home/aiserver/anaconda3/lib/python3.8/site-packages/torch/serialization.py", line 882, in _load
result = unpickler.load()
File "/home/aiserver/anaconda3/lib/python3.8/site-packages/torch/serialization.py", line 875, in find_class
return super().find_class(mod_name, name)
AttributeError: Can't get attribute 'SPPF' on <module 'models.common' from '/home/aiserver/coding/GitHub/tonnx/yolov5/models/common.py'>
Thank you.