Spaces:
Sleeping
Sleeping
Commit
•
26b27eb
1
Parent(s):
f87c68c
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pickle
|
2 |
+
def make_prediction(sepal_length,sepal_width,petal_length,petal_width):
|
3 |
+
with open("model_iris.pkl", "rb") as f:
|
4 |
+
clf = pickle.load(f)
|
5 |
+
preds = clf.predict([[sepal_length,sepal_width,petal_length,petal_width]])
|
6 |
+
if preds == 0:
|
7 |
+
return "IRIS-SETOSA"
|
8 |
+
elif preds == 1:
|
9 |
+
return "IRIS-VERSICOLOR"
|
10 |
+
else:
|
11 |
+
return "IRIS-VIRGINICA"
|
12 |
+
|
13 |
+
#Create the input component for Gradio since we are expecting 4 inputs
|
14 |
+
|
15 |
+
sep_len = gr.Number(label = "SEPAL LENGTH")
|
16 |
+
sep_wid = gr.Number(label = "SEPAL WIDTH")
|
17 |
+
pet_len = gr.Number(label = "PETAL LENGTH")
|
18 |
+
pet_wid = gr.Number(label = "PETAL WIDTH")
|
19 |
+
|
20 |
+
# We create the output
|
21 |
+
output = gr.Textbox()
|
22 |
+
|
23 |
+
|
24 |
+
app = gr.Interface(fn = make_prediction, inputs=[sep_len, sep_wid,pet_len,pet_wid], outputs=output)
|
25 |
+
app.launch()
|