-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.py
75 lines (53 loc) · 1.9 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
65
66
67
68
69
70
71
72
73
74
75
from flask import Flask,request, url_for, redirect, render_template
import pickle
import joblib
import numpy as np
import tensorflow as tf
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
model = tf.keras.models.load_model('my-model.h5')
# @app.route('/')
# def hello_world():
# return render_template("index.js")
@app.route('/predict',methods=['POST','GET'])
def predict():
# final=[np.array(int_features)]
# print(int_features)
# print(final)
# prediction=model.predict_proba(final)
# output='{0:.{1}f}'.format(prediction[0][1], 2)
if request.method == 'GET':
return {'req':'successful'}
if request.method == 'POST':
# print(request.get_json().'loan_history')
object=request.get_json()
object=object.values()
arr=[int(i) for i in list(object)]
# print(arr)
arr=np.array(arr)
arr=np.expand_dims(arr,0)
print(arr.shape)
prediction = model.predict(arr)
percentage = prediction[0][0]*100
percentage=str(int(percentage))
print(percentage)
print(prediction)
# return '{}'.format(percentage)
return percentage
# return {'percentage':prediction}
# return prediction
# print(object['check_telephone'])
# print(object.items().values())
# int_features=[int(value) for value in list(object.values())]
# print(int_features)
# int_features=[int(x) for x in (request.get_json())]
# print(int_features)
# print({'post-req':'successful'})
return {'post-req':'predict hogya'}
# if output>str(0.5):
# return render_template('./components/percentagemeter.jsx',percentage='{}'.format(output))
# else:
# return render_template('./components/percentagemeter.jsx',percentage='{}'.format(output))
if __name__ == '__main__':
app.run(debug=True)