Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import joblib | |
| import numpy as np | |
| # Load model | |
| model = joblib.load("model.joblib") | |
| labels = ["setosa", "versicolor", "virginica"] | |
| def predict_iris(sepal_length, sepal_width, petal_length, petal_width): | |
| X = np.array([[sepal_length, sepal_width, petal_length, petal_width]]) | |
| probs = model.predict_proba(X)[0] | |
| idx = probs.argmax() | |
| return f"{labels[idx]} (Confidence: {probs[idx]:.2f})" | |
| # Gradio UI | |
| interface = 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=gr.Textbox(label="Prediction"), | |
| title="🌸 Iris Flower Classification", | |
| description="Enter flower measurements to predict the Iris species" | |
| ) | |
| interface.launch() | |