Saving and using a model

I have trained a model on top of the ULMFiT pre-trained model, and have saved it using the .save(’…’) command. I would now like to load this model elsewhere and use it for classification. However, I’m not able to figure out how to load this model and use it. Using the save fn generates a .pth file, which I’m not sure how to use.

1 Like

Try learn.export() and then learn = load_learner(path). Then you can learn.predict() whatever target data you need to in production. See https://docs.fast.ai/tutorial.inference.html.

learn.save() requires that you reload the databunch when you spin it up, which you don’t want.

8 Likes

This throws an error.
‘str’ object has no attribute ‘apply_tfms’