forked from ygarg704/ph-value-recognition-based-on-rgb-color
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
42 lines (29 loc) · 975 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
36
37
38
39
40
41
42
from flask import Flask, render_template, request
import pandas as pd
import re
import os
import joblib
from sklearn.preprocessing import StandardScaler
app = Flask(__name__)
@app.route('/')
def index():
return render_template("index.html")
@app.route('/second', methods=['POST'])
def second():
if request.method == 'POST':
comment1 = request.form['blue']
comment2 = request.form['green']
comment3 = request.form['red']
comment = [comment1, comment2, comment3]
ds = pd.read_csv('dataset/ph-data.csv')
X = ds.iloc[:, :-1]
X.loc[len(X)] = comment
X = X.values
sc = StandardScaler()
X = sc.fit_transform(X)
model = joblib.load('notebook/model.pkl')
pred = model.predict(X)[-1]
print(pred)
return render_template("result.html", prediction=pred, comments1=comment1, comments2=comment2, comments3=comment3)
if __name__ == '__main__':
app.run()