我正在尝试使用Flask在我的OpenLiteSpeed VPS中设置fastai图像推断应用程序。我有基本的“ Hello world”,但是尝试添加模型会破坏事情。在命令行中运行不会出错。如何解决问题?
app.py
from flask import Flask
from flask import request
from fastai.vision import *
learn = load_learner("","modelv2.pkl") # This line will break things
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello, World"
if __name__ == "__main__":
app.run()
app.wsgi
#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/usr/local/lsws/website/html/python/")
from flask_app import app as application
application.secret_key = 'Add your secret key'