File size: 1,006 Bytes
04fc35c
 
1fd4ca3
 
04fc35c
1fd4ca3
 
04fc35c
 
1fd4ca3
04fc35c
1fd4ca3
 
 
 
 
 
04fc35c
1fd4ca3
04fc35c
 
1fd4ca3
04fc35c
 
1fd4ca3
 
 
 
04fc35c
1fd4ca3
 
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
34
35
import gradio as gr
import pandas as pd
import joblib
from huggingface_hub import hf_hub_download

# Download model from Hugging Face
model_path = hf_hub_download(repo_id="abhishek/autotrain-iris-xgboost", filename="model.joblib")
model = joblib.load(model_path)

# Prediction function
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

# Gradio interface
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()