Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Use color map for Results metrics values
Browse files- src/results.py +13 -9
src/results.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import asyncio
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
-
import numpy as np
|
| 5 |
import pandas as pd
|
| 6 |
from huggingface_hub import HfFileSystem
|
| 7 |
|
|
@@ -67,6 +66,7 @@ def display_tab(tab, df, task, hide_errors=True, show_only_differences=False):
|
|
| 67 |
if show_only_differences:
|
| 68 |
any_difference = df.ne(df.iloc[:, 0], axis=0).any(axis=1)
|
| 69 |
df = df.style.format(escape="html", na_rep="")
|
|
|
|
| 70 |
df.hide(
|
| 71 |
[
|
| 72 |
row
|
|
@@ -88,7 +88,18 @@ def display_tab(tab, df, task, hide_errors=True, show_only_differences=False):
|
|
| 88 |
],
|
| 89 |
axis="index",
|
| 90 |
)
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
start = len(f"{tab}.leaderboard_") if task == "All" else len(f"{tab}.{task} ")
|
| 93 |
df.format_index(lambda idx: idx[start:].removesuffix(",none"), axis="index")
|
| 94 |
return df.to_html()
|
|
@@ -127,12 +138,5 @@ def clear_results():
|
|
| 127 |
)
|
| 128 |
|
| 129 |
|
| 130 |
-
def highlight_min_max(s):
|
| 131 |
-
if s.name.endswith("acc,none") or s.name.endswith("acc_norm,none") or s.name.endswith("exact_match,none"):
|
| 132 |
-
return np.where(s == np.nanmax(s.values), "background-color:green", "background-color:#D81B60")
|
| 133 |
-
else:
|
| 134 |
-
return [""] * len(s)
|
| 135 |
-
|
| 136 |
-
|
| 137 |
def display_loading_message_for_results():
|
| 138 |
return ("<h3 style='text-align: center;'>Loading...</h3>",) * 2
|
|
|
|
| 1 |
import asyncio
|
| 2 |
|
| 3 |
import gradio as gr
|
|
|
|
| 4 |
import pandas as pd
|
| 5 |
from huggingface_hub import HfFileSystem
|
| 6 |
|
|
|
|
| 66 |
if show_only_differences:
|
| 67 |
any_difference = df.ne(df.iloc[:, 0], axis=0).any(axis=1)
|
| 68 |
df = df.style.format(escape="html", na_rep="")
|
| 69 |
+
# Hide rows
|
| 70 |
df.hide(
|
| 71 |
[
|
| 72 |
row
|
|
|
|
| 88 |
],
|
| 89 |
axis="index",
|
| 90 |
)
|
| 91 |
+
# Color metric result cells
|
| 92 |
+
idx = pd.IndexSlice
|
| 93 |
+
colored_rows = idx[
|
| 94 |
+
[
|
| 95 |
+
row
|
| 96 |
+
for row in df.index
|
| 97 |
+
if row.endswith("acc,none") or row.endswith("acc_norm,none") or row.endswith("exact_match,none")
|
| 98 |
+
]
|
| 99 |
+
] # Apply only on numeric cells, otherwise the background gradient will not work
|
| 100 |
+
subset = idx[colored_rows, idx[:]]
|
| 101 |
+
df.background_gradient(cmap="Greens", vmin=0, vmax=1, subset=subset, axis=None)
|
| 102 |
+
# Format index values: remove prefix and suffix
|
| 103 |
start = len(f"{tab}.leaderboard_") if task == "All" else len(f"{tab}.{task} ")
|
| 104 |
df.format_index(lambda idx: idx[start:].removesuffix(",none"), axis="index")
|
| 105 |
return df.to_html()
|
|
|
|
| 138 |
)
|
| 139 |
|
| 140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
def display_loading_message_for_results():
|
| 142 |
return ("<h3 style='text-align: center;'>Loading...</h3>",) * 2
|