Spaces:
Sleeping
Sleeping
yoonho
commited on
Commit
·
b7f4b99
1
Parent(s):
d7dde67
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
def classifier(RI, Na, Mg, Al, Si, K, Ca, Ba, Fe):
|
18 |
+
pred_glass = pipe.predict([[RI, Na, Mg, Al, Si, K, Ca, Ba, Fe]])[0]
|
19 |
+
label = f"Predicted Glass label: **{classes[pred_glass]}**"
|
20 |
+
return label
|
21 |
+
|
22 |
+
inputs = [
|
23 |
+
gr.Slider(1.51, 1.54, step=0.01, label="Refractive Index"),
|
24 |
+
gr.Slider(10, 17, step=1, label="Sodium"),
|
25 |
+
gr.Slider(0, 4.5, step=0.5, label="Magnesium"),
|
26 |
+
gr.Slider(0.3, 3.5, step=0.1, label="Aluminum"),
|
27 |
+
gr.Slider(69.8, 75.4, step=0.1, label="Silicon"),
|
28 |
+
gr.Slider(0, 6.2, step=0.1, label="Potassium"),
|
29 |
+
gr.Slider(5.4, 16.19, step=0.1, label="Calcium"),
|
30 |
+
gr.Slider(0, 3, step=0.1, label="Barium"),
|
31 |
+
gr.Slider(0, 0.5, step=0.1, label="Iron"),
|
32 |
+
]
|
33 |
+
outputs = [gr.Label(num_top_classes=7)]
|
34 |
+
|
35 |
+
title = "Glass Classification"
|
36 |
+
description = "Enter the details to correctly identify glass type?"
|
37 |
+
|
38 |
+
gr.Interface(
|
39 |
+
fn=classifier,
|
40 |
+
inputs=inputs,
|
41 |
+
outputs=outputs,
|
42 |
+
title=title,
|
43 |
+
description=description,
|
44 |
+
).launch()
|