Then i put the exported model in a model directory. In app.py i just had
from fastai.text import *
learn = load_learner('model')
print(learn.predict('example'))
In the terminal, this created the right output.
Then however i added flask to the installation (pip install flask). I did not call it from app.py, still then the terminal gives me the same error output as before in the web app.
So I assume that it is some compatibility issue with flask?
I had a similar issue today. After doing a fresh install of fastai v1 (version 1.0.60 and pytorch 1.4.0) the imdb notebook from course-v3 lesson 3 failed on this cell:
data = TextClasDataBunch.from_csv(path, 'texts.csv')
data.show_batch()
with the error message:
ValueError: Value must be a nonnegative integer or None
The same code ran without problem in an old environment (fastai version 1.0.57 and pytorch 1.2.0), but not with fastai 1.0.60 and pytorch 1.2.0.
It looks like they changed the code of LSTM so you have to re-export your model after training (or loading saved weights) with PyTorch 1.4.0. This on their side, we can’t do anything about it inside fastai.
Got the same error when trying to deploy a trained model from FastAI (which I trained in Google Colab) with Flask. For me it worked when I did “pip install torch==1.2.0” and “pip install fastai==1.0.57” in my virtual environment on my laptop. Hope it helps