-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Description
I am trying to load my model checkpoints with the function torchreid.utils.load_pretrained_weights
but am getting the following error:
Unable to load checkpoint from [file]
File ~/Documents/github/stick-it-ai/venv/lib64/python3.13/site-packages/torchreid/reid/utils/torchtools.py:273, in load_pretrained_weights(model, weight_path)
257 def load_pretrained_weights(model, weight_path):
258 r"""Loads pretrianed weights to model.
259
260 Features::
(...) 271 >>> load_pretrained_weights(model, weight_path)
272 """
--> 273 checkpoint = load_checkpoint(weight_path)
274 if 'state_dict' in 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._core.multiarray.scalar was not an allowed global by default. Please use `torch.serialization.add_safe_globals([scalar])` or the `torch.serialization.safe_globals([scalar])` context manager to allowlist this global if you trust this class/function
From what I have seen by searching and by the warning message, Pytorch 2.6 changed the weights_only argument which breaks the loading of checkpoints. As these are my own models I do trust them. Can someone help me trying to build a workaround?
Metadata
Metadata
Assignees
Labels
No labels