Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
import numpy as np
|
| 4 |
import lightgbm as lgb
|
| 5 |
from sklearn.model_selection import train_test_split
|
| 6 |
from PIL import Image
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
title = "RegMix"
|
| 9 |
description = "TBD."
|
| 10 |
|
| 11 |
-
def infer(inputs):
|
| 12 |
df = pd.DataFrame(inputs, columns=headers)
|
| 13 |
|
| 14 |
X_columns = df.columns[0:-1]
|
|
@@ -166,7 +171,7 @@ def infer(inputs):
|
|
| 166 |
gr.Image(Image.open('tmp.png')),
|
| 167 |
df_val[['Target', 'Prediction']], ]
|
| 168 |
|
| 169 |
-
def
|
| 170 |
df = pd.read_csv(file.name,
|
| 171 |
# encoding='utf-8'
|
| 172 |
)
|
|
@@ -181,12 +186,20 @@ inputs = [gr.Dataframe(headers=headers, row_count = (8, "dynamic"), datatype='nu
|
|
| 181 |
outputs = [gr.ScatterPlot(), gr.Image(), gr.Dataframe(row_count = (2, "dynamic"), col_count=(2, "fixed"), datatype='number', label="Results", headers=["True Loss", "Pred Loss"])]
|
| 182 |
|
| 183 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
| 184 |
upload_button = gr.UploadButton(label="Upload", file_types = ['.csv'],
|
| 185 |
# live=True,
|
| 186 |
-
file_count = "single")
|
| 187 |
-
upload_button.upload(fn=
|
|
|
|
| 188 |
|
| 189 |
-
gr.Interface(infer, inputs=inputs, outputs=outputs, title
|
| 190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
|
|
|
|
| 192 |
demo.launch(debug=False)
|
|
|
|
| 1 |
+
# import sklearn
|
| 2 |
import gradio as gr
|
| 3 |
+
# import joblib
|
| 4 |
import pandas as pd
|
| 5 |
import numpy as np
|
| 6 |
import lightgbm as lgb
|
| 7 |
from sklearn.model_selection import train_test_split
|
| 8 |
from PIL import Image
|
| 9 |
+
# import datasets
|
| 10 |
+
|
| 11 |
+
# pipe = joblib.load("./model.pkl")
|
| 12 |
|
| 13 |
title = "RegMix"
|
| 14 |
description = "TBD."
|
| 15 |
|
| 16 |
+
def infer(inputs, additional_inputs):
|
| 17 |
df = pd.DataFrame(inputs, columns=headers)
|
| 18 |
|
| 19 |
X_columns = df.columns[0:-1]
|
|
|
|
| 171 |
gr.Image(Image.open('tmp.png')),
|
| 172 |
df_val[['Target', 'Prediction']], ]
|
| 173 |
|
| 174 |
+
def upload_csv(file):
|
| 175 |
df = pd.read_csv(file.name,
|
| 176 |
# encoding='utf-8'
|
| 177 |
)
|
|
|
|
| 186 |
outputs = [gr.ScatterPlot(), gr.Image(), gr.Dataframe(row_count = (2, "dynamic"), col_count=(2, "fixed"), datatype='number', label="Results", headers=["True Loss", "Pred Loss"])]
|
| 187 |
|
| 188 |
with gr.Blocks() as demo:
|
| 189 |
+
|
| 190 |
+
####
|
| 191 |
upload_button = gr.UploadButton(label="Upload", file_types = ['.csv'],
|
| 192 |
# live=True,
|
| 193 |
+
file_count = "single", render=False)
|
| 194 |
+
upload_button.upload(fn=upload_csv, inputs=upload_button, outputs=inputs, api_name="upload_csv")
|
| 195 |
+
####
|
| 196 |
|
| 197 |
+
gr.Interface(infer, inputs=inputs, outputs=outputs, title=title,
|
| 198 |
+
additional_inputs = [upload_button],
|
| 199 |
+
additional_inputs_accordion='Upload CSV',
|
| 200 |
+
description = description,
|
| 201 |
+
examples=[[df], []],
|
| 202 |
+
cache_examples=False, allow_flagging='never')
|
| 203 |
|
| 204 |
+
|
| 205 |
demo.launch(debug=False)
|