| """Find videos where Gemini and Qwen3-Omni both failed across mute/swap/sync. |
| |
| Selection criteria (all must hold for a base video X.mp4): |
| 1. Gemini failed on swap version of X -> X in swap case_study_explicit.jsonl |
| 2. Gemini failed on muted version of X -> X in gemini mute jsonl with correct=false |
| 3. Qwen failed on muted version of X -> X in qwen mute jsonl with correct=false |
| 4. Qwen failed on swap version of X -> X in qwen swap jsonl with correct=false |
| 5. Qwen failed on >=1 sync intervention -> X_delay_*.mp4 / X_early_*.mp4 wrong |
| (gt_synced=False but pred_synced=True, |
| OR pred_direction != gt_direction) |
| """ |
|
|
| import json |
| import re |
| from pathlib import Path |
|
|
| GEMINI_SWAP_CASE = "/home/ubuntu/eval_results/gemini_mute_sync_swap/swap/swap_gemini_gemini-3.1-pro-preview__promptDirect/case_study_explicit.jsonl" |
| GEMINI_MUTE = "/home/ubuntu/eval_results/gemini_mute_sync_swap/mute/mute_gemini_gemini-3.1-pro-preview__promptDirect/eval_results.jsonl" |
| QWEN_MUTE = "/home/ubuntu/eval_results/mute/mute_qwen3omni_vanilla_promptDirect/eval_results.jsonl" |
| QWEN_SWAP = "/home/ubuntu/eval_results/swap/swap_Qwen_Qwen3-Omni-30B-A3B-Instruct_promptDirect/eval_results.jsonl" |
| QWEN_SYNC = "/home/ubuntu/eval_results/sync/sync_qwen3omni_vanilla/eval_results.jsonl" |
|
|
| |
| SYNC_SUFFIX_RE = re.compile(r"_(delay|early)_\d+(?:\.\d+)?s(?=\.mp4$)") |
|
|
|
|
| def base_of(video_name: str) -> str: |
| return SYNC_SUFFIX_RE.sub("", video_name) |
|
|
|
|
| def load_jsonl(path: str): |
| with open(path) as f: |
| for line in f: |
| line = line.strip() |
| if line: |
| yield json.loads(line) |
|
|
|
|
| def sync_is_wrong(row: dict) -> bool: |
| """Qwen sync correctness: pred must match gt_synced AND (when not synced) direction.""" |
| gt_synced = bool(row.get("gt_synced")) |
| pred_synced = bool(row.get("pred_synced")) |
| if gt_synced != pred_synced: |
| return True |
| if not gt_synced and row.get("pred_direction") != row.get("gt_direction"): |
| return True |
| return False |
|
|
|
|
| def main(): |
| |
| gemini_swap_wrong = {row["video"] for row in load_jsonl(GEMINI_SWAP_CASE)} |
|
|
| |
| gemini_mute_wrong = {r["video"] for r in load_jsonl(GEMINI_MUTE) if not r.get("correct", True)} |
| qwen_mute_wrong = {r["video"] for r in load_jsonl(QWEN_MUTE) if not r.get("correct", True)} |
| qwen_swap_wrong = {r["video"] for r in load_jsonl(QWEN_SWAP) if not r.get("correct", True)} |
|
|
| |
| qwen_sync_variants = {} |
| for r in load_jsonl(QWEN_SYNC): |
| v = r["video"] |
| base = base_of(v) |
| if v == base: |
| continue |
| if sync_is_wrong(r): |
| qwen_sync_variants.setdefault(base, []).append({ |
| "variant": v, |
| "gt": (r.get("gt_direction"), r.get("gt_offset_sec")), |
| "pred_synced": r.get("pred_synced"), |
| "pred": (r.get("pred_direction"), r.get("pred_offset_sec")), |
| }) |
| qwen_sync_intervention_wrong = set(qwen_sync_variants.keys()) |
|
|
| |
| candidates = ( |
| gemini_swap_wrong |
| & gemini_mute_wrong |
| & qwen_mute_wrong |
| & qwen_swap_wrong |
| & qwen_sync_intervention_wrong |
| ) |
|
|
| print(f"Per-source wrong sets:") |
| print(f" gemini swap (case_study) : {len(gemini_swap_wrong)}") |
| print(f" gemini mute (correct=false) : {len(gemini_mute_wrong)}") |
| print(f" qwen mute (correct=false) : {len(qwen_mute_wrong)}") |
| print(f" qwen swap (correct=false) : {len(qwen_swap_wrong)}") |
| print(f" qwen sync (>=1 wrong inter.): {len(qwen_sync_intervention_wrong)}") |
| print(f"\nFull intersection (5/5): {len(candidates)} videos") |
| print("=" * 60) |
|
|
| |
| gemini_swap_rows = {r["video"]: r for r in load_jsonl(GEMINI_SWAP_CASE)} |
| qwen_swap_rows = {r["video"]: r for r in load_jsonl(QWEN_SWAP) |
| if not r.get("correct", True)} |
|
|
| out_path = Path("/home/ubuntu/case_study_candidates.jsonl") |
| records = [] |
| for v in sorted(candidates): |
| gs = gemini_swap_rows.get(v, {}) |
| qs = qwen_swap_rows.get(v, {}) |
| rec = { |
| "video": v, |
| "gemini_swap_audio_from": gs.get("swapped_from"), |
| "qwen_swap_audio_from": qs.get("swapped_from"), |
| "qwen_sync_failures": qwen_sync_variants[v], |
| } |
| records.append(rec) |
| print(f"\nVIDEO: {v}") |
| print(f" swap audio source (gemini view) : {rec['gemini_swap_audio_from']}") |
| print(f" swap audio source (qwen view) : {rec['qwen_swap_audio_from']}") |
| print(f" qwen sync intervention failures :") |
| for hit in qwen_sync_variants[v]: |
| print(f" - {hit['variant']}") |
| print(f" gt={hit['gt']} pred_synced={hit['pred_synced']} pred={hit['pred']}") |
|
|
| with open(out_path, "w") as f: |
| for rec in records: |
| f.write(json.dumps(rec, ensure_ascii=False) + "\n") |
| print(f"\n[saved] {len(records)} candidates -> {out_path}") |
|
|
| |
| if not candidates: |
| print("\nNo full intersection. Pairwise overlap diagnostic:") |
| sets = { |
| "gemini_swap": gemini_swap_wrong, |
| "gemini_mute": gemini_mute_wrong, |
| "qwen_mute": qwen_mute_wrong, |
| "qwen_swap": qwen_swap_wrong, |
| "qwen_sync": qwen_sync_intervention_wrong, |
| } |
| names = list(sets) |
| for i, a in enumerate(names): |
| for b in names[i+1:]: |
| print(f" {a} & {b}: {len(sets[a] & sets[b])}") |
|
|
|
|
| if __name__ == "__main__": |
| main() |
|
|