Spaces:
Sleeping
Sleeping
feat: excel file upload
Browse files- app.py +12 -1
- requirements.txt +2 -0
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import joblib
|
2 |
import gradio as gr
|
|
|
3 |
from models import HealthInsurance
|
4 |
|
5 |
def load_data():
|
@@ -49,19 +50,29 @@ def create_output_table():
|
|
49 |
interactive =False)
|
50 |
|
51 |
def create_file_object():
|
52 |
-
return gr.File(label = 'File upload'
|
|
|
53 |
|
|
|
54 |
|
|
|
|
|
|
|
55 |
|
56 |
def build_interface():
|
57 |
|
58 |
with gr.Blocks() as interface:
|
|
|
59 |
file_object = create_file_object()
|
60 |
input_table = create_input_table()
|
61 |
output_table = create_output_table()
|
62 |
|
63 |
greet_btn = gr.Button("Submit")
|
64 |
greet_btn.click(fn=predict, inputs=input_table, outputs=output_table)
|
|
|
|
|
|
|
|
|
65 |
|
66 |
interface.launch()
|
67 |
|
|
|
1 |
import joblib
|
2 |
import gradio as gr
|
3 |
+
import pandas as pd
|
4 |
from models import HealthInsurance
|
5 |
|
6 |
def load_data():
|
|
|
50 |
interactive =False)
|
51 |
|
52 |
def create_file_object():
|
53 |
+
return gr.File(label = 'File upload',
|
54 |
+
type = 'bytes')
|
55 |
|
56 |
+
def convert_file_to_pandas(file):
|
57 |
|
58 |
+
df = pd.read_excel(io = file)
|
59 |
+
|
60 |
+
return df
|
61 |
|
62 |
def build_interface():
|
63 |
|
64 |
with gr.Blocks() as interface:
|
65 |
+
|
66 |
file_object = create_file_object()
|
67 |
input_table = create_input_table()
|
68 |
output_table = create_output_table()
|
69 |
|
70 |
greet_btn = gr.Button("Submit")
|
71 |
greet_btn.click(fn=predict, inputs=input_table, outputs=output_table)
|
72 |
+
|
73 |
+
file_object.change(fn = convert_file_to_pandas,
|
74 |
+
inputs = file_object,
|
75 |
+
outputs = input_table)
|
76 |
|
77 |
interface.launch()
|
78 |
|
requirements.txt
CHANGED
@@ -13,6 +13,7 @@ charset-normalizer==2.1.1
|
|
13 |
click==8.1.3
|
14 |
cryptography==38.0.1
|
15 |
cycler==0.11.0
|
|
|
16 |
fastapi==0.82.0
|
17 |
ffmpy==0.3.0
|
18 |
fonttools==4.37.1
|
@@ -35,6 +36,7 @@ mdurl==0.1.2
|
|
35 |
monotonic==1.6
|
36 |
multidict==6.0.2
|
37 |
numpy==1.23.2
|
|
|
38 |
orjson==3.8.0
|
39 |
packaging==21.3
|
40 |
pandas==1.4.4
|
|
|
13 |
click==8.1.3
|
14 |
cryptography==38.0.1
|
15 |
cycler==0.11.0
|
16 |
+
et-xmlfile==1.1.0
|
17 |
fastapi==0.82.0
|
18 |
ffmpy==0.3.0
|
19 |
fonttools==4.37.1
|
|
|
36 |
monotonic==1.6
|
37 |
multidict==6.0.2
|
38 |
numpy==1.23.2
|
39 |
+
openpyxl==3.0.10
|
40 |
orjson==3.8.0
|
41 |
packaging==21.3
|
42 |
pandas==1.4.4
|