File size: 2,547 Bytes
8773579
 
 
 
91fb04a
8773579
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91fb04a
 
 
 
8773579
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
import hashlib
import json
import re
import tarfile
from collections import Counter
from pathlib import Path

root = Path(__file__).resolve().parents[1]
qa = [json.loads(line) for line in (root / "annotations/qa_test.jsonl").read_text().splitlines() if line]
videos = [json.loads(line) for line in (root / "videos/metadata.jsonl").read_text().splitlines() if line]
assert len(qa) == 1217, len(qa)
assert len(videos) == 839, len(videos)
assert Counter(x["category"] for x in qa) == {
    "Identity Recall": 400,
    "Cross-Episode Identity Retrieval": 500,
    "Long-Term Identity Profile Inference": 317,
}
ids = {x["video_id"] for x in videos}
assert ids == {f"clip_{index:03d}" for index in range(839)}
with tarfile.open(root / "videos.tar", "r") as archive:
    archived_ids = {Path(name).stem for name in archive.getnames() if name.endswith(".mp4")}
assert archived_ids == ids
assert not list((root / "videos").glob("clip_*.mp4"))
video_fields = {"file_name", "video_id", "date", "duration_seconds", "is_calibration"}
assert all(set(row) == video_fields for row in videos)
for row in qa:
    assert "evidence_shot_ids" not in row
    assert set(row["evidence_video_ids"]) <= ids
    assert "category_id" not in row
    assert "evidence_id_namespace" not in row
    assert "evidence_metadata_status" not in row
    assert "access_policy" not in row
    if row["category"] == "Long-Term Identity Profile Inference":
        assert row["before_clip"] is None
    else:
        assert row["before_clip"] in ids
        latest_evidence = max(int(value.removeprefix("clip_")) for value in row["evidence_video_ids"])
        target_delay = 5 + int(hashlib.sha256(row["question_id"].encode("utf-8")).hexdigest()[:8], 16) % 16
        expected_before_clip = f"clip_{min(838, latest_evidence + target_delay):03d}"
        assert row["before_clip"] == expected_before_clip
profile = [row for row in qa if row["category"] == "Long-Term Identity Profile Inference"]
assert all(len(row["evidence_video_ids"]) >= 2 for row in profile)
speaker_pattern = re.compile(r"\b(?:Li Ming|Wang Lin|Zhang Hua|Li Jian|Chen Tao|Sarah Wu):\s*")
speakerless = sorted((root / "resources/asr_transcripts").glob("*.srt"))
labeled = sorted((root / "resources/transcripts_with_speakers").glob("*.srt"))
assert len(speakerless) == len(labeled) == 829
assert [path.name for path in speakerless] == [path.name for path in labeled]
assert all(not speaker_pattern.search(path.read_text()) for path in speakerless)
print("ICM-Bench release validation passed.")