File size: 675 Bytes
3467256
 
 
 
 
 
99f01e8
3467256
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import joblib
import numpy as np
from huggingface_hub import hf_hub_download

model_path = hf_hub_download(
    repo_id="24f2000010/iris-sklearn-model",
    filename="model.joblib"
)

model = joblib.load(model_path)

def predict(sl, sw, pl, pw):
    x = np.array([[sl, sw, pl, pw]])
    pred = model.predict(x)[0]
    return ["setosa", "versicolor", "virginica"][pred]

gr.Interface(
    fn=predict,
    inputs=[
        gr.Number(label="Sepal Length"),
        gr.Number(label="Sepal Width"),
        gr.Number(label="Petal Length"),
        gr.Number(label="Petal Width"),
    ],
    outputs="text",
    title="Iris Classification (sklearn)"
).launch()