umair894 commited on
Commit
16d1faf
·
verified ·
1 Parent(s): a451d94

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import joblib
3
+ import numpy as np
4
+ import sklearn
5
+
6
+ # Load the saved model
7
+ loaded_model = joblib.load('iris_model.sav')
8
+
9
+ def predict_iris(sepal_length, sepal_width, petal_length, petal_width):
10
+ input_data = np.array([[sepal_length, sepal_width, petal_length, petal_width]])
11
+ prediction = loaded_model.predict(input_data)[0]
12
+ iris_classes = ['setosa', 'versicolor', 'virginica']
13
+ return iris_classes[prediction]
14
+
15
+ iface = gr.Interface(
16
+ fn=predict_iris,
17
+ inputs=[
18
+ gr.Number(label="Sepal Length"),
19
+ gr.Number(label="Sepal Width"),
20
+ gr.Number(label="Petal Length"),
21
+ gr.Number(label="Petal Width")
22
+ ],
23
+ outputs=gr.Textbox(label="Predicted Iris Class"),
24
+ title="Iris Flower Classification",
25
+ description="Enter sepal and petal measurements to predict the Iris species."
26
+ )
27
+
28
+ iface.launch()