Spaces:
Sleeping
Sleeping
import gradio as gr | |
import skops.io as sio | |
pipe = sio.load("glass_pipeline.skops", trusted=True) | |
classes = [ | |
"None", | |
"Building Windows Float Processed", | |
"Building Windows Non Float Processed", | |
"Vehicle Windows Float Processed", | |
"Vehicle Windows Non Float Processed", | |
"Containers", | |
"Tableware", | |
"Headlamps", | |
] | |
def classifier(RI, Na, Mg, Al, Si, K, Ca, Ba, Fe): | |
pred_glass = pipe.predict([[RI, Na, Mg, Al, Si, K, Ca, Ba, Fe]])[0] | |
label = f"Predicted Glass label: **{classes[pred_glass]}**" | |
return label | |
inputs = [ | |
gr.Slider(1.51, 1.54, step=0.01, label="Refractive Index"), | |
gr.Slider(10, 17, step=1, label="Sodium"), | |
gr.Slider(0, 4.5, step=0.5, label="Magnesium"), | |
gr.Slider(0.3, 3.5, step=0.1, label="Aluminum"), | |
gr.Slider(69.8, 75.4, step=0.1, label="Silicon"), | |
gr.Slider(0, 6.2, step=0.1, label="Potassium"), | |
gr.Slider(5.4, 16.19, step=0.1, label="Calcium"), | |
gr.Slider(0, 3, step=0.1, label="Barium"), | |
gr.Slider(0, 0.5, step=0.1, label="Iron"), | |
] | |
outputs = [gr.Label(num_top_classes=7)] | |
title = "Glass Classification" | |
description = "Enter the details to correctly identify glass type?" | |
gr.Interface( | |
fn=classifier, | |
inputs=inputs, | |
outputs=outputs, | |
title=title, | |
description=description, | |
).launch() |