forked from osamhack2020/Infra_Meditact_Meditact
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpredict.py
26 lines (23 loc) · 867 Bytes
/
predict.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from flask import Flask, request, jsonify
from flask.json import JSONEncoder
from flask_cors import CORS, cross_origin
import keras
import api
app = Flask(__name__)
app.config['JSON_AS_ASCII'] = False
CORS(app)
#@app.route("/", methods =['POST'])
@app.route("/", methods =['GET'])
def model():
#----------------------------- TODO: reading user input json and extract sentence
payload = request.json
#-----------------------------
#input_features = api.preprocess_sentence("다리가 진짜 아파요")
input_features = api.preprocess_sentence(payload['conversation'])
model = keras.models.load_model('model_FINAL.h5', compile = False)
result = {
'model name': 'work',
'api ver': '1.0',
'predict result': str(api.get_result(model.predict(input_features))) ,
}
return jsonify(result)