Spaces:
Sleeping
Sleeping
Peiran
commited on
Commit
·
9f6abf4
1
Parent(s):
9c94332
Validation: skip pairs with missing image paths; docs: add Updates section describing pairing/scheduling, storage, fairness, and config (AGENTS.md updated but intentionally ignored)
Browse files
app.py
CHANGED
|
@@ -46,6 +46,12 @@ def _resolve_image_path(path: str) -> str:
|
|
| 46 |
return path if os.path.isabs(path) else os.path.join(BASE_DIR, path)
|
| 47 |
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
def _load_task_rows(task_name: str) -> List[Dict[str, str]]:
|
| 50 |
csv_path = _csv_path_for_task(task_name, "results.csv")
|
| 51 |
if not os.path.exists(csv_path):
|
|
@@ -70,15 +76,31 @@ def _build_image_pairs(rows: List[Dict[str, str]], task_name: str) -> List[Dict[
|
|
| 70 |
if model_a["model_name"] == model_b["model_name"]:
|
| 71 |
continue
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
pair = {
|
| 74 |
"test_id": test_id,
|
| 75 |
-
"org_img":
|
| 76 |
"model1_name": model_a["model_name"],
|
| 77 |
"model1_res": model_a["res"],
|
| 78 |
-
"model1_path":
|
| 79 |
"model2_name": model_b["model_name"],
|
| 80 |
"model2_res": model_b["res"],
|
| 81 |
-
"model2_path":
|
| 82 |
}
|
| 83 |
pairs.append(pair)
|
| 84 |
|
|
|
|
| 46 |
return path if os.path.isabs(path) else os.path.join(BASE_DIR, path)
|
| 47 |
|
| 48 |
|
| 49 |
+
def _file_exists_under_base(rel_or_abs_path: str) -> bool:
|
| 50 |
+
"""Check if file exists, resolving relative paths under BASE_DIR."""
|
| 51 |
+
check_path = rel_or_abs_path if os.path.isabs(rel_or_abs_path) else os.path.join(BASE_DIR, rel_or_abs_path)
|
| 52 |
+
return os.path.exists(check_path)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
def _load_task_rows(task_name: str) -> List[Dict[str, str]]:
|
| 56 |
csv_path = _csv_path_for_task(task_name, "results.csv")
|
| 57 |
if not os.path.exists(csv_path):
|
|
|
|
| 76 |
if model_a["model_name"] == model_b["model_name"]:
|
| 77 |
continue
|
| 78 |
|
| 79 |
+
org_path = os.path.join(folder, org_img)
|
| 80 |
+
path_a = os.path.join(folder, model_a["path"])
|
| 81 |
+
path_b = os.path.join(folder, model_b["path"])
|
| 82 |
+
|
| 83 |
+
# Validate existence to avoid UI errors
|
| 84 |
+
if not (_file_exists_under_base(org_path) and _file_exists_under_base(path_a) and _file_exists_under_base(path_b)):
|
| 85 |
+
try:
|
| 86 |
+
print("[VisArena] Skipping invalid paths for test_id=", test_id, {
|
| 87 |
+
"org": org_path,
|
| 88 |
+
"a": path_a,
|
| 89 |
+
"b": path_b,
|
| 90 |
+
})
|
| 91 |
+
except Exception:
|
| 92 |
+
pass
|
| 93 |
+
continue
|
| 94 |
+
|
| 95 |
pair = {
|
| 96 |
"test_id": test_id,
|
| 97 |
+
"org_img": org_path,
|
| 98 |
"model1_name": model_a["model_name"],
|
| 99 |
"model1_res": model_a["res"],
|
| 100 |
+
"model1_path": path_a,
|
| 101 |
"model2_name": model_b["model_name"],
|
| 102 |
"model2_res": model_b["res"],
|
| 103 |
+
"model2_path": path_b,
|
| 104 |
}
|
| 105 |
pairs.append(pair)
|
| 106 |
|