Skip to content

_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. #6

@RajabMuhammad

Description

@RajabMuhammad

Starting training for 2 epochs...

  Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size

0%| | 0/155 00:00/home/rajab/projects/PK-YOLO-main/train_dual.py:313: FutureWarning: torch.cuda.amp.autocast(args...) is deprecated. Please use torch.amp.autocast('cuda', args...) instead.
with torch.cuda.amp.autocast(amp):
0/1 5.5G 7.116 8.983 5.843 6 640: 0%| | 0/155 00:08WARNING ⚠️ TensorBoard graph visualization failure Only tensors, lists, tuples of tensors, or dictionary of tensors can be output from traced functions
0/1 5.5G 7.116 8.983 5.843 6 640: 1%| | 1/155 00:10/home/rajab/projects/PK-YOLO-main/train_dual.py:313: FutureWarning: torch.cuda.amp.autocast(args...) is deprecated. Please use torch.amp.autocast('cuda', args...) instead.
with torch.cuda.amp.autocast(amp):
0/1 6.53G 4.728 10.93 5.138 4 640: 100%|██████████| 155/155 00:48
Class Images Instances P R mAP50 mAP50-95: 100%|██████████| 19/19 00:07
all 75 81 0.00214 0.432 0.00389 0.000389

  Epoch    GPU_mem   box_loss   cls_loss   dfl_loss  Instances       Size
    1/1      7.09G      4.756      10.59      5.183          0        640: 100%|██████████| 155/155 00:36
             Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 19/19 00:02
               all         75         81    0.00194      0.395    0.00388   0.000388

2 epochs completed in 0.028 hours.
Traceback (most recent call last):
File "/home/rajab/projects/PK-YOLO-main/train_dual.py", line 645, in
main(opt)
~~~~^^^^^
File "/home/rajab/projects/PK-YOLO-main/train_dual.py", line 539, in main
train(opt.hyp, opt, device, callbacks)
~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/rajab/projects/PK-YOLO-main/train_dual.py", line 413, in train
strip_optimizer(f) # strip optimizers
~~~~~~~~~~~~~~~^^^
File "/home/rajab/projects/PK-YOLO-main/utils/general.py", line 999, in strip_optimizer
x = torch.load(f, map_location=torch.device('cpu'))
File "/home/rajab/anaconda3/envs/pk_yolo__env/lib/python3.13/site-packages/torch/serialization.py", line 1529, 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 numpy.dtype was not an allowed global by default. Please use torch.serialization.add_safe_globals([numpy.dtype]) or the torch.serialization.safe_globals([numpy.dtype]) 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/generated/torch.load.html.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions