Spaces:
Sleeping
Sleeping
File size: 864 Bytes
7c9c5ca 67bc5ef 7c9c5ca 67bc5ef 7c9c5ca 67bc5ef 7c9c5ca 6128517 7c9c5ca |
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 |
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()
|