File size: 773 Bytes
8e73db1 a0a3eef 8e73db1 f8f7839 8e73db1 ec85363 8e73db1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import pickle
import gradio as gr
def make_predicition(sepal_length,sepal_width,petal_length,petal_width):
with open("model_iris.pkl","rb") as f:
clf=pickle.load(f)
preds=clf.predict([[sepal_length,sepal_width,petal_length,petal_width]])
if preds==0:
return "IRIS-SETOSA"
elif preds==1:
return "IRIS-VERSICOLOR"
else:
return "IRIS-VIRGINICA"
#CREATE the input component for Gradio since we are expecting 4 inputs
sep_len=gr.Number(label="SEPAL LENGTH")
sep_wid=gr.Number(label="SEPAL WIDTH")
pet_len=gr.Number(label="PETAL LENGTH")
pet_wid=gr.Number(label="PETAL WIDTH")
#create the output
output=gr.Textbox()
app=gr.Interface(fn=make_predicition,inputs=[sep_len,sep_wid,pet_len,pet_wid],outputs=output)
app.launch() |