I have a luckfox pico ultra w.
I'm facing an issue when trying to export the Yolov5 model to ONNX format and encountering an error related to loading the weights file in PyTorch. After running the following command:
python export.py --rknpu --weight yolov5s.pt
I receive the following error:
export: data=data/coco128.yaml, weights=['yolov5s.pt'], imgsz=[640, 640], batch_size=1, device=cpu, half=False, inplace=False, keras=False, optimize=False, int8=False, dynamic=False, simplify=False, opset=12, verbose=False, workspace=4, nms=False, agnostic_nms=False, topk_per_class=100, topk_all=100, iou_thres=0.45, conf_thres=0.25, include=['onnx'], rknpu=True YOLOv5
Traceback (most recent call last): File "/home/taibt/Project_Camera_AI/yolov5/export.py", line 723, in main(opt) File "/home/taibt/Project_Camera_AI/yolov5/export.py", line 717, in main run(**vars(opt)) File "/home/taibt/miniconda3/envs/yolov5/lib/python3.9/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context return func(*args, **kwargs) File "/home/taibt/Project_Camera_AI/yolov5/export.py", line 533, in run model = attempt_load(weights, device=device, inplace=True, fuse=True) # load FP32 model File "/home/taibt/Project_Camera_AI/yolov5/models/experimental.py", line 80, in attempt_load ckpt = torch.load(attempt_download(w), map_location='cpu') # load File "/home/taibt/miniconda3/envs/yolov5/lib/python3.9/site-packages/torch/serialization.py", line 1470, in load raise pickle.UnpicklingError(_get_wo_message(str(e))) from None _pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those steps only if you trust the source of the checkpoint. (1) In PyTorch 2.6, we changed the default value of the weights_only argument in torch.load from False to True. Re-running torch.load with weights_only set to False will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source. (2) Alternatively, to load with weights_only=True please check the recommended steps in the following error message. WeightsUnpickler error: Unsupported global: GLOBAL models.yolo.Model was not an allowed global by default. Please use torch.serialization.add_safe_globals([Model]) or the torch.serialization.safe_globals([Model]) context manager to allowlist this global if you trust this class/function.
Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generat ... .load.html.
Has anyone encountered this issue and could provide advice on how to resolve it? Thank you so much!
Best regards,