烧瓶应用。
我试图joblib.load并获得AttributeError 'ManyToOneClassifier'。
但是我已经用类导入了所有模块。如果我尝试将它加载到模块中的类中,那么它......再次出错。
但是当我在 __ main __ 中加载它时 - 很好,一切正常......上传时,uwsgi在我的 __ main __ 中看不到任何东西。
我是 C# 程序员(.NET、Microsoft 等),对 nginx 和 Linux 不太了解。
from clf_service import app, classificator
from clf_service.classificator import ManyClassifier, ManyToOneClassifier
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.externals import joblib
from os import path
application = app
APP_ROOT = path.dirname(path.abspath(__file__))
print "Loading models"
app.model = joblib.load(path.join(APP_ROOT, "clf_service/static/ml/clf/model_vec_to_one.pkl"))
app.vec = joblib.load(path.join(APP_ROOT, "clf_service/static/ml/clf/vec_to_one.pkl"))
print "Done, we are ready!"
if __name__ == '__main__':
app.run(debug=False)
__ 初始化 __.py
from flask.ext.sqlalchemy import SQLAlchemy
from flask import Flask
application = Flask(__name__)
app = application
app.config.from_object('config')
db = SQLAlchemy(app)
from clf_service import views, models, classificator