Lesson-3: Load Data Fails

(Abhishek Singh) #1

Hi guys,
I’m working on the Lesson-3 IMDB. I have trained my model on AWS which is running on Ubuntu System. I have downloaded my trained models on the local system, the problem is I’m not able to load the data bunch by using the load_data(path,’ filename’). The error is cannot instantiate ‘PosixPath’ on your system. The problem is I used Path as on AWS which defaults to PosixPath and since the local system is Windows it is not able to load the model. Are there any dependency while saving the model.

The code is straight forward
from fastai.text import *
from fastai import *
#path ="/home/ubuntu/cleanClause/Clause" # while training on AWS
path = “C:/Users/abhis/Desktop/Ec2/cleanClause/Clause”
bs = 16
#data_lm = TextList.from_folder(path).split_by_rand_pct(0.0).label_for_lm().databunch(bs=bs) # while training on AWS
data_lm = load_data(path,‘vocabpath’)

The stacktrace is
NotImplementedError Traceback (most recent call last)
----> 1 data_lm = load_data(path,‘vocabpath’)

F:\Anaconda\envs\fastai\lib\site-packages\fastai\basic_data.py in load_data(path, file, bs, val_bs, num_workers, dl_tfms, device, collate_fn, no_check, **kwargs)
276 source = Path(path)/file if is_pathlike(file) else file
277 print(source)
–> 278 ll = torch.load(source, map_location=‘cpu’) if defaults.device == torch.device(‘cpu’) else torch.load(source)
279 return ll.databunch(path=path, bs=bs, val_bs=val_bs, num_workers=num_workers, dl_tfms=dl_tfms, device=device,
280 collate_fn=collate_fn, no_check=no_check, **kwargs)

F:\Anaconda\envs\fastai\lib\site-packages\torch\serialization.py in load(f, map_location, pickle_module)
365 f = open(f, ‘rb’)
366 try:
–> 367 return _load(f, map_location, pickle_module)
368 finally:
369 if new_fd:

F:\Anaconda\envs\fastai\lib\site-packages\torch\serialization.py in _load(f, map_location, pickle_module)
536 unpickler = pickle_module.Unpickler(f)
537 unpickler.persistent_load = persistent_load
–> 538 result = unpickler.load()
540 deserialized_storage_keys = pickle_module.load(f)

F:\Anaconda\envs\fastai\lib\pathlib.py in new(cls, *args, **kwargs)
995 if not self._flavour.is_supported:
996 raise NotImplementedError(“cannot instantiate %r on your system”
–> 997 % (cls.name,))
998 self._init()
999 return self

NotImplementedError: cannot instantiate ‘PosixPath’ on your system