fix(loader): use video_id from JSON data instead of filename
load_benchmark used the JSON filename stem as video_id, which broke v2-360 questions (all 180 questions got video_id='accepted_questions'). Now uses qa['video_id'] when present, falls back to filename for Video-MME format compatibility.
This commit is contained in:
@@ -21,8 +21,10 @@ _LEGACY_DEFAULT_DIFFICULTY = "medium"
|
||||
def load_benchmark(questions_dir: Path) -> list[GeneratedQuestion]:
|
||||
"""从 benchmark JSON 目录加载题目列表。
|
||||
|
||||
每个 JSON 文件以文件名(不含扩展名)作为 video_id,
|
||||
文件内容为题目数组。
|
||||
video_id 优先使用题目 JSON 中的 ``video_id`` 字段;若缺失则回退到
|
||||
文件名(不含扩展名)。Video-MME benchmark 按视频拆文件(文件名即
|
||||
video_id),v2 生成题把多视频题目合并在单个 JSON 中(每条记录自带
|
||||
``video_id``),两种格式均兼容。
|
||||
|
||||
参数:
|
||||
questions_dir: 包含 *.json 文件的目录路径。
|
||||
@@ -32,20 +34,21 @@ def load_benchmark(questions_dir: Path) -> list[GeneratedQuestion]:
|
||||
"""
|
||||
results: list[GeneratedQuestion] = []
|
||||
for path in sorted(questions_dir.glob("*.json")):
|
||||
video_id = path.stem
|
||||
fallback_video_id = path.stem
|
||||
with open(path, encoding="utf-8") as f:
|
||||
qa_list: list[dict] = json.load(f)
|
||||
for qa in qa_list:
|
||||
results.append(
|
||||
GeneratedQuestion(
|
||||
question_id=qa["question_id"],
|
||||
video_id=video_id,
|
||||
video_id=qa.get("video_id", fallback_video_id),
|
||||
task_type=qa["task_type"],
|
||||
question=qa["question"],
|
||||
options=tuple(qa["options"]),
|
||||
answer=qa["answer"],
|
||||
source_nodes=tuple(qa.get("source_nodes", ())),
|
||||
difficulty=qa.get("difficulty", _LEGACY_DEFAULT_DIFFICULTY),
|
||||
family=qa.get("family"),
|
||||
skill_target=qa.get("skill_target"),
|
||||
difficulty_steps=qa.get("difficulty_steps"),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user