File size: 859 Bytes
16d1faf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import joblib
import numpy as np
import sklearn 

# Load the saved model
loaded_model = joblib.load('iris_model.sav')

def predict_iris(sepal_length, sepal_width, petal_length, petal_width):
    input_data = np.array([[sepal_length, sepal_width, petal_length, petal_width]])
    prediction = loaded_model.predict(input_data)[0]
    iris_classes = ['setosa', 'versicolor', 'virginica']
    return iris_classes[prediction]

iface = gr.Interface(
    fn=predict_iris,
    inputs=[
        gr.Number(label="Sepal Length"),
        gr.Number(label="Sepal Width"),
        gr.Number(label="Petal Length"),
        gr.Number(label="Petal Width")
    ],
    outputs=gr.Textbox(label="Predicted Iris Class"),
    title="Iris Flower Classification",
    description="Enter sepal and petal measurements to predict the Iris species."
)

iface.launch()