Spaces:
Sleeping
Sleeping
Download app.py from Vamshiboss8055/iris-api: direct link, hf CLI and curl.
- Browser
- Download file 864 Bytes
-
https://huggingface.co/spaces/Vamshiboss8055/iris-api/resolve/main/app.py
- Command line
-
hf download hf://spaces/Vamshiboss8055/iris-api/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Vamshiboss8055/iris-api/resolve/main/app.py
864 Bytes
| 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() | |