Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
+
|
| 4 |
+
with gr.Blocks() as demo:
|
| 5 |
+
dataset_df = {}
|
| 6 |
+
state = gr.State(value=0)
|
| 7 |
+
with gr.Row():
|
| 8 |
+
gr.Markdown("# Distributed Evaluation Parallel 😎")
|
| 9 |
+
with gr.Row():
|
| 10 |
+
upload = gr.UploadButton(label="Upload a file")
|
| 11 |
+
prev = gr.Button(value="Previous")
|
| 12 |
+
next = gr.Button(value="Next")
|
| 13 |
+
download = gr.Button(value="Download")
|
| 14 |
+
with gr.Row():
|
| 15 |
+
with gr.Column():
|
| 16 |
+
question = gr.Textbox(label="Question")
|
| 17 |
+
with gr.Column():
|
| 18 |
+
ground_truth = gr.Textbox(label="GT")
|
| 19 |
+
with gr.Column():
|
| 20 |
+
prediction = gr.Textbox(label="Prediction")
|
| 21 |
+
score = gr.Radio(["Incorrect", "Correct"], label="Score")
|
| 22 |
+
with gr.Row():
|
| 23 |
+
todos = gr.DataFrame()
|
| 24 |
+
done = gr.DataFrame()
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def csv2df(file):
|
| 28 |
+
df = pd.read_csv(file.name)
|
| 29 |
+
dataset_df.update(dict(df=df))
|
| 30 |
+
return update()
|
| 31 |
+
|
| 32 |
+
def prev_func():
|
| 33 |
+
state.value = max(state.value - 1, 0)
|
| 34 |
+
return update()
|
| 35 |
+
|
| 36 |
+
def next_func():
|
| 37 |
+
state.value = min(state.value + 1, len(dataset_df['df']) - 1)
|
| 38 |
+
return update()
|
| 39 |
+
|
| 40 |
+
def update():
|
| 41 |
+
q = dataset_df['df'].question.to_list()[state.value]
|
| 42 |
+
g = dataset_df['df'].answer.to_list()[state.value]
|
| 43 |
+
p = dataset_df['df'].prediction.to_list()[state.value]
|
| 44 |
+
return q, g, p, dataset_df['df'], dataset_df['df']
|
| 45 |
+
upload.upload(csv2df, upload, [question, ground_truth, prediction, todos, done])
|
| 46 |
+
prev.click(prev_func, None, [question, ground_truth, prediction, todos, done])
|
| 47 |
+
next.click(next_func, None, [question, ground_truth, prediction, todos, done])
|
| 48 |
+
|
| 49 |
+
demo.queue()
|
| 50 |
+
demo.launch(share=True)
|