Hi there,
I’m trying to load an exported fastai v2 model into a production environment by loading the model into a flask app.
My code is pretty simple:
from fastai2.text.all import load_learner
from fastai2.imports import *
from flask import Flask
app = Flask(__name__)
path = Path()
# print(path.ls(file_exts='.pkl'))
learn_inf = load_learner(path/'exported-model.pkl')
@app.route('/')
def hello():
return "Hello World!"
@app.route('/predict', methods=['POST'])
def show_post():
data = request.json
return learn_inf.predict(data.q)
if __name__ == '__main__':
app.run()
But when I run the app, I get this error:
AttributeError: Can't get attribute 'cluster' on <module 'spacy.lang.lex_attrs' from '/Users/username/.local/share/virtualenvs/news-category-predictor-fsb6DkGE/lib/python3.7/site-packages/spacy/lang/lex_attrs.py'>
When I try to run load_learner from a Colab notebook with the same model, it’s working. Am I missing something or completely down the wrong path here?
Thanks!