File size: 940 Bytes
6091059
6e4a161
 
 
6091059
6e4a161
 
 
6091059
 
 
 
 
6e4a161
6091059
 
 
 
 
 
 
 
 
 
 
 
 
6e4a161
6091059
 
 
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
import gradio as gr
import numpy as np
import pickle

# Load the trained model
model = pickle.load(open('model.pkl', 'rb'))
iris_labels = ['Setosa', 'Versicolor', 'Virginica']

# Define the prediction function
def predict_iris(sepal_length, sepal_width, petal_length, petal_width):
    data = np.array([[sepal_length, sepal_width, petal_length, petal_width]])
    prediction = model.predict(data)[0]
    return f"Predicted Iris Species: {iris_labels[prediction]}"

# Create the Gradio interface
iface = gr.Interface(
    fn=predict_iris,
    inputs=[
        gr.Number(label="Sepal Length (cm)"),
        gr.Number(label="Sepal Width (cm)"),
        gr.Number(label="Petal Length (cm)"),
        gr.Number(label="Petal Width (cm)")
    ],
    outputs="text",
    title="Iris Species Predictor",
    description="Enter the flower's measurements to predict the Iris species."
)

# Launch the app
if __name__ == "__main__":
    iface.launch()