Spaces:
Running
Running
Deploy Space: update src
Browse files- src/display/css_html_js.py +76 -5
- src/utils.py +38 -14
src/display/css_html_js.py
CHANGED
|
@@ -1,8 +1,74 @@
|
|
| 1 |
# Gradio custom styles for the TSFM Realworld Bench leaderboard.
|
| 2 |
custom_css = """
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
#leaderboard-table { margin-top: 15px; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
.domain-heading {
|
| 7 |
margin-top: 1.75rem;
|
| 8 |
margin-bottom: 0.5rem;
|
|
@@ -12,14 +78,19 @@ custom_css = """
|
|
| 12 |
.dataset-heading {
|
| 13 |
margin-top: 2rem;
|
| 14 |
margin-bottom: 0.75rem;
|
| 15 |
-
font-size: 1.
|
| 16 |
font-weight: 700 !important;
|
| 17 |
line-height: 1.35;
|
| 18 |
-
color:
|
| 19 |
}
|
| 20 |
.dataset-heading p {
|
| 21 |
-
font-size: 1.
|
| 22 |
font-weight: 700 !important;
|
| 23 |
margin: 0;
|
| 24 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
"""
|
|
|
|
| 1 |
# Gradio custom styles for the TSFM Realworld Bench leaderboard.
|
| 2 |
custom_css = """
|
| 3 |
+
:root {
|
| 4 |
+
--bench-ink: #18202f;
|
| 5 |
+
--bench-muted: #5b6575;
|
| 6 |
+
--bench-line: #d7dce5;
|
| 7 |
+
--bench-panel: #f8fafc;
|
| 8 |
+
--bench-blue: #2563eb;
|
| 9 |
+
--bench-teal: #0f766e;
|
| 10 |
+
}
|
| 11 |
+
.gradio-container {
|
| 12 |
+
max-width: 1320px !important;
|
| 13 |
+
margin: 0 auto !important;
|
| 14 |
+
}
|
| 15 |
+
.markdown-text {
|
| 16 |
+
font-size: 16px !important;
|
| 17 |
+
color: var(--bench-muted);
|
| 18 |
+
}
|
| 19 |
+
.tab-buttons button {
|
| 20 |
+
font-size: 16px !important;
|
| 21 |
+
font-weight: 650 !important;
|
| 22 |
+
border-radius: 6px 6px 0 0 !important;
|
| 23 |
+
}
|
| 24 |
#leaderboard-table { margin-top: 15px; }
|
| 25 |
+
.summary-grid {
|
| 26 |
+
display: grid;
|
| 27 |
+
grid-template-columns: repeat(4, minmax(0, 1fr));
|
| 28 |
+
gap: 12px;
|
| 29 |
+
margin: 18px 0 22px;
|
| 30 |
+
}
|
| 31 |
+
.summary-card {
|
| 32 |
+
border: 1px solid var(--bench-line);
|
| 33 |
+
border-radius: 8px;
|
| 34 |
+
background: linear-gradient(180deg, #ffffff 0%, var(--bench-panel) 100%);
|
| 35 |
+
padding: 14px 16px;
|
| 36 |
+
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
|
| 37 |
+
}
|
| 38 |
+
.summary-value {
|
| 39 |
+
color: var(--bench-ink);
|
| 40 |
+
font-size: 28px;
|
| 41 |
+
line-height: 1.1;
|
| 42 |
+
font-weight: 780;
|
| 43 |
+
}
|
| 44 |
+
.summary-value.small {
|
| 45 |
+
font-size: 18px;
|
| 46 |
+
line-height: 1.35;
|
| 47 |
+
}
|
| 48 |
+
.summary-label {
|
| 49 |
+
margin-top: 5px;
|
| 50 |
+
color: var(--bench-muted);
|
| 51 |
+
font-size: 12px;
|
| 52 |
+
text-transform: uppercase;
|
| 53 |
+
letter-spacing: 0.04em;
|
| 54 |
+
font-weight: 700;
|
| 55 |
+
}
|
| 56 |
+
.dataframe {
|
| 57 |
+
border-radius: 8px !important;
|
| 58 |
+
overflow: hidden !important;
|
| 59 |
+
border: 1px solid var(--bench-line) !important;
|
| 60 |
+
}
|
| 61 |
+
.dataframe table {
|
| 62 |
+
font-size: 14px !important;
|
| 63 |
+
}
|
| 64 |
+
.dataframe th {
|
| 65 |
+
background: #eef2f7 !important;
|
| 66 |
+
color: var(--bench-ink) !important;
|
| 67 |
+
font-weight: 750 !important;
|
| 68 |
+
}
|
| 69 |
+
.dataframe td {
|
| 70 |
+
color: #263244 !important;
|
| 71 |
+
}
|
| 72 |
.domain-heading {
|
| 73 |
margin-top: 1.75rem;
|
| 74 |
margin-bottom: 0.5rem;
|
|
|
|
| 78 |
.dataset-heading {
|
| 79 |
margin-top: 2rem;
|
| 80 |
margin-bottom: 0.75rem;
|
| 81 |
+
font-size: 1.25rem !important;
|
| 82 |
font-weight: 700 !important;
|
| 83 |
line-height: 1.35;
|
| 84 |
+
color: var(--bench-ink);
|
| 85 |
}
|
| 86 |
.dataset-heading p {
|
| 87 |
+
font-size: 1.25rem !important;
|
| 88 |
font-weight: 700 !important;
|
| 89 |
margin: 0;
|
| 90 |
}
|
| 91 |
+
@media (max-width: 820px) {
|
| 92 |
+
.summary-grid {
|
| 93 |
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
"""
|
src/utils.py
CHANGED
|
@@ -10,6 +10,8 @@ import numpy as np
|
|
| 10 |
import pandas as pd
|
| 11 |
from scipy import stats
|
| 12 |
|
|
|
|
|
|
|
| 13 |
METRIC_COLUMNS = [
|
| 14 |
"eval_metrics/MSE[mean]",
|
| 15 |
"eval_metrics/MSE[0.5]",
|
|
@@ -123,16 +125,6 @@ def load_all_results(root_dir: str = "results") -> pd.DataFrame:
|
|
| 123 |
df = df.sort_values(by=["model", "dataset"]).reset_index(drop=True)
|
| 124 |
df["model"] = df["model"].replace(LEGACY_MODEL_NAMES)
|
| 125 |
|
| 126 |
-
ALLOWED_MODELS = {
|
| 127 |
-
"Toto-2.0-1B",
|
| 128 |
-
"Moirai-1.1-Large",
|
| 129 |
-
"Chronos-2",
|
| 130 |
-
"Timer-S1",
|
| 131 |
-
"TiRex",
|
| 132 |
-
"TimesFM-2.5"
|
| 133 |
-
}
|
| 134 |
-
df = df[df["model"].isin(ALLOWED_MODELS)]
|
| 135 |
-
|
| 136 |
parts = df["dataset"].astype(str).str.split("/", expand=True)
|
| 137 |
if parts.shape[1] < 3:
|
| 138 |
for idx in range(parts.shape[1], 3):
|
|
@@ -364,6 +356,40 @@ def group_datasets_by_domain(
|
|
| 364 |
return ordered
|
| 365 |
|
| 366 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 367 |
def dataset_tab_label(dataset: str, root_dir: str = "results") -> str:
|
| 368 |
raw_domain = lookup_dataset_domain(dataset, root_dir)
|
| 369 |
domain = display_domain(raw_domain)
|
|
@@ -638,10 +664,9 @@ def _today_start_utc8() -> datetime:
|
|
| 638 |
|
| 639 |
def get_dataset_last_eval_time(ds_base: str, root_dir: str = "results") -> datetime | None:
|
| 640 |
latest_dt: datetime | None = None
|
| 641 |
-
ALLOWED_SLUGS = {"chronos_2", "moirai_1_1_large", "timer_s1", "timesfm_2_5", "tirex", "toto_2_0_1b"}
|
| 642 |
# Scan model directories
|
| 643 |
for model_dir in Path(root_dir).iterdir():
|
| 644 |
-
if not model_dir.is_dir()
|
| 645 |
continue
|
| 646 |
forecasts_dir = model_dir / "forecasts"
|
| 647 |
if not forecasts_dir.is_dir():
|
|
@@ -716,9 +741,8 @@ def make_domain_pie_chart(root_dir: str = "results") -> object | None:
|
|
| 716 |
# Fallback to cumulative snapshots count (no today filter) if empty
|
| 717 |
if not timestamp_counts:
|
| 718 |
seen_datasets: set[str] = set()
|
| 719 |
-
ALLOWED_SLUGS = {"chronos_2", "moirai_1_1_large", "timer_s1", "timesfm_2_5", "tirex", "toto_2_0_1b"}
|
| 720 |
for model_dir in sorted(Path(root_dir).iterdir()):
|
| 721 |
-
if not model_dir.is_dir()
|
| 722 |
continue
|
| 723 |
forecasts_dir = model_dir / "forecasts"
|
| 724 |
if not forecasts_dir.is_dir():
|
|
|
|
| 10 |
import pandas as pd
|
| 11 |
from scipy import stats
|
| 12 |
|
| 13 |
+
from src.display.formatting import format_timestamp_utc8
|
| 14 |
+
|
| 15 |
METRIC_COLUMNS = [
|
| 16 |
"eval_metrics/MSE[mean]",
|
| 17 |
"eval_metrics/MSE[0.5]",
|
|
|
|
| 125 |
df = df.sort_values(by=["model", "dataset"]).reset_index(drop=True)
|
| 126 |
df["model"] = df["model"].replace(LEGACY_MODEL_NAMES)
|
| 127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
parts = df["dataset"].astype(str).str.split("/", expand=True)
|
| 129 |
if parts.shape[1] < 3:
|
| 130 |
for idx in range(parts.shape[1], 3):
|
|
|
|
| 356 |
return ordered
|
| 357 |
|
| 358 |
|
| 359 |
+
def build_leaderboard_summary_html(root_dir: str = "results") -> str:
|
| 360 |
+
df = prepare_results_df(root_dir)
|
| 361 |
+
if df.empty:
|
| 362 |
+
return """
|
| 363 |
+
<div class="summary-grid">
|
| 364 |
+
<div class="summary-card"><div class="summary-value">0</div><div class="summary-label">Models</div></div>
|
| 365 |
+
<div class="summary-card"><div class="summary-value">0</div><div class="summary-label">Datasets</div></div>
|
| 366 |
+
<div class="summary-card"><div class="summary-value">0</div><div class="summary-label">Domains</div></div>
|
| 367 |
+
<div class="summary-card"><div class="summary-value">n/a</div><div class="summary-label">Last Refresh</div></div>
|
| 368 |
+
</div>
|
| 369 |
+
"""
|
| 370 |
+
|
| 371 |
+
models = df["model"].nunique()
|
| 372 |
+
datasets = df["dataset"].nunique()
|
| 373 |
+
domains = df["domain"].nunique() if "domain" in df.columns else 0
|
| 374 |
+
last_refresh = "n/a"
|
| 375 |
+
status_path = Path(root_dir) / "online_status.json"
|
| 376 |
+
if status_path.exists():
|
| 377 |
+
try:
|
| 378 |
+
status = json.loads(status_path.read_text())
|
| 379 |
+
last_refresh = format_timestamp_utc8(status.get("finished_at", ""))
|
| 380 |
+
except Exception:
|
| 381 |
+
pass
|
| 382 |
+
|
| 383 |
+
return f"""
|
| 384 |
+
<div class="summary-grid">
|
| 385 |
+
<div class="summary-card"><div class="summary-value">{models}</div><div class="summary-label">Models</div></div>
|
| 386 |
+
<div class="summary-card"><div class="summary-value">{datasets}</div><div class="summary-label">Datasets</div></div>
|
| 387 |
+
<div class="summary-card"><div class="summary-value">{domains}</div><div class="summary-label">Domains</div></div>
|
| 388 |
+
<div class="summary-card wide"><div class="summary-value small">{last_refresh}</div><div class="summary-label">Last Refresh</div></div>
|
| 389 |
+
</div>
|
| 390 |
+
"""
|
| 391 |
+
|
| 392 |
+
|
| 393 |
def dataset_tab_label(dataset: str, root_dir: str = "results") -> str:
|
| 394 |
raw_domain = lookup_dataset_domain(dataset, root_dir)
|
| 395 |
domain = display_domain(raw_domain)
|
|
|
|
| 664 |
|
| 665 |
def get_dataset_last_eval_time(ds_base: str, root_dir: str = "results") -> datetime | None:
|
| 666 |
latest_dt: datetime | None = None
|
|
|
|
| 667 |
# Scan model directories
|
| 668 |
for model_dir in Path(root_dir).iterdir():
|
| 669 |
+
if not model_dir.is_dir():
|
| 670 |
continue
|
| 671 |
forecasts_dir = model_dir / "forecasts"
|
| 672 |
if not forecasts_dir.is_dir():
|
|
|
|
| 741 |
# Fallback to cumulative snapshots count (no today filter) if empty
|
| 742 |
if not timestamp_counts:
|
| 743 |
seen_datasets: set[str] = set()
|
|
|
|
| 744 |
for model_dir in sorted(Path(root_dir).iterdir()):
|
| 745 |
+
if not model_dir.is_dir():
|
| 746 |
continue
|
| 747 |
forecasts_dir = model_dir / "forecasts"
|
| 748 |
if not forecasts_dir.is_dir():
|