r4d-bench-qa / scripts /_dump_abc_checklist.py
LiYacheng's picture
Fill unannotated_visible gaps: every query/frame has GT masks (part 24)
aa7e82c verified
Raw History Blame Contribute Delete
1.66 kB
"""Dump A/B/C checklist for final human confirmation."""
from __future__ import annotations
import json
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT))
from scripts.predictions_ground_truth import SCENES_CONFIG
OUT = ROOT / "assets" / "gt_audit" / "final_id_lockdown" / "ABC_CHECKLIST.md"
lines = ["# A / B / C target checklist (IDs locked)\n"]
counts = {"A": 0, "B": 0, "C": 0}
for cfg in SCENES_CONFIG:
scene = ROOT / "data" / "scenes" / cfg["folder"]
tracks = {
t["track_id"]: t
for t in json.loads((scene / cfg["track_file"]).read_text(encoding="utf-8"))["tracks"]
}
qs = json.loads((scene / cfg["query_file"]).read_text(encoding="utf-8"))
if isinstance(qs, dict):
qs = qs["queries"]
lines.append(f"\n## {cfg['folder']}\n")
for q in qs:
qt = q.get("query_type")
counts[qt] = counts.get(qt, 0) + 1
tids = q.get("target_track_ids") or []
cats = [tracks[t]["category"] for t in tids if t in tracks]
kind = { "A": "单目标", "B": "多目标", "C": "零目标" }.get(qt, qt)
lines.append(
f"- **{q['query_id']}** [{kind}/{qt}] n={len(tids)}\n"
f" - EN: {q.get('text_en')}\n"
f" - ZH: {q.get('text_zh')}\n"
f" - IDs: `{tids}`\n"
f" - Cats: {cats}\n"
)
lines.insert(1, f"\nTotals: A(单)={counts.get('A')} B(多)={counts.get('B')} C(零)={counts.get('C')} sum={sum(counts.values())}\n")
OUT.write_text("\n".join(lines), encoding="utf-8")
print(f"Wrote {OUT} counts={counts}")