Atul-jha commited on
Commit
43ef764
1 Parent(s): 3dc1092

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask,request, url_for, redirect, render_template
2
+ import pickle
3
+ import numpy as np
4
+
5
+ app = Flask(__name__)
6
+
7
+ model=pickle.load(open('model.pkl','rb'))
8
+
9
+
10
+ @app.route('/')
11
+ def hello_world():
12
+ return render_template("forest_fire.html")
13
+
14
+
15
+ @app.route('/predict',methods=['POST','GET'])
16
+ def predict():
17
+ int_features=[int(x) for x in request.form.values()]
18
+ final=[np.array(int_features)]
19
+ print(int_features)
20
+ print(final)
21
+ prediction=model.predict_proba(final)
22
+ output='{0:.{1}f}'.format(prediction[0][1], 2)
23
+
24
+ if output>str(0.5):
25
+ return render_template('forest_fire.html',pred='Your Forest is in Danger.\nProbability of fire occuring is {}'.format(output),bhai="kuch karna hain iska ab?")
26
+ else:
27
+ return render_template('forest_fire.html',pred='Your Forest is safe.\n Probability of fire occuring is {}'.format(output),bhai="Your Forest is Safe for now")
28
+
29
+
30
+ if __name__ == '__main__':
31
+ app.run(debug=True)