Spaces:
Sleeping
Sleeping
Commit ·
8b19a5b
1
Parent(s): e9627f4
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import skops.io as sio
|
| 3 |
+
|
| 4 |
+
pipe = sio.load("glass_pipeline.skops", trusted=True)
|
| 5 |
+
|
| 6 |
+
classes = [
|
| 7 |
+
"None",
|
| 8 |
+
"Building Windows Float Processed",
|
| 9 |
+
"Building Windows Non Float Processed",
|
| 10 |
+
"Vehicle Windows Float Processed",
|
| 11 |
+
"Vehicle Windows Non Float Processed",
|
| 12 |
+
"Containers",
|
| 13 |
+
"Tableware",
|
| 14 |
+
"Headlamps",
|
| 15 |
+
]
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def classifier(RI, Na, Mg, Al, Si, K, Ca, Ba, Fe):
|
| 19 |
+
pred_glass = pipe.predict([[RI, Na, Mg, Al, Si, K, Ca, Ba, Fe]])[0]
|
| 20 |
+
label = f"Predicted Glass label: **{classes[pred_glass]}**"
|
| 21 |
+
return label
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
inputs = [
|
| 25 |
+
gr.Slider(1.51, 1.54, step=0.01, label="Refractive Index"),
|
| 26 |
+
gr.Slider(10, 17, step=1, label="Sodium"),
|
| 27 |
+
gr.Slider(0, 4.5, step=0.5, label="Magnesium"),
|
| 28 |
+
gr.Slider(0.3, 3.5, step=0.1, label="Aluminum"),
|
| 29 |
+
gr.Slider(69.8, 75.4, step=0.1, label="Silicon"),
|
| 30 |
+
gr.Slider(0, 6.2, step=0.1, label="Potassium"),
|
| 31 |
+
gr.Slider(5.4, 16.19, step=0.1, label="Calcium"),
|
| 32 |
+
gr.Slider(0, 3, step=0.1, label="Barium"),
|
| 33 |
+
gr.Slider(0, 0.5, step=0.1, label="Iron"),
|
| 34 |
+
]
|
| 35 |
+
outputs = [gr.Label(num_top_classes=7)]
|
| 36 |
+
|
| 37 |
+
title = "Glass Classification"
|
| 38 |
+
description = "Enter the details to correctly identify glass type?"
|
| 39 |
+
|
| 40 |
+
gr.Interface(
|
| 41 |
+
fn=classifier,
|
| 42 |
+
inputs=inputs,
|
| 43 |
+
outputs=outputs,
|
| 44 |
+
title=title,
|
| 45 |
+
description=description,
|
| 46 |
+
).launch()
|