Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Put Tasks into tabs and merge Load Result buttons
Browse files
app.py
CHANGED
|
@@ -105,6 +105,10 @@ def get_result_path_from_model(model_id, result_path_per_model):
|
|
| 105 |
return result_path_per_model[model_id]
|
| 106 |
|
| 107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
def load_data(result_path) -> pd.DataFrame:
|
| 109 |
with fs.open(result_path, "r") as f:
|
| 110 |
data = json.load(f)
|
|
@@ -112,6 +116,8 @@ def load_data(result_path) -> pd.DataFrame:
|
|
| 112 |
|
| 113 |
|
| 114 |
def load_results_dataframe(model_id):
|
|
|
|
|
|
|
| 115 |
result_path = get_result_path_from_model(model_id, latest_result_path_per_model)
|
| 116 |
data = load_data(result_path)
|
| 117 |
model_name = data.get("model_name", "Model")
|
|
@@ -146,7 +152,7 @@ def display_tab(tab, df, task):
|
|
| 146 |
return df.to_html()
|
| 147 |
|
| 148 |
|
| 149 |
-
def
|
| 150 |
return gr.Radio(
|
| 151 |
["All"] + list(TASKS.values()),
|
| 152 |
label="Tasks",
|
|
@@ -156,7 +162,7 @@ def update_tasks(task):
|
|
| 156 |
)
|
| 157 |
|
| 158 |
|
| 159 |
-
def
|
| 160 |
return gr.Radio(
|
| 161 |
SUBTASKS.get(task),
|
| 162 |
info="Evaluation subtasks to be displayed",
|
|
@@ -209,31 +215,37 @@ with gr.Blocks(fill_height=True) as demo:
|
|
| 209 |
with gr.Row():
|
| 210 |
with gr.Column():
|
| 211 |
model_id_1 = gr.Dropdown(choices=list(latest_result_path_per_model.keys()), label="Models")
|
| 212 |
-
load_btn_1 = gr.Button("Load")
|
| 213 |
dataframe_1 = gr.Dataframe(visible=False)
|
| 214 |
with gr.Column():
|
| 215 |
model_id_2 = gr.Dropdown(choices=list(latest_result_path_per_model.keys()), label="Models")
|
| 216 |
-
load_btn_2 = gr.Button("Load")
|
| 217 |
dataframe_2 = gr.Dataframe(visible=False)
|
| 218 |
-
with gr.Row():
|
| 219 |
-
task = gr.Radio(
|
| 220 |
-
["All"] + list(TASKS.values()),
|
| 221 |
-
label="Tasks",
|
| 222 |
-
info="Evaluation tasks to be displayed",
|
| 223 |
-
value="All",
|
| 224 |
-
interactive=False,
|
| 225 |
-
)
|
| 226 |
|
| 227 |
with gr.Row():
|
| 228 |
# with gr.Tab("All"):
|
| 229 |
# pass
|
| 230 |
with gr.Tab("Results"):
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
with gr.Tab("Details"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
subtask = gr.Radio(
|
| 236 |
-
SUBTASKS.get(
|
| 237 |
label="Subtasks",
|
| 238 |
info="Evaluation subtasks to be displayed (choose one of the Tasks above)",
|
| 239 |
)
|
|
@@ -244,20 +256,15 @@ with gr.Blocks(fill_height=True) as demo:
|
|
| 244 |
details_dataframe_2 = gr.Dataframe(visible=False)
|
| 245 |
details_dataframe = gr.DataFrame(visible=False)
|
| 246 |
|
| 247 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
fn=load_results_dataframe,
|
| 249 |
inputs=model_id_1,
|
| 250 |
outputs=dataframe_1,
|
| 251 |
).then(
|
| 252 |
-
fn=display_results,
|
| 253 |
-
inputs=[dataframe_1, dataframe_2, task],
|
| 254 |
-
outputs=[results, configs],
|
| 255 |
-
).then(
|
| 256 |
-
fn=update_tasks,
|
| 257 |
-
inputs=task,
|
| 258 |
-
outputs=task,
|
| 259 |
-
)
|
| 260 |
-
load_btn_2.click(
|
| 261 |
fn=load_results_dataframe,
|
| 262 |
inputs=model_id_2,
|
| 263 |
outputs=dataframe_2,
|
|
@@ -266,7 +273,7 @@ with gr.Blocks(fill_height=True) as demo:
|
|
| 266 |
inputs=[dataframe_1, dataframe_2, task],
|
| 267 |
outputs=[results, configs],
|
| 268 |
).then(
|
| 269 |
-
fn=
|
| 270 |
inputs=task,
|
| 271 |
outputs=task,
|
| 272 |
)
|
|
@@ -274,12 +281,13 @@ with gr.Blocks(fill_height=True) as demo:
|
|
| 274 |
fn=display_results,
|
| 275 |
inputs=[dataframe_1, dataframe_2, task],
|
| 276 |
outputs=[results, configs],
|
| 277 |
-
).then(
|
| 278 |
-
fn=update_subtasks,
|
| 279 |
-
inputs=task,
|
| 280 |
-
outputs=subtask,
|
| 281 |
)
|
| 282 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 283 |
load_details_btn.click(
|
| 284 |
fn=load_details_dataframe,
|
| 285 |
inputs=[model_id_1, subtask],
|
|
|
|
| 105 |
return result_path_per_model[model_id]
|
| 106 |
|
| 107 |
|
| 108 |
+
def update_load_results_component():
|
| 109 |
+
return gr.Button("Load Results", interactive=True)
|
| 110 |
+
|
| 111 |
+
|
| 112 |
def load_data(result_path) -> pd.DataFrame:
|
| 113 |
with fs.open(result_path, "r") as f:
|
| 114 |
data = json.load(f)
|
|
|
|
| 116 |
|
| 117 |
|
| 118 |
def load_results_dataframe(model_id):
|
| 119 |
+
if not model_id:
|
| 120 |
+
return
|
| 121 |
result_path = get_result_path_from_model(model_id, latest_result_path_per_model)
|
| 122 |
data = load_data(result_path)
|
| 123 |
model_name = data.get("model_name", "Model")
|
|
|
|
| 152 |
return df.to_html()
|
| 153 |
|
| 154 |
|
| 155 |
+
def update_tasks_component(task):
|
| 156 |
return gr.Radio(
|
| 157 |
["All"] + list(TASKS.values()),
|
| 158 |
label="Tasks",
|
|
|
|
| 162 |
)
|
| 163 |
|
| 164 |
|
| 165 |
+
def update_subtasks_component(task):
|
| 166 |
return gr.Radio(
|
| 167 |
SUBTASKS.get(task),
|
| 168 |
info="Evaluation subtasks to be displayed",
|
|
|
|
| 215 |
with gr.Row():
|
| 216 |
with gr.Column():
|
| 217 |
model_id_1 = gr.Dropdown(choices=list(latest_result_path_per_model.keys()), label="Models")
|
|
|
|
| 218 |
dataframe_1 = gr.Dataframe(visible=False)
|
| 219 |
with gr.Column():
|
| 220 |
model_id_2 = gr.Dropdown(choices=list(latest_result_path_per_model.keys()), label="Models")
|
|
|
|
| 221 |
dataframe_2 = gr.Dataframe(visible=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
|
| 223 |
with gr.Row():
|
| 224 |
# with gr.Tab("All"):
|
| 225 |
# pass
|
| 226 |
with gr.Tab("Results"):
|
| 227 |
+
task = gr.Radio(
|
| 228 |
+
["All"] + list(TASKS.values()),
|
| 229 |
+
label="Tasks",
|
| 230 |
+
info="Evaluation tasks to be displayed",
|
| 231 |
+
value="All",
|
| 232 |
+
interactive=False,
|
| 233 |
+
)
|
| 234 |
+
load_results_btn = gr.Button("Load Results", interactive=False)
|
| 235 |
+
with gr.Tab("Results"):
|
| 236 |
+
results = gr.HTML()
|
| 237 |
+
with gr.Tab("Configs"):
|
| 238 |
+
configs = gr.HTML()
|
| 239 |
with gr.Tab("Details"):
|
| 240 |
+
details_task = gr.Radio(
|
| 241 |
+
["All"] + list(TASKS.values()),
|
| 242 |
+
label="Tasks",
|
| 243 |
+
info="Evaluation tasks to be displayed",
|
| 244 |
+
value="All",
|
| 245 |
+
interactive=True,
|
| 246 |
+
)
|
| 247 |
subtask = gr.Radio(
|
| 248 |
+
SUBTASKS.get(details_task.value),
|
| 249 |
label="Subtasks",
|
| 250 |
info="Evaluation subtasks to be displayed (choose one of the Tasks above)",
|
| 251 |
)
|
|
|
|
| 256 |
details_dataframe_2 = gr.Dataframe(visible=False)
|
| 257 |
details_dataframe = gr.DataFrame(visible=False)
|
| 258 |
|
| 259 |
+
model_id_1.change(
|
| 260 |
+
fn=update_load_results_component,
|
| 261 |
+
outputs=load_results_btn,
|
| 262 |
+
)
|
| 263 |
+
load_results_btn.click(
|
| 264 |
fn=load_results_dataframe,
|
| 265 |
inputs=model_id_1,
|
| 266 |
outputs=dataframe_1,
|
| 267 |
).then(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
fn=load_results_dataframe,
|
| 269 |
inputs=model_id_2,
|
| 270 |
outputs=dataframe_2,
|
|
|
|
| 273 |
inputs=[dataframe_1, dataframe_2, task],
|
| 274 |
outputs=[results, configs],
|
| 275 |
).then(
|
| 276 |
+
fn=update_tasks_component,
|
| 277 |
inputs=task,
|
| 278 |
outputs=task,
|
| 279 |
)
|
|
|
|
| 281 |
fn=display_results,
|
| 282 |
inputs=[dataframe_1, dataframe_2, task],
|
| 283 |
outputs=[results, configs],
|
|
|
|
|
|
|
|
|
|
|
|
|
| 284 |
)
|
| 285 |
|
| 286 |
+
details_task.change(
|
| 287 |
+
fn=update_subtasks_component,
|
| 288 |
+
inputs=details_task,
|
| 289 |
+
outputs=subtask,
|
| 290 |
+
)
|
| 291 |
load_details_btn.click(
|
| 292 |
fn=load_details_dataframe,
|
| 293 |
inputs=[model_id_1, subtask],
|