Attribute Error when loading my model on huggingface/gradio

Hi all,

I am trying to recreate the first part of lesson 10 in fast books by creating a Language Model, but I am using the yelp reviews dataset.

It seems to be working when I tests it out on kaggle however when I save the ‘finetuned.pth’ model and upload it to huggingface I get an error saying:

Traceback (most recent call last):
  File "/home/user/app/app.py", line 3, in <module>
    learn = load_learner('finetuned.pth')
  File "/usr/local/lib/python3.10/site-packages/fastai/learner.py", line 451, in load_learner
    res.dls.cpu()
AttributeError: 'collections.OrderedDict' object has no attribute 'dls'
Traceback (most recent call last):
  File "/home/user/app/app.py", line 3, in <module>
    learn = load_learner('finetuned.pth')
  File "/usr/local/lib/python3.10/site-packages/fastai/learner.py", line 451, in load_learner
    res.dls.cpu()
AttributeError: 'collections.OrderedDict' object has no attribute 'dls'

Have I loaded the model incorrectly?

Thanks in advance

I seem to have solved but dont understand why! Had some modules that werent needed in the requirements file. deleted them and app started to work. :grin: