-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
40 lines (23 loc) · 976 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
from flask import Flask, request, render_template
import pickle
file1 = open('bodyfatmodel.pkl', 'rb')
rf = pickle.load(file1)
file1.close()
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def predict():
if request.method == 'POST':
my_dict = request.form
density = float(my_dict['density'])
abdomen = float(my_dict['abdomen'])
chest = float(my_dict['chest'])
weight = float(my_dict['weight'])
hip = float(my_dict['hip'])
input_features = [[density, abdomen, chest, weight, hip]]
prediction = rf.predict(input_features)[0].round(2)
# <p class="big-font">Hello World !!</p>', unsafe_allow_html=True
string = 'Percentage of Body Fat Estimated is : ' + str(prediction)+'%'
return render_template('show.html', string=string)
return render_template('home.html')
if __name__ == "__main__":
app.run(debug=True)