File size: 1,147 Bytes
04fc35c 1fd4ca3 834cdd5 1fd4ca3 04fc35c 834cdd5 1fd4ca3 04fc35c 834cdd5 04fc35c 834cdd5 04fc35c 1fd4ca3 04fc35c 834cdd5 04fc35c 834cdd5 04fc35c 1fd4ca3 |
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 33 |
import gradio as gr
import joblib
import pandas as pd
from huggingface_hub import hf_hub_download
# Download model from Hugging Face Hub
model_path = hf_hub_download(repo_id="abhishek/autotrain-iris-xgboost", filename="model.joblib")
model = joblib.load(model_path)
# Input labels expected by the model
feature_names = ['feat_SepalLengthCm', 'feat_SepalWidthCm', 'feat_PetalLengthCm', 'feat_PetalWidthCm']
def predict(sepal_length, sepal_width, petal_length, petal_width):
data = pd.DataFrame([[sepal_length, sepal_width, petal_length, petal_width]], columns=feature_names)
prediction = model.predict(data)[0]
return f"Predicted Iris Class: {prediction}"
# Gradio interface
iface = gr.Interface(
fn=predict,
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 Species Predictor 🌸",
description="Enter flower features to predict the Iris species using a model trained with AutoTrain Tabular."
)
iface.launch()
|