|
import gradio as gr |
|
import pandas as pd |
|
import joblib |
|
from huggingface_hub import hf_hub_download |
|
|
|
|
|
model_path = hf_hub_download(repo_id="abhishek/autotrain-iris-xgboost", filename="model.joblib") |
|
model = joblib.load(model_path) |
|
|
|
|
|
def predict(sepal_length, sepal_width, petal_length, petal_width): |
|
input_df = pd.DataFrame([{ |
|
"feat_SepalLengthCm": sepal_length, |
|
"feat_SepalWidthCm": sepal_width, |
|
"feat_PetalLengthCm": petal_length, |
|
"feat_PetalWidthCm": petal_width |
|
}]) |
|
prediction = model.predict(input_df)[0] |
|
return prediction |
|
|
|
|
|
iface = gr.Interface( |
|
fn=predict, |
|
inputs=[ |
|
gr.Slider(4.0, 8.0, label="Sepal Length (cm)"), |
|
gr.Slider(2.0, 5.0, label="Sepal Width (cm)"), |
|
gr.Slider(1.0, 7.0, label="Petal Length (cm)"), |
|
gr.Slider(0.1, 3.0, label="Petal Width (cm)") |
|
], |
|
outputs="text", |
|
title="Iris Flower Classifier 🌸" |
|
) |
|
|
|
iface.launch() |
|
|