diff --git a/tools/generate_questions.py b/tools/generate_questions.py index 2cb6880..317795f 100644 --- a/tools/generate_questions.py +++ b/tools/generate_questions.py @@ -908,30 +908,28 @@ async def _run_generate(args: argparse.Namespace) -> None: exemplars = _select_exemplars(benchmark, task_type, 3, rng) for seq in range(start_seq, per_type): - # 随机选一个视频 - video_id = rng.choice(video_ids) - tree_path = videos_dir / video_id / "tree.json" - - try: - tree = TreeIndex.load_json(str(tree_path)) - except Exception as exc: - logger.warning("加载树 {} 失败: {}", tree_path, exc) - total_failed += 1 - continue - - # frame_path 是相对于视频目录的,拼为绝对路径供 VLM 读取 - video_dir = videos_dir / video_id - for l1 in tree.roots: - for l2 in l1.children: - for l3 in l2.children: - if l3.frame_path and not Path(l3.frame_path).is_absolute(): - l3.frame_path = str(video_dir / l3.frame_path) - used_node_ids: set[str] = set() session_id = f"gen-{task_type}-{seq}" generated = False for _attempt in range(max_retries): + # 每次重试换一个视频,避免同视频反复去重失败 + video_id = rng.choice(video_ids) + tree_path = videos_dir / video_id / "tree.json" + + try: + tree = TreeIndex.load_json(str(tree_path)) + except Exception as exc: + logger.warning("加载树 {} 失败: {}", tree_path, exc) + continue + + video_dir = videos_dir / video_id + for l1 in tree.roots: + for l2 in l1.children: + for l3 in l2.children: + if l3.frame_path and not Path(l3.frame_path).is_absolute(): + l3.frame_path = str(video_dir / l3.frame_path) + candidate = await _generate_with_sem( vlm, tree,