-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.py
32 lines (25 loc) · 830 Bytes
/
app.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
27
28
29
30
31
32
import os
import numpy as np
from keras.models import load_model
from flask import Flask, render_template, request
app = Flask(__name__)
model = load_model('model/model.h5', compile=False)
model.compile(
optimizer = 'adam',
loss = 'categorical_crossentropy',
metrics = ['accuracy']
)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/predict')
def predict():
return render_template('predict.html')
@app.route('/result', methods=['GET', 'POST'])
def result():
features = [float(x) for x in request.form.values()]
final_features = np.array([features])
prediction = np.argmax(model.predict(final_features))
return render_template('predict.html', result=prediction)
if __name__ == '__main__':
app.run(debug=True, port=os.getenv("PORT", default=5000))