Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -107,15 +107,15 @@ def update_metrics(selected_benchmarks):
|
|
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 |
-
|
111 |
-
|
112 |
-
return html
|
113 |
|
114 |
-
def style_methods(val):
|
115 |
-
"""Given a model name, return a CSS style string."""
|
116 |
-
c = color_dict.get(val, "black")
|
117 |
-
return f"color: {c}"
|
118 |
|
|
|
|
|
|
|
|
|
|
|
119 |
# ------- Visualisation helpers ---------------------------------------------
|
120 |
|
121 |
|
@@ -222,6 +222,7 @@ with block:
|
|
222 |
|
223 |
baseline_value = get_baseline_df(method_names, metric_names)
|
224 |
baseline_value = baseline_value.applymap(lambda x: round(x, 4) if isinstance(x, (int, float)) else x)
|
|
|
225 |
baseline_header = ["Method"] + metric_names
|
226 |
baseline_datatype = ['markdown'] + ['number'] * len(metric_names)
|
227 |
|
@@ -233,7 +234,7 @@ with block:
|
|
233 |
|
234 |
with gr.Row(show_progress=True, variant='panel'):
|
235 |
data_component = gr.Dataframe(
|
236 |
-
value=
|
237 |
headers=baseline_header,
|
238 |
type="pandas",
|
239 |
datatype=baseline_datatype,
|
|
|
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 |
+
df['Method'] = df['Method'].apply(format_method)
|
111 |
+
return df
|
|
|
112 |
|
|
|
|
|
|
|
|
|
113 |
|
114 |
+
def format_method(name: str) -> str:
|
115 |
+
"""Wrap a model name in a coloured <span> so Gradio renders it."""
|
116 |
+
colour = color_dict.get(name, "black")
|
117 |
+
return f"<span style='color:{colour}; font-weight:bold;'>{name}</span>"
|
118 |
+
|
119 |
# ------- Visualisation helpers ---------------------------------------------
|
120 |
|
121 |
|
|
|
222 |
|
223 |
baseline_value = get_baseline_df(method_names, metric_names)
|
224 |
baseline_value = baseline_value.applymap(lambda x: round(x, 4) if isinstance(x, (int, float)) else x)
|
225 |
+
baseline_value['Method'] = baseline_value['Method'].apply(format_method)
|
226 |
baseline_header = ["Method"] + metric_names
|
227 |
baseline_datatype = ['markdown'] + ['number'] * len(metric_names)
|
228 |
|
|
|
234 |
|
235 |
with gr.Row(show_progress=True, variant='panel'):
|
236 |
data_component = gr.Dataframe(
|
237 |
+
value=baseline_value,
|
238 |
headers=baseline_header,
|
239 |
type="pandas",
|
240 |
datatype=baseline_datatype,
|