Spaces:
Runtime error
Runtime error
UnpicklingError
#1
by
Tungland
- opened
Hi! Tried you modelwrapper locally but got an UnpicklingError. What could be the issue here?
import model_wrapper
model = model_wrapper.PredictionModel()
---------------------------------------------------------------------------
UnpicklingError Traceback (most recent call last)
Cell In[2], line 1
----> 1 model = model_wrapper.PredictionModel()
File ~/projects/dhlab_projects/ssa-perin/model_wrapper.py:25, in PredictionModel.__init__(self, checkpoint_path, default_mrp_path, verbose)
23 def __init__(self, checkpoint_path=os.path.join('models', 'checkpoint.bin'), default_mrp_path=os.path.join('models', 'default.mrp'), verbose=False):
24 self.verbose = verbose
---> 25 self.checkpoint = torch.load('./models/checkpoint.bin', map_location=torch.device('cpu'))
26 self.args = Params().load_state_dict(self.checkpoint['params'])
27 self.args.log_wandb = False
File ~/anaconda3/envs/ssa-perin/lib/python3.11/site-packages/torch/serialization.py:795, in load(f, map_location, pickle_module, weights_only, **pickle_load_args)
793 except RuntimeError as e:
794 raise pickle.UnpicklingError(UNSAFE_MESSAGE + str(e)) from None
--> 795 return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File ~/anaconda3/envs/ssa-perin/lib/python3.11/site-packages/torch/serialization.py:1002, in _legacy_load(f, map_location, pickle_module, **pickle_load_args)
996 if not hasattr(f, 'readinto') and (3, 8, 0) <= sys.version_info < (3, 8, 2):
997 raise RuntimeError(
998 "torch.load does not work with file-like objects that do not implement readinto on Python 3.8.0 and 3.8.1. "
999 f"Received object of type \"{type(f)}\". Please update to Python 3.8.2 or newer to restore this "
1000 "functionality.")
-> 1002 magic_number = pickle_module.load(f, **pickle_load_args)
1003 if magic_number != MAGIC_NUMBER:
1004 raise RuntimeError("Invalid magic number; corrupt file?")
UnpicklingError: invalid load key, 'v'.
Hi, yes that was indeed the issue! My bad, not very experienced with these types of models.