如图在linux上一步步调试最后结果正常
但部署在flask+uwsgi+nginx上就报错,报错如图所示,求大佬解惑
uwsgi配置如图
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