Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -105,13 +105,11 @@ def update_metrics(selected_benchmarks):
|
|
105 |
|
106 |
|
107 |
def update_leaderboard(selected_methods, selected_metrics):
|
108 |
-
# 1) get the df
|
109 |
df = get_baseline_df(selected_methods, selected_metrics)
|
110 |
-
# 2) round floats
|
111 |
df = df.applymap(lambda x: round(x, 4) if isinstance(x, (int, float)) else x)
|
112 |
-
# 3) apply your colour‐styling to the Method column
|
113 |
styled = df.style.applymap(style_methods, subset=["Method"])
|
114 |
-
|
|
|
115 |
|
116 |
def style_methods(val):
|
117 |
"""Given a model name, return a CSS style string."""
|
@@ -227,14 +225,15 @@ with block:
|
|
227 |
baseline_header = ["Method"] + metric_names
|
228 |
baseline_datatype = ['markdown'] + ['number'] * len(metric_names)
|
229 |
|
230 |
-
|
231 |
-
style_methods,
|
232 |
-
|
|
|
233 |
)
|
234 |
|
235 |
with gr.Row(show_progress=True, variant='panel'):
|
236 |
data_component = gr.Dataframe(
|
237 |
-
value=
|
238 |
headers=baseline_header,
|
239 |
type="pandas",
|
240 |
datatype=baseline_datatype,
|
|
|
105 |
|
106 |
|
107 |
def update_leaderboard(selected_methods, selected_metrics):
|
|
|
108 |
df = get_baseline_df(selected_methods, selected_metrics)
|
|
|
109 |
df = df.applymap(lambda x: round(x, 4) if isinstance(x, (int, float)) else x)
|
|
|
110 |
styled = df.style.applymap(style_methods, subset=["Method"])
|
111 |
+
html = styled.set_table_attributes('class="dataframe"').render()
|
112 |
+
return html
|
113 |
|
114 |
def style_methods(val):
|
115 |
"""Given a model name, return a CSS style string."""
|
|
|
225 |
baseline_header = ["Method"] + metric_names
|
226 |
baseline_datatype = ['markdown'] + ['number'] * len(metric_names)
|
227 |
|
228 |
+
initial_html = baseline_value.style\
|
229 |
+
.applymap(style_methods, subset=["Method"])\
|
230 |
+
.set_table_attributes('class="dataframe"')\
|
231 |
+
.render()
|
232 |
)
|
233 |
|
234 |
with gr.Row(show_progress=True, variant='panel'):
|
235 |
data_component = gr.Dataframe(
|
236 |
+
value=initial_html,
|
237 |
headers=baseline_header,
|
238 |
type="pandas",
|
239 |
datatype=baseline_datatype,
|