Description
When I run the code:
from mambavision import create_model
model = create_model('mamba_vision_T', pretrained=True, model_path="nvidia/MambaVision-T-1K/mambavision_tiny_1k.pth.tar")
Something wrong:
File "/mnt/data/LHZ/MambaProj/test_MambaVision.py", line 77, in test4
model = create_model('mamba_vision_T', pretrained=True, model_path="nvidia/MambaVision-T-1K/mambavision_tiny_1k.pth.tar")
File "/opt/soft/anaconda3/envs/mamba2/lib/python3.12/site-packages/mambavision/models/registry.py", line 201, in create_model
model = create_fn(pretrained=pretrained, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/soft/anaconda3/envs/mamba2/lib/python3.12/site-packages/mambavision/models/mamba_vision.py", line 766, in mamba_vision_T
model._load_state_dict(model_path)
File "/opt/soft/anaconda3/envs/mamba2/lib/python3.12/site-packages/mambavision/models/mamba_vision.py", line 732, in _load_state_dict
_load_checkpoint(self,
^^^^^^^^^^^^^^^^^^^^^^
File "/opt/soft/anaconda3/envs/mamba2/lib/python3.12/site-packages/mambavision/models/mamba_vision.py", line 207, in _load_checkpoint
checkpoint = torch.load(filename, map_location=map_location)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/soft/anaconda3/envs/mamba2/lib/python3.12/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 argparse.Namespace was not an allowed global by default. Please use torch.serialization.add_safe_globals([Namespace])
or the torch.serialization.safe_globals([Namespace])
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.