keras模型做预测在linux一句句运行正常,但部署在falsk+uwsgi+nginx上,就报错,如图所示,求大佬解惑

如图在linux上一步步调试最后结果正常
clipboard.png
但部署在flask+uwsgi+nginx上就报错,报错如图所示,求大佬解惑

clipboard.png
uwsgi配置如图

clipboard.png

app = Flask(__name__)
app.debug = True
app.config.update(RESTFUL_JSON=dict(ensure_ascii=False))
api = Api(app)

@app.route('/')
def hello_world():
    return 'hello world'

@app.route('/SVM_TextSort/', methods=['POST'])
def add_task():
    neg1_entity_list,neg1_word_list,neg2_entity_list,neg2_word_list,lable_sen = sj.sentiment(title,text,entitylist,news1)
    if lable== '':
        lable = lable_sen
    else:
        lable = lable + ',' + lable_sen
import re
import load_config
from keras.preprocessing import sequence
import keras
import tensorflow as tf

def sentiment(title,text,entitylist,news1):
    neg1_entity_list = []
    neg1_word_list = []
    neg2_entity_list = []
    neg2_word_list = []
    lable = ''
    MAX_SENTENCE_LENGTH = 150
    if entitylist and title and text:
        entitylist = [entity for entity in entitylist if isinstance(entity,str)]
        org_entitylist = load_config.org.findall(' '.join(entitylist))
        if len(entitylist) == len(org_entitylist) or len(entitylist) == 0:
            neg1_entity_list = []
            neg1_word_list = []
            neg2_entity_list = []
            neg2_word_list = []
            lable = ''
        else:
            unneg_word = re.search(load_config.unneg,title)
            if not unneg_word:
                neg1_word = re.findall(load_config.neg1,title)
                neg2_word = re.findall(load_config.neg2,title)
                vec_sen = load_config.pn1vec.transform(news1)
                tf_sen = load_config.pn1transformer.transform(vec_sen)
                ch2_sen = load_config.pn1ch2.transform(tf_sen)
                ypn = load_config.pn1clf.predict(ch2_sen)
                neg_tit = load_config.negative_tit.search(title)
                neg_con = load_config.negative_cont.search(text)
                cnn_vec = load_config.cnn_tok.texts_to_sequences(news1)
                x_train = sequence.pad_sequences(cnn_vec,maxlen = MAX_SENTENCE_LENGTH)
                keras.backend.clear_session()
                global graph
                graph = tf.get_default_graph()
                with graph.as_default():
                    y = load_config.cnn_model.predict(x_train)
                print (y)
        return neg1_entity_list,neg1_word_list,neg2_entity_list,neg2_word_list,lable
阅读 1.6k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题