File size: 1,318 Bytes
06a64ab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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(share=True)