File size: 2,247 Bytes
6aeb675
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import json
import string
from pathlib import Path


def option_label(index: int) -> str:
    """Return spreadsheet-style labels: A, B, ... Z, AA, AB, ..."""
    label = ""
    n = index + 1
    while n > 0:
        n, rem = divmod(n - 1, 26)
        label = string.ascii_uppercase[rem] + label
    return label


def main() -> None:
    source_path = Path("/home/jisoo/ECCV2026/data/Video-Holmes/test_Video-Holmes.json")
    video_root = Path("/home/jisoo/ECCV2026/data/Video-Holmes/videos_cropped")
    output_path = Path("/home/jisoo/ECCV2026/data/Video-Holmes/tests_videoholmes_all.json")

    all_tests = json.load(source_path.open("r", encoding="utf-8"))
    print(len(all_tests))

    videos2paths = {p.stem: p for p in video_root.rglob("*") if p.is_file()}

    new_test = []
    missing_videos = []

    for test_i, test in enumerate(all_tests):
        video_id = test["video ID"]
        video_path = videos2paths.get(video_id)
        if video_path is None:
            missing_videos.append(video_id)
            continue

        options_dict = test["Options"]
        option_keys = sorted(options_dict.keys())
        options = [f"{k}. {options_dict[k]}" for k in option_keys]

        answer_key = str(test["Answer"]).strip().upper()
        if answer_key not in option_keys:
            # Keep parity with MVBench conversion style while skipping bad rows safely.
            continue

        question_text = test["Question"]

        new_test.append(
            {
                "problem_id": test_i,
                "data_type": "video",
                "problem_type": "multiple choice",
                "options": options,
                "data_source": "Video-Holmes",
                "answer": f"<answer>{answer_key}</answer>",
                "videos": [str(video_path).replace("/home/jisoo/ECCV2026/data/Video-Holmes/", "./")],
                "problem": f"<video> {question_text}",
                "problem_reserved_text": question_text,
            }
        )

    json.dump(new_test, output_path.open("w", encoding="utf-8"), ensure_ascii=False, indent=2)
    print(f"Wrote {len(new_test)} samples to {output_path}")
    print(f"Missing videos: {len(missing_videos)}")


if __name__ == "__main__":
    main()


# 1837