-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver.py
37 lines (26 loc) · 1.14 KB
/
server.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
# -*- coding: utf-8 -*-
"""server.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1sS5JIOv0kfQc0Bq1t6OrBYyznjpzm8SQ
"""
import numpy as np
from flask import Flask, request, jsonify
import pickle
import tensorflow as tf
app = Flask(__name__)
model_load=pickle.load(open('model.pkl','rb'))
@app.route('/api/',methods=['POST'])
def predict():
# Get the data from the POST request.
data = request.get_json(force=True)
# Make prediction using model loaded from disk as per the data.
prediction = model_load.predict([[np.array(data['age', 'gender', 'polyuria', 'polydipsia', 'sudden_weight_loss', 'weakness', 'polyphagia', 'genital_thrush', 'visual_blurring', 'itching', 'irritability', 'delayed_healing', 'partial_paresis', 'muscle_stiffness', 'alopecia', 'obesity'])]])
# Take the first value of prediction
output = prediction[40, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1]
return jsonify(output)
if __name__ == '__main__':
try:
app.run(port=5000, debug=True)
except:
print("Server is exited unexpectedly. Please contact server admin.")