Spaces:
Sleeping
Sleeping
Commit
•
6cf57e4
1
Parent(s):
f12aa56
Add checkbox in Details to show only differences
Browse files- app.py +8 -2
- src/details.py +5 -1
app.py
CHANGED
@@ -105,6 +105,7 @@ with gr.Blocks(fill_height=True, fill_width=True) as demo:
|
|
105 |
sample_idx = gr.Number(
|
106 |
label="Sample Index", info="Index of the sample to be displayed", value=0, minimum=0, visible=False
|
107 |
)
|
|
|
108 |
details = gr.HTML()
|
109 |
details_dataframe_1 = gr.Dataframe(visible=False)
|
110 |
details_dataframe_2 = gr.Dataframe(visible=False)
|
@@ -197,9 +198,14 @@ with gr.Blocks(fill_height=True, fill_width=True) as demo:
|
|
197 |
outputs=sample_idx,
|
198 |
)
|
199 |
gr.on(
|
200 |
-
triggers=[
|
|
|
|
|
|
|
|
|
|
|
201 |
fn=display_details,
|
202 |
-
inputs=[sample_idx, details_dataframe_1, details_dataframe_2],
|
203 |
outputs=details,
|
204 |
)
|
205 |
clear_details_btn.click(
|
|
|
105 |
sample_idx = gr.Number(
|
106 |
label="Sample Index", info="Index of the sample to be displayed", value=0, minimum=0, visible=False
|
107 |
)
|
108 |
+
details_show_only_differences = gr.Checkbox(label="Show Only Differences", value=False, info="Options")
|
109 |
details = gr.HTML()
|
110 |
details_dataframe_1 = gr.Dataframe(visible=False)
|
111 |
details_dataframe_2 = gr.Dataframe(visible=False)
|
|
|
198 |
outputs=sample_idx,
|
199 |
)
|
200 |
gr.on(
|
201 |
+
triggers=[
|
202 |
+
details_dataframe_1.change,
|
203 |
+
details_dataframe_2.change,
|
204 |
+
sample_idx.change,
|
205 |
+
details_show_only_differences.change,
|
206 |
+
],
|
207 |
fn=display_details,
|
208 |
+
inputs=[sample_idx, details_show_only_differences, details_dataframe_1, details_dataframe_2],
|
209 |
outputs=details,
|
210 |
)
|
211 |
clear_details_btn.click(
|
src/details.py
CHANGED
@@ -66,7 +66,7 @@ async def load_details_dataframes(subtask, *model_ids):
|
|
66 |
return result
|
67 |
|
68 |
|
69 |
-
def display_details(sample_idx, *dfs):
|
70 |
rows = [df.iloc[sample_idx] for df in dfs if "model_name" in df.columns and sample_idx < len(df)]
|
71 |
if not rows:
|
72 |
return
|
@@ -82,10 +82,14 @@ def display_details(sample_idx, *dfs):
|
|
82 |
return row
|
83 |
|
84 |
df = df.apply(wrap, axis=1)
|
|
|
|
|
85 |
# Style
|
86 |
return (
|
87 |
df.style.format(escape="html", na_rep="")
|
88 |
# .hide(axis="index")
|
|
|
|
|
89 |
.to_html()
|
90 |
)
|
91 |
|
|
|
66 |
return result
|
67 |
|
68 |
|
69 |
+
def display_details(sample_idx, show_only_differences, *dfs):
|
70 |
rows = [df.iloc[sample_idx] for df in dfs if "model_name" in df.columns and sample_idx < len(df)]
|
71 |
if not rows:
|
72 |
return
|
|
|
82 |
return row
|
83 |
|
84 |
df = df.apply(wrap, axis=1)
|
85 |
+
if show_only_differences:
|
86 |
+
any_difference = df.ne(df.iloc[:, 0], axis=0).any(axis=1)
|
87 |
# Style
|
88 |
return (
|
89 |
df.style.format(escape="html", na_rep="")
|
90 |
# .hide(axis="index")
|
91 |
+
# Hide non-different rows
|
92 |
+
.hide([row for row in df.index if show_only_differences and not any_difference[row]])
|
93 |
.to_html()
|
94 |
)
|
95 |
|