I use fastai2 and paperspace to create a model like this:
dls = ImageDataLoaders.from_folder(path, train='elephants', valid_pct=0.2, item_tfms=RandomResizedCrop(224, min_scale=0.5))
learn = cnn_learner(dls, resnet18,
loss_func=F.cross_entropy, metrics=accuracy)
learn.fine_tune(4)
I then download the model from paperspace and put it on my local machine. I try to replace the model in the bear_classifier notebook in the bear_voila repository. When it runs the line
learn_inf = load_learner(path/'export_el_reijer.pkl', cpu=True)
I get the error
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/torch/serialization.py in _legacy_load(f, map_location, pickle_module, **pickle_load_args)
700 unpickler = pickle_module.Unpickler(f, **pickle_load_args)
701 unpickler.persistent_load = persistent_load
–> 702 result = unpickler.load()
703
704 deserialized_storage_keys = pickle_module.load(f, **pickle_load_args)
AttributeError: Can't get attribute '_ConstantFunc' on <module 'fastai2.learner' from '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/fastai2/learner.py'>
Now this is correct, I am missing the _Constantfunc in the learner.py on my computer. But pip3 install --upgrade fastai2 does not give me _Constantfunc, it says my fastai2 is up to date. I am reluctant to add it manually, is there something I am doing wrong in this process?