-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.py
35 lines (22 loc) · 964 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
33
34
35
from flask import Flask, render_template, request
# Import your models
from gpt2_predictor import Gpt2_predictor
from mnist_predictor import MNIST_predictor
app = Flask(__name__)
# Instantiate your models
gpt2 = Gpt2_predictor()
mnist = MNIST_predictor()
# Base endpoint to perform prediction.
@app.route('/', methods=['POST'])
def make_prediction():
if request.form['predictor'] == 'mnist':
prediction = mnist.predict(request)
return render_template('index.html', prediction=prediction, generated_text=None, tab_to_show='mnist')
elif request.form['predictor'] == 'gpt2':
generated_text = gpt2.predict(request)
return render_template('index.html', prediction=None, generated_text=generated_text, tab_to_show='gpt2')
@app.route('/', methods=['GET'])
def load():
return render_template('index.html', prediction=None, generated_text=None, tab_to_show='mnist')
if __name__ == '__main__':
app.run(debug=True)