Spaces:
Sleeping
Sleeping
Upload 3 files
Browse filesSpecify the ingredients and identify the glass
- app.py +36 -0
- requirements.txt +3 -0
- stack_gls.pkl +3 -0
app.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import pickle
|
| 3 |
+
import pandas as pd
|
| 4 |
+
|
| 5 |
+
def predict(RI, Na, Mg, Al, Si, K, Ca, Ba, Fe):
|
| 6 |
+
tst = pd.DataFrame([[RI, Na, Mg, Al, Si, K, Ca, Ba, Fe]],
|
| 7 |
+
columns=['RI', 'Na', 'Mg', 'Al', 'Si', 'K', 'Ca', 'Ba', 'Fe'])
|
| 8 |
+
filehandler = open("stack_gls.pkl", "rb")
|
| 9 |
+
bm_loaded = pickle.load(filehandler)
|
| 10 |
+
print(tst)
|
| 11 |
+
return bm_loaded.predict(tst)[0]
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
with gr.Blocks() as demo:
|
| 15 |
+
with gr.Row():
|
| 16 |
+
RI = gr.Number(label='RI')
|
| 17 |
+
Na = gr.Number(label='Na')
|
| 18 |
+
Mg = gr.Number(label='Mg')
|
| 19 |
+
with gr.Row():
|
| 20 |
+
Al = gr.Number(label='Al')
|
| 21 |
+
Si = gr.Number(label='Si')
|
| 22 |
+
K = gr.Number(label='K')
|
| 23 |
+
with gr.Row():
|
| 24 |
+
Ca = gr.Number(label='Ca')
|
| 25 |
+
Ba = gr.Number(label='Ba')
|
| 26 |
+
Fe = gr.Number(label='Fe')
|
| 27 |
+
with gr.Row():
|
| 28 |
+
Type = gr.Text(label='Type')
|
| 29 |
+
with gr.Row():
|
| 30 |
+
button = gr.Button(value="Which Glass?")
|
| 31 |
+
button.click(predict,
|
| 32 |
+
inputs=[RI, Na, Mg, Al, Si, K, Ca, Ba, Fe],
|
| 33 |
+
outputs=[Type])
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
scikit-learn==1.7.2
|
| 2 |
+
pandas==2.3.3
|
| 3 |
+
gradio==5.48.0
|
stack_gls.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b88bb714307bb74df3e204e6cab127bc85402ccd62c7e77b68ee5e4aea664bbf
|
| 3 |
+
size 265585
|