-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
61 lines (48 loc) · 1.39 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
import pickle
from flask import Flask, request
app = Flask(__name__)
model_pickle = open("./Achira.pkl", "rb")
clf = pickle.load(model_pickle)
@app.route("/ping", methods=['GET'])
def ping():
return {"message": "Hi there, I'm working with the new API. Can you kindly input the parameters needed to run my model!!"}
@app.route("/params", methods=['GET'])
def get_application_params():
"""
"""
parameters = {
'input_path': "<path>",
'Dimensions': "<1024/512>",
'Number_of_Images': "100/1000",
'Shapes_to_detect': "4",
'Shapes_to_Draw': "<10/20>"
}
return parameters
##defining the endpoint which will make the prediction
@app.route("/classify", methods=['POST'])
def classify():
"""
Returns bounding boxes along with its class
"""
req = request.get_json()
print(req)
if req['Dimensions'] == "1024":
M = 1024
else:
M = 512
if req['Number_of_Images'] == "100":
num = 100
else:
num = 1000
if req['Shapes_to_Draw'] == "10":
N = 10
else:
N = 20
input_path = req['input_path']
Shapes_to_detect = req['4']
result = clf.classify([[input_path, Dimensions, Number_of_Images, Shapes_to_detect, Shapes_to_Draw]])
if result >= 0.90:
pred = "Good Accuracy"
else:
pred = "More Improvement needed"
return {"Final_detection_status": pred}