Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Make display_details robust
Browse files
app.py
CHANGED
|
@@ -206,11 +206,12 @@ def load_details_dataframes(subtask, *model_ids):
|
|
| 206 |
return [load_details_dataframe(model_id, subtask) for model_id in model_ids]
|
| 207 |
|
| 208 |
|
| 209 |
-
def display_details(
|
| 210 |
-
|
| 211 |
-
|
|
|
|
| 212 |
# Pop model_name and add it to the column name
|
| 213 |
-
df = pd.concat([
|
| 214 |
return (
|
| 215 |
df.style
|
| 216 |
.format(na_rep="")
|
|
@@ -309,12 +310,12 @@ with gr.Blocks(fill_height=True) as demo:
|
|
| 309 |
outputs=[details_dataframe_1, details_dataframe_2],
|
| 310 |
).then(
|
| 311 |
fn=display_details,
|
| 312 |
-
inputs=[details_dataframe_1, details_dataframe_2
|
| 313 |
outputs=details,
|
| 314 |
)
|
| 315 |
sample_idx.change(
|
| 316 |
fn=display_details,
|
| 317 |
-
inputs=[details_dataframe_1, details_dataframe_2
|
| 318 |
outputs=details,
|
| 319 |
)
|
| 320 |
|
|
|
|
| 206 |
return [load_details_dataframe(model_id, subtask) for model_id in model_ids]
|
| 207 |
|
| 208 |
|
| 209 |
+
def display_details(sample_idx, *dfs):
|
| 210 |
+
rows = [df.iloc[sample_idx] for df in dfs if "model_name" in df.columns and sample_idx < len(df)]
|
| 211 |
+
if not rows:
|
| 212 |
+
return
|
| 213 |
# Pop model_name and add it to the column name
|
| 214 |
+
df = pd.concat([row.rename(row.pop("model_name")) for row in rows], axis="columns")
|
| 215 |
return (
|
| 216 |
df.style
|
| 217 |
.format(na_rep="")
|
|
|
|
| 310 |
outputs=[details_dataframe_1, details_dataframe_2],
|
| 311 |
).then(
|
| 312 |
fn=display_details,
|
| 313 |
+
inputs=[sample_idx, details_dataframe_1, details_dataframe_2],
|
| 314 |
outputs=details,
|
| 315 |
)
|
| 316 |
sample_idx.change(
|
| 317 |
fn=display_details,
|
| 318 |
+
inputs=[sample_idx, details_dataframe_1, details_dataframe_2],
|
| 319 |
outputs=details,
|
| 320 |
)
|
| 321 |
|