Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,9 +9,9 @@ RESULT_DIR = os.environ.get("MOECAP_RESULT_DIR")
|
|
| 9 |
if not RESULT_DIR:
|
| 10 |
# For testing purposes, you can uncomment the line below:
|
| 11 |
# RESULT_DIR = "generic_result_dir"
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
|
| 16 |
import gradio as gr
|
| 17 |
import pandas as pd
|
|
@@ -214,7 +214,7 @@ def json_to_row(path: str, metrics: dict) -> dict:
|
|
| 214 |
"Model type": model_type,
|
| 215 |
"Precision": precision,
|
| 216 |
"E2E(s)": f2(e2e_s),
|
| 217 |
-
"GPU": gpu_type,
|
| 218 |
"Accuracy(%)": pct(acc),
|
| 219 |
"Cost($)": cost,
|
| 220 |
"Decoding T/s": f2(metrics.get("decoding_throughput")),
|
|
@@ -231,12 +231,16 @@ def json_to_row(path: str, metrics: dict) -> dict:
|
|
| 231 |
|
| 232 |
|
| 233 |
def load_from_dir(dir_path: str, selected_tasks=None, selected_frameworks=None, selected_model_types=None, selected_precisions=None, search_keyword="", force_refresh=False):
|
|
|
|
|
|
|
|
|
|
| 234 |
try:
|
| 235 |
pattern = f"hf://datasets/{dir_path}/**/*.json"
|
| 236 |
dl_mode = "force_redownload" if force_refresh else None
|
| 237 |
print(f"Fetching from {pattern} (mode={dl_mode})...")
|
| 238 |
ds = load_dataset("json", data_files={"train": pattern}, split="train", download_mode=dl_mode)
|
| 239 |
-
except Exception:
|
|
|
|
| 240 |
return "<p style='color:black'>No files loaded or Dataset not found.</p>", []
|
| 241 |
|
| 242 |
rows = []
|
|
@@ -249,6 +253,10 @@ def load_from_dir(dir_path: str, selected_tasks=None, selected_frameworks=None,
|
|
| 249 |
|
| 250 |
df = pd.DataFrame(rows)
|
| 251 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
if selected_tasks:
|
| 253 |
df = df[df["Dataset"].astype(str).str.lower().isin([x.lower() for x in selected_tasks])]
|
| 254 |
if selected_frameworks:
|
|
@@ -316,7 +324,6 @@ def build_app() -> gr.Blocks:
|
|
| 316 |
}
|
| 317 |
|
| 318 |
/* 3. SPECIFIC FIX FOR THE DARK "FILTERS" and "RADAR" SECTIONS */
|
| 319 |
-
/* This targets the class you added in python: elem_classes="filter-section" */
|
| 320 |
.filter-section {
|
| 321 |
background-color: #ffffff !important;
|
| 322 |
border: 2px solid #e1e4e8 !important;
|
|
@@ -325,7 +332,6 @@ def build_app() -> gr.Blocks:
|
|
| 325 |
box-shadow: 0 2px 4px rgba(0,0,0,0.05) !important;
|
| 326 |
}
|
| 327 |
|
| 328 |
-
/* Ensure NO child elements inside filter-section have dark backgrounds */
|
| 329 |
.filter-section * {
|
| 330 |
background-color: transparent !important;
|
| 331 |
color: #24292e !important;
|
|
@@ -340,11 +346,21 @@ def build_app() -> gr.Blocks:
|
|
| 340 |
color: #24292e !important;
|
| 341 |
}
|
| 342 |
|
| 343 |
-
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
| 344 |
.filter-section input[type="checkbox"] {
|
| 345 |
-
background-color: #ffffff !important;
|
| 346 |
border: 1px solid #d1d5da !important;
|
| 347 |
accent-color: #0366d6 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 348 |
}
|
| 349 |
|
| 350 |
/* Fix "How to use" Text (Markdown/Prose) */
|
|
|
|
| 9 |
if not RESULT_DIR:
|
| 10 |
# For testing purposes, you can uncomment the line below:
|
| 11 |
# RESULT_DIR = "generic_result_dir"
|
| 12 |
+
# If you are running locally without this env var,
|
| 13 |
+
# ensure you handle this error or set the var.
|
| 14 |
+
pass
|
| 15 |
|
| 16 |
import gradio as gr
|
| 17 |
import pandas as pd
|
|
|
|
| 214 |
"Model type": model_type,
|
| 215 |
"Precision": precision,
|
| 216 |
"E2E(s)": f2(e2e_s),
|
| 217 |
+
"GPU": gpu_type,
|
| 218 |
"Accuracy(%)": pct(acc),
|
| 219 |
"Cost($)": cost,
|
| 220 |
"Decoding T/s": f2(metrics.get("decoding_throughput")),
|
|
|
|
| 231 |
|
| 232 |
|
| 233 |
def load_from_dir(dir_path: str, selected_tasks=None, selected_frameworks=None, selected_model_types=None, selected_precisions=None, search_keyword="", force_refresh=False):
|
| 234 |
+
if not dir_path:
|
| 235 |
+
return "<p style='color:black'>Result Directory not set.</p>", []
|
| 236 |
+
|
| 237 |
try:
|
| 238 |
pattern = f"hf://datasets/{dir_path}/**/*.json"
|
| 239 |
dl_mode = "force_redownload" if force_refresh else None
|
| 240 |
print(f"Fetching from {pattern} (mode={dl_mode})...")
|
| 241 |
ds = load_dataset("json", data_files={"train": pattern}, split="train", download_mode=dl_mode)
|
| 242 |
+
except Exception as e:
|
| 243 |
+
print(f"Error loading dataset: {e}")
|
| 244 |
return "<p style='color:black'>No files loaded or Dataset not found.</p>", []
|
| 245 |
|
| 246 |
rows = []
|
|
|
|
| 253 |
|
| 254 |
df = pd.DataFrame(rows)
|
| 255 |
|
| 256 |
+
# --- Filtering Logic ---
|
| 257 |
+
# This logic is consistent: if a filter is provided, we ONLY keep rows
|
| 258 |
+
# where the column value is inside the selected list.
|
| 259 |
+
|
| 260 |
if selected_tasks:
|
| 261 |
df = df[df["Dataset"].astype(str).str.lower().isin([x.lower() for x in selected_tasks])]
|
| 262 |
if selected_frameworks:
|
|
|
|
| 324 |
}
|
| 325 |
|
| 326 |
/* 3. SPECIFIC FIX FOR THE DARK "FILTERS" and "RADAR" SECTIONS */
|
|
|
|
| 327 |
.filter-section {
|
| 328 |
background-color: #ffffff !important;
|
| 329 |
border: 2px solid #e1e4e8 !important;
|
|
|
|
| 332 |
box-shadow: 0 2px 4px rgba(0,0,0,0.05) !important;
|
| 333 |
}
|
| 334 |
|
|
|
|
| 335 |
.filter-section * {
|
| 336 |
background-color: transparent !important;
|
| 337 |
color: #24292e !important;
|
|
|
|
| 346 |
color: #24292e !important;
|
| 347 |
}
|
| 348 |
|
| 349 |
+
/* --- FIX FOR CHECKBOXES --- */
|
| 350 |
+
/* Problem was here: `background-color: #ffffff !important` prevented
|
| 351 |
+
the browser from painting the blue checked state.
|
| 352 |
+
We removed background-color !important and rely on accent-color.
|
| 353 |
+
*/
|
| 354 |
.filter-section input[type="checkbox"] {
|
|
|
|
| 355 |
border: 1px solid #d1d5da !important;
|
| 356 |
accent-color: #0366d6 !important;
|
| 357 |
+
/* Do NOT force background-color to white with !important here,
|
| 358 |
+
or the checkmark will be invisible */
|
| 359 |
+
}
|
| 360 |
+
|
| 361 |
+
/* Ensure label text next to checkbox is visible */
|
| 362 |
+
.filter-section label span {
|
| 363 |
+
color: #24292e !important;
|
| 364 |
}
|
| 365 |
|
| 366 |
/* Fix "How to use" Text (Markdown/Prose) */
|