-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
77 lines (52 loc) · 1.72 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from flask import Flask, render_template, redirect, request
from keras.layers import Dense, Input, Conv2D, LSTM, MaxPool2D, UpSampling2D
from keras.callbacks import EarlyStopping
from keras.utils import to_categorical
from numpy import argmax, array_equal
import matplotlib.pyplot as plt
from keras.models import load_model
from keras.models import Model
from imgaug import augmenters
import random
from datetime import datetime
from numpy import genfromtxt
import pandas as pd
import numpy as np
app = Flask(__name__)
my_data = genfromtxt('validation_MINIST.csv', delimiter=',')
model = load_model('model.h5')
preds = model.predict(my_data)
global_paths = []
@app.route('/', methods = ['GET', 'POST'])
def index():
#random.seed(datetime.now())
get_random = random.randint(0, 600)
# print(get_random)
f, ax = plt.subplots(1)
ax.imshow(my_data[get_random].reshape(28, 28))
path1 = "./static/{}q.png".format(get_random)
path2 = "./static/{}a.png".format(get_random)
plt.savefig(path1 , bbox_inches='tight')
f, ax = plt.subplots(1)
ax.imshow(preds[get_random].reshape(28, 28))
plt.savefig(path2 , bbox_inches='tight')
paths = [];
paths.append(path1)
paths.append(path2)
global_paths.append(path1)
global_paths.append(path2)
print(global_paths)
return render_template("index.html", paths = paths)
@app.route('/gallery', methods = ['GET', 'POST'])
def gallery():
return render_template("gallery.html", paths = global_paths)
# @app.route('/', methods = ['POST'])
# def upload():
# if request.method == 'POST':
# f = request.files['userfile']
# path = "./static/{}".format(f.filename)
# f.save(path)
# #paths = []
# return render_template("index.html", imgpath = path)
if __name__=='__main__':
app.run(debug=True)