"""Inspect the 3 user-flagged issues + all motionless queries.""" import json from pathlib import Path import numpy as np from PIL import Image ROOT = Path(__file__).resolve().parents[1] gt = json.loads((ROOT / "scripts/new_predictions_ground_truth_all_queries_with_paths.json").read_text(encoding="utf-8")) qs = json.loads((ROOT / "evaluation/R4D-Bench_queries.json").read_text(encoding="utf-8")) def show(qid: str): it = next(x for x in gt if x["query_id"] == qid) g = it["ground_truth"] exist = set(g.get("existence_frames") or []) allf = [fr["frame_id"] for fr in g["frames"]] black = [f for f in allf if f not in exist] print(f"==== {qid}") print(" text_en:", it.get("text_en")) print(" targets:", g["target_tracks"]) print(" n_frames", len(allf), "pos", len(exist), "black", black, "excl", len(g.get("excluded_frames") or [])) print(" gating:", g.get("temporal_gating")) # PNG nonzero for black-listed frames for fr in g["frames"]: fid = fr["frame_id"] rel = fr.get("combined_mask_image") if not rel: continue arr = np.array(Image.open(ROOT / rel)) nz = int((arr > 127).sum()) if fid not in exist and nz > 0: print(" BUG black-frame has white", fid, nz) if fid in exist and nz == 0: print(" BUG pos-frame all black", fid) for qid in [ "flame_salmon_q1", "flame_salmon_q4", "cook-spinach_q1", "cut_roasted_beef_q1", ]: show(qid) print("\n==== motionless / never-move queries ====") keys = ( "never move", "motionless", "stationary", "completely still", "do not change position", "完全静止", "从未移动", "始终保持静止", "不改变位置", "physically motionless", "physically stationary", ) for q in qs: blob = f"{q.get('text_en','')} {q.get('text_zh','')}".lower() if any(k.lower() in blob for k in keys): it = next(x for x in gt if x["query_id"] == q["query_id"]) print(q["query_id"], it["ground_truth"]["target_tracks"], "|", q["text_en"][:80])