Hi, I’m having a weird error. I train my model (I’m using Colab) as usual with learn= create_cnn(data, models.resnet50, metrics=[accuracy])
then fit the model and save it. After that I use learn.export()
to get the file export.pkl
when I try to do inference I used learn=load_learner(path_to_pkl_file)
and the following error appears:
---------------------------------------------------------------------------
UnpicklingError Traceback (most recent call last)
<ipython-input-84-b9e031f97a6b> in <module>()
1 pkl = Path('fer2013/')
----> 2 learner= load_learner(pkl)
/usr/local/lib/python3.6/dist-packages/fastai/basic_train.py in load_learner(path, fname, test)
467 def load_learner(path:PathOrStr, fname:PathOrStr='export.pkl', test:ItemList=None):
468 "Load a `Learner` object saved with `export_state` in `path/fn` with empty data, optionally add `test` and load on `cpu`."
--> 469 state = torch.load(open(Path(path)/fname, 'rb'))
470 model = state.pop('model')
471 src = LabelLists.load_state(path, state.pop('data'))
/usr/local/lib/python3.6/dist-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:
/usr/local/lib/python3.6/dist-packages/torch/serialization.py in _load(f, map_location, pickle_module)
526 f.seek(0)
527
--> 528 magic_number = pickle_module.load(f)
529 if magic_number != MAGIC_NUMBER:
530 raise RuntimeError("Invalid magic number; corrupt file?")
UnpicklingError: unpickling stack underflow