Cannot import load_learner

My system automatically updated from fastai v1 to v2. I have a text model that has been in production and was trained from fastai v1. It is stored in Microsoft Azure Storage as a block blob and I have been using load_learner to load it from a file path and to predict.

from fastai import load_learner
path = ‘/dbfs/mnt/lake/users/helena_shi’
learn = load_learner(path, ‘final_whole’) *final_whole = trained model name
learn.predict(text)

I would like to restore my previous function as that had no issues so I have installed fastai v1 with pip install https://github.com/fastai/fastai1/archive/master.zip but that only installs fastai v1.0.34 when I need 1.4.0 to use load_learner.
Alternatively, does fastai v2 have a similiar function to directly load a model from a path and predict with or do I need to retrain my existing model with the new syntax?
Please advise - thank you!

I don’t think there is a fastai v1.4.0. Do you mean PyTorch 1.4.0?

I don’t think fastai v1 models will work with fastai v2 library, unfortunately.

Hello @helenas
I have the same issue : ImportError: cannot import name 'load_learner' from 'fastai.vision'
I have python 3.8.2 and I’m unable to install fastai v1
pip install fastai automatically installs fastai==2.0.6

Is there any solution to be able to import / use load_learner in fastai 2 ? Or to install fastai 1 with python 3.8 ? :face_with_monocle:

Thank you :pray:

hello @alaeddinez
I have used pip install from fastai gitlab archives for fastai v1, but load_learner() doesn’t work in this version (1.0.34) for me.

pip install https://github.com/fastai/fastai1/archive/master.zip

appreciate any thoughts or input from others on how to install the last updated version of fastai v1 before it was updated to v2

Hello @helenas,
I didn’t find a proper way to install previous fastai version while using python 3.8
When doing pip install fastai==1.0.57 or whatever 1.0.x version, I encounter a problem with pynvx

The only way I found is :

  • installing fastai without dependencies : pip install --no-deps fastai
  • manually installing the dependencies using pip command (except pynvx and bottleneck which caused a problem for me)

that allows me to have fastai v1 with python 3.8 on macOS. I tried
from fastai.vision import load_learner and that works

Tell me if that helps !

is there any way to do the same for fastai v2

the community for fast ai looks very small, people normally are not able to find answer and had to look toward other algos unfortunately. I am algo going back to conventional networks, After spending hours no solution.