-
Notifications
You must be signed in to change notification settings - Fork 1
/
app2.py
63 lines (47 loc) · 1.4 KB
/
app2.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
from flask import Flask, render_template, request, url_for, Markup, jsonify
import pickle
import pandas as pd
import numpy as np
from sklearn.preprocessing import MinMaxScaler
from werkzeug.utils import secure_filename
import pickle
from flask import *
import os
from werkzeug.utils import secure_filename
import label_image
def load_image(image):
text = label_image.main(image)
return text
app = Flask(__name__) #Initialize the flask App
@app.route('/')
@app.route('/first')
def first():
return render_template('first.html')
@app.route('/login')
def login():
return render_template('login.html')
@app.route('/chart')
def chart():
return render_template('chart.html')
@app.route('/index')
def index():
return render_template('index.html')
@app.route('/predict', methods=['GET', 'POST'])
def upload():
if request.method == 'POST':
# Get the file from post request
f = request.files['file']
file_path = secure_filename(f.filename)
f.save(file_path)
# Make prediction
result = load_image(file_path)
result = result.title()
d = {"Normal":"✓",'Mild':"❌","Moderate":"❌","Severe":"❌","Proliferative":"❌"}
result = result+d[result]
#result = [result]
print(result)
os.remove(file_path)
return result
return None
if __name__ == '__main__':
app.run(debug=False,host='0.0.0.0')