If I train the model somewhere and want to load the model in a completely different directory, this error appears:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-6-c3946dc50b4c> in <module>
1 from reader import ReaderCaller
2
----> 3 reader = ReaderCaller(MODEL_PATH,hparams)
4 topn_contexts = df_test['context'].to_numpy()
5 topn_contexts = topn_contexts[:10]
~/tasks/Document Reader/reader.py in __init__(self, MODEL_PATH, hparams)
246 self.hparams = self._retrieve_hparams(hparams)
247
--> 248 self.MODEL = Reader.load_from_checkpoint(checkpoint_path = MODEL_PATH,map_location=self.device,hparams=self.hparams)
249 self.softmax = torch.nn.Softmax(dim=1)
250
/opt/conda/lib/python3.7/site-packages/pytorch_lightning/core/saving.py in load_from_checkpoint(cls, checkpoint_path, map_location, hparams_file, strict, **kwargs)
130 """
131 if map_location is not None:
--> 132 checkpoint = pl_load(checkpoint_path, map_location=map_location)
133 else:
134 checkpoint = pl_load(checkpoint_path, map_location=lambda storage, loc: storage)
/opt/conda/lib/python3.7/site-packages/pytorch_lightning/utilities/cloud_io.py in load(path_or_url, map_location)
30 fs = get_filesystem(path_or_url)
31 with fs.open(path_or_url, "rb") as f:
---> 32 return torch.load(f, map_location=map_location)
33
34
/opt/conda/lib/python3.7/site-packages/torch/serialization.py in load(f, map_location, pickle_module, **pickle_load_args)
590 opened_file.seek(orig_position)
591 return torch.jit.load(opened_file)
--> 592 return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
593 return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
594
/opt/conda/lib/python3.7/site-packages/torch/serialization.py in _load(zip_file, map_location, pickle_module, pickle_file, **pickle_load_args)
849 unpickler = pickle_module.Unpickler(data_file, **pickle_load_args)
850 unpickler.persistent_load = persistent_load
--> 851 result = unpickler.load()
852
853 torch._utils._validate_loaded_sparse_tensors()
ModuleNotFoundError: No module named 'vident'
My code
self.MODEL = Model.load_from_checkpoint(checkpoint_path = MODEL_PATH,map_location=self.device,hparams=self.hparams)
I’d like to know if it is a bug or if I am doing somethins wrong