futurefantasy commited on
Commit
b4df401
·
verified ·
1 Parent(s): 0d10787

Add VLAC-Cut public benchmark evaluation workflow

Browse files
README.md CHANGED
@@ -26,6 +26,7 @@ scripts/
26
  unpack_data.sh
27
  extract_vlac2_release_frames.py
28
  build_vlac_cut_eval_manifest.py
 
29
  evaluate_vpb_predictions.py
30
  vlac2_release_common.py
31
  vpb_public_eval_utils.py
@@ -40,6 +41,11 @@ data/
40
 
41
  ## Usage
42
 
 
 
 
 
 
43
  ### 1. Unpack the video archives
44
 
45
  ```bash
@@ -85,30 +91,41 @@ python scripts/build_vlac_cut_eval_manifest.py \
85
  --out manifests/vlac_cut_vpb_eval.jsonl
86
  ```
87
 
88
- For our VLAC-Cut benchmark evaluation, the manifest samples 2Hz video input frames and also records the public 1Hz evaluation frames from the main view of each trajectory. The 2Hz setting is an evaluation choice for VLAC-Cut input, not a benchmark-wide requirement. Metrics are computed on the released 1Hz evaluation frames.
89
 
90
  For trajectory-level VLAC-Cut predictions, keep the manifest's 2Hz `frames` list in each prediction row. The evaluator maps predictions by original frame id and scores only the public 1Hz `eval_frames` for global progress and terminal metrics.
91
 
92
  By default, each manifest row is one trajectory with a list of sampled frame paths for VLAC-Cut inference.
93
 
94
- ### 5. Evaluate VLAC-Cut predictions
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
 
96
  ```bash
97
  python scripts/evaluate_vpb_predictions.py \
98
  --benchmark-root benchmark_splits \
99
- --predictions vlac_cut_predictions.jsonl \
100
  --out-json reports/vlac_cut_vpb_eval.json \
101
  --out-md reports/vlac_cut_vpb_eval.md
102
  ```
103
 
104
  The evaluator reports global progress metrics, terminal success metrics, and local direction AP on adjacent semantic anchors. Global progress is shown for the 4-bucket overall split and each bucket; terminal metrics and local direction AP are shown for 4-bucket overall, seen merged, and unseen merged. See `docs/evaluate_vlac_cut_on_vpb.md` for the accepted prediction schema and metric definitions.
105
 
106
- ### 6. Evaluate VLAC-Cut
107
-
108
- VLAC-Cut is released separately at <https://huggingface.co/InternRobotics/VLAC-Cut>. This benchmark release does not vendor model weights or a VLAC-Cut batch inference runner; it only defines the benchmark frames, prediction schema, and evaluator.
109
-
110
- For our VLAC-Cut evaluation, run the model on the 2Hz `image_paths` from the trajectory manifest instead of re-sampling the full raw video. This 2Hz input setting is what we use for VLAC-Cut evaluation; the public benchmark metrics themselves are computed on the 1Hz `eval_frames`. Write one prediction row per trajectory with `global_episode_id`, `frames`, and either the raw VLAC-Cut `response` or an aligned `pred_progress_sequence`, then run `evaluate_vpb_predictions.py` as above. The evaluator parses VLAC-style keypoint responses, reconstructs the prediction curve, and reports global progress, terminal success, and local direction AP. The exact adapter contract is documented in `docs/evaluate_vlac_cut_on_vpb.md`.
111
-
112
  ## Notes
113
 
114
  * This repository contains only the raw videos required by the released benchmark splits.
 
26
  unpack_data.sh
27
  extract_vlac2_release_frames.py
28
  build_vlac_cut_eval_manifest.py
29
+ run_vlac_cut_batch.py
30
  evaluate_vpb_predictions.py
31
  vlac2_release_common.py
32
  vpb_public_eval_utils.py
 
41
 
42
  ## Usage
43
 
44
+ VLAC-Cut inference uses the model release's Transformers interface and requires
45
+ an environment that can load `Qwen3VLMoeForConditionalGeneration`, plus enough
46
+ GPU memory for the 30B checkpoint. Frame extraction and metric computation use
47
+ only the files in this benchmark release.
48
+
49
  ### 1. Unpack the video archives
50
 
51
  ```bash
 
91
  --out manifests/vlac_cut_vpb_eval.jsonl
92
  ```
93
 
94
+ For our VLAC-Cut benchmark evaluation, the manifest samples 2Hz video input frames, records the public 1Hz evaluation frames, and materializes the exact `chunk_all` text prompt in `vlac_cut_prompt`. The 2Hz setting is an evaluation choice for VLAC-Cut input, not a benchmark-wide requirement. Metrics are computed on the released 1Hz evaluation frames.
95
 
96
  For trajectory-level VLAC-Cut predictions, keep the manifest's 2Hz `frames` list in each prediction row. The evaluator maps predictions by original frame id and scores only the public 1Hz `eval_frames` for global progress and terminal metrics.
97
 
98
  By default, each manifest row is one trajectory with a list of sampled frame paths for VLAC-Cut inference.
99
 
100
+ ### 5. Run VLAC-Cut batch inference
101
+
102
+ VLAC-Cut is released separately at <https://huggingface.co/InternRobotics/VLAC-Cut>.
103
+
104
+ ```bash
105
+ python scripts/run_vlac_cut_batch.py \
106
+ --model-path /path/to/VLAC-Cut \
107
+ --manifest manifests/vlac_cut_vpb_eval.jsonl \
108
+ --out predictions/vlac_cut_predictions.jsonl
109
+ ```
110
+
111
+ The batch prediction file uses one fixed schema:
112
+
113
+ ```json
114
+ {"global_episode_id": "...", "frames": [65, 80, 95], "response": "时间: 0.0s, 进度: 0%\n时间: 1.0s, 进度: 50%"}
115
+ ```
116
+
117
+ ### 6. Evaluate VLAC-Cut predictions
118
 
119
  ```bash
120
  python scripts/evaluate_vpb_predictions.py \
121
  --benchmark-root benchmark_splits \
122
+ --predictions predictions/vlac_cut_predictions.jsonl \
123
  --out-json reports/vlac_cut_vpb_eval.json \
124
  --out-md reports/vlac_cut_vpb_eval.md
125
  ```
126
 
127
  The evaluator reports global progress metrics, terminal success metrics, and local direction AP on adjacent semantic anchors. Global progress is shown for the 4-bucket overall split and each bucket; terminal metrics and local direction AP are shown for 4-bucket overall, seen merged, and unseen merged. See `docs/evaluate_vlac_cut_on_vpb.md` for the accepted prediction schema and metric definitions.
128
 
 
 
 
 
 
 
129
  ## Notes
130
 
131
  * This repository contains only the raw videos required by the released benchmark splits.
docs/evaluate_vlac_cut_on_vpb.md CHANGED
@@ -1,18 +1,12 @@
1
  # Evaluating VLAC-Cut on Video-Progress Benchmark
2
 
3
- This document describes how to evaluate VLAC-Cut benchmark metrics using only
4
- the public Video-Progress Benchmark release files. It does not require private
5
- workspace paths or private metric code.
6
-
7
- The VLAC-Cut model release is hosted separately at
8
- <https://huggingface.co/InternRobotics/VLAC-Cut>. This benchmark release
9
- contains the split files, frame extraction scripts, a VLAC-Cut evaluation
10
- manifest builder, and a prediction evaluator. It does not vendor model weights
11
- or a VLAC-Cut batch inference runner.
12
 
13
  ## Evaluation Scope
14
 
15
- The public benchmark metrics are computed on the released 1Hz evaluation frames
16
  reconstructed from each dense video timeline:
17
 
18
  - split scope: `test_expert_seen`, `test_expert_unseen`,
@@ -24,25 +18,25 @@ reconstructed from each dense video timeline:
24
  - local direction metrics: `AP+`, `AP-`, and `MacroAP_D` on adjacent
25
  `semantic_anchors` with `tau=0`
26
 
27
- For our VLAC-Cut evaluation, we feed the model video frames sampled at 2Hz. This
28
- 2Hz input rate is an evaluation setting for VLAC-Cut, not a benchmark-wide
29
- protocol requirement. The evaluator maps VLAC-Cut predictions back to original
30
- frame ids and computes the benchmark metrics on the public 1Hz evaluation
31
- frames.
32
-
33
- The released JSON files also contain dense frame-level progress. Use
34
- `--eval-points dense` only for diagnostics; it is not the paper-comparable
35
- default.
36
 
37
  ## Workflow
38
 
 
 
 
 
 
39
  Unpack videos:
40
 
41
  ```bash
42
  bash scripts/unpack_data.sh /path/to/data
43
  ```
44
 
45
- Extract frames:
46
 
47
  ```bash
48
  python scripts/extract_vlac2_release_frames.py \
@@ -59,70 +53,68 @@ python scripts/build_vlac_cut_eval_manifest.py \
59
  --out manifests/vlac_cut_vpb_eval.jsonl
60
  ```
61
 
62
- Each trajectory-level manifest row contains:
63
 
64
- - `frames` / `input_frames`: the 2Hz frame ids used as VLAC-Cut video input.
65
- - `image_paths` / `input_image_paths`: the extracted images for those 2Hz
66
- frames.
67
- - `eval_frames`: the public 1Hz frame ids used for global progress and terminal
68
- metrics.
69
- - `task_instruction` and `task_description`: text fields used to build the
70
- VLAC-Cut prompt.
71
 
72
- For this release, the default 1Hz `eval_frames` are a subset of the default 2Hz
73
- `input_frames`. Keep the 2Hz `frames` list in each VLAC-Cut prediction row. The
74
- evaluator stores predictions by original frame id, then compares only the 1Hz
75
- `eval_frames` against the released `dense_kinematic_progress` GT.
76
 
77
- ## VLAC-Cut Prediction Rows
 
 
 
 
 
 
78
 
79
- A minimal VLAC-Cut adapter should:
80
 
81
- 1. Read each row from `manifests/vlac_cut_vpb_eval.jsonl`.
82
- 2. Build the same VLAC-Cut prompt from `task_instruction` and
83
- `task_description`.
84
- 3. Run VLAC-Cut on `image_paths` with the frame order unchanged.
85
- 4. Write one prediction row per trajectory with the raw VLAC-Cut response.
86
 
87
- Example:
 
 
 
 
 
 
 
88
 
89
- ```json
90
- {
91
- "global_episode_id": "ARX-data/.../episode_000000",
92
- "frames": [0, 15, 30, 45, 60],
93
- "response": "时间: 0.5s, 进度: 0%\n时间: 2.0s, 进度: 30%"
94
- }
 
 
 
95
  ```
96
 
97
- The evaluator parses VLAC-style keypoint responses, aligns the parsed progress
98
- curve to the provided 2Hz `frames` list using the same index-normalized
99
- alignment rule as the formal VLAC evaluation code, and then takes the 1Hz subset
100
- for metric computation.
101
 
102
- If your adapter has already converted the response into a progress sequence
103
- aligned to the 2Hz frames, this format is also accepted:
 
104
 
105
  ```json
106
  {
107
  "global_episode_id": "ARX-data/.../episode_000000",
108
  "frames": [0, 15, 30, 45, 60],
109
- "pred_progress_sequence": [0.0, 5.0, 12.5, 20.0, 28.0]
110
  }
111
  ```
112
 
113
- Run evaluation:
114
-
115
- ```bash
116
- python scripts/evaluate_vpb_predictions.py \
117
- --benchmark-root benchmark_splits \
118
- --predictions vlac_cut_predictions.jsonl \
119
- --out-json reports/vlac_cut_vpb_eval.json \
120
- --out-md reports/vlac_cut_vpb_eval.md
121
- ```
122
-
123
- Use `--interpolate-missing` only for sparse outputs that do not contain the 1Hz
124
- evaluation frame ids. Reports generated with interpolation are not strict
125
- paper-comparable outputs.
126
 
127
  ## Metrics
128
 
@@ -163,7 +155,7 @@ Delta_pred = pred_progress_end - pred_progress_start
163
  ```
164
 
165
  Prediction values at anchor frames are obtained by linear interpolation over the
166
- model's valid predicted curve. The formal public report uses `tau=0`:
167
 
168
  ```text
169
  AP+ = AP(y = 1[Delta_gt > 0], score = Delta_pred)
@@ -177,11 +169,12 @@ merged, and unseen merged rows.
177
 
178
  ## Diagnostics
179
 
180
- Missing predictions are not silently filled in strict mode. The report includes
181
- coverage, missing final counts, duplicate prediction counts, unknown episode
182
- ids, prediction frames outside the selected 1Hz evaluation points, and counts
183
- for predictions outside the nominal `[0, 100]` range. The nominal range counts
184
- are diagnostics only; predictions are not clipped unless `--clip-pred` is set.
 
185
 
186
  ## Quick Checks
187
 
 
1
  # Evaluating VLAC-Cut on Video-Progress Benchmark
2
 
3
+ This document describes the public VLAC-Cut evaluation workflow for
4
+ Video-Progress Benchmark. It uses only this benchmark release plus the separate
5
+ VLAC-Cut model release at <https://huggingface.co/InternRobotics/VLAC-Cut>.
 
 
 
 
 
 
6
 
7
  ## Evaluation Scope
8
 
9
+ The benchmark metrics are computed on the released 1Hz evaluation frames
10
  reconstructed from each dense video timeline:
11
 
12
  - split scope: `test_expert_seen`, `test_expert_unseen`,
 
18
  - local direction metrics: `AP+`, `AP-`, and `MacroAP_D` on adjacent
19
  `semantic_anchors` with `tau=0`
20
 
21
+ For VLAC-Cut evaluation we feed the model frames sampled at 2Hz. This 2Hz input
22
+ rate is a VLAC-Cut evaluation setting, not a benchmark-wide protocol
23
+ requirement. The evaluator maps VLAC-Cut outputs back to original frame ids and
24
+ computes metrics on the public 1Hz evaluation frames.
 
 
 
 
 
25
 
26
  ## Workflow
27
 
28
+ VLAC-Cut inference requires the model release environment: `torch`,
29
+ `transformers` with `Qwen3VLMoeForConditionalGeneration` support, and enough GPU
30
+ memory for the 30B checkpoint. The benchmark-side frame extraction, manifest
31
+ building, and evaluation scripts are included in this release.
32
+
33
  Unpack videos:
34
 
35
  ```bash
36
  bash scripts/unpack_data.sh /path/to/data
37
  ```
38
 
39
+ Extract benchmark frames:
40
 
41
  ```bash
42
  python scripts/extract_vlac2_release_frames.py \
 
53
  --out manifests/vlac_cut_vpb_eval.jsonl
54
  ```
55
 
56
+ Run VLAC-Cut batch inference:
57
 
58
+ ```bash
59
+ python scripts/run_vlac_cut_batch.py \
60
+ --model-path /path/to/VLAC-Cut \
61
+ --manifest manifests/vlac_cut_vpb_eval.jsonl \
62
+ --out predictions/vlac_cut_predictions.jsonl
63
+ ```
 
64
 
65
+ Evaluate the batch predictions:
 
 
 
66
 
67
+ ```bash
68
+ python scripts/evaluate_vpb_predictions.py \
69
+ --benchmark-root benchmark_splits \
70
+ --predictions predictions/vlac_cut_predictions.jsonl \
71
+ --out-json reports/vlac_cut_vpb_eval.json \
72
+ --out-md reports/vlac_cut_vpb_eval.md
73
+ ```
74
 
75
+ ## Manifest Fields
76
 
77
+ Each trajectory-level manifest row contains the fields needed by the batch
78
+ inference script:
 
 
 
79
 
80
+ - `global_episode_id`: episode key used to match predictions with GT.
81
+ - `frames` / `image_paths`: the 2Hz frame ids and frame images passed to
82
+ VLAC-Cut.
83
+ - `eval_frames`: the public 1Hz frame ids used for global progress and terminal
84
+ metrics.
85
+ - `vlac_cut_prompt`: the exact text prompt passed to the Qwen/VLAC-Cut model.
86
+ - `prompt_variant`: fixed to `chunk_all`.
87
+ - `prompt_source`: fixed to `task_description`.
88
 
89
+ The prompt is materialized by the manifest builder as:
90
+
91
+ ```text
92
+ 任务描述和具体规划: {task_description}
93
+
94
+ 请根据任务描述和具体规划,找到并���点生成视频中的关键动作点和相应的进度标注。输出格式要求:每个关键点一行,格式为:
95
+ 时间: X.Xs, 进度: Y%
96
+
97
+ 请严格按照上述格式输出,不要输出额外说明。
98
  ```
99
 
100
+ `task_description` already contains the task and progress plan, so it is not
101
+ prefixed again with `task_instruction`.
 
 
102
 
103
+ ## Prediction Schema
104
+
105
+ `run_vlac_cut_batch.py` writes one JSON object per trajectory:
106
 
107
  ```json
108
  {
109
  "global_episode_id": "ARX-data/.../episode_000000",
110
  "frames": [0, 15, 30, 45, 60],
111
+ "response": "时间: 0.5s, 进度: 0%\n时间: 2.0s, 进度: 30%"
112
  }
113
  ```
114
 
115
+ This is the public evaluator schema. The evaluator parses `response`, aligns the
116
+ parsed keypoints to the provided 2Hz `frames` list using index-normalized curve
117
+ alignment, and then evaluates the aligned curve on the benchmark points.
 
 
 
 
 
 
 
 
 
 
118
 
119
  ## Metrics
120
 
 
155
  ```
156
 
157
  Prediction values at anchor frames are obtained by linear interpolation over the
158
+ model's valid predicted curve. The public report uses `tau=0`:
159
 
160
  ```text
161
  AP+ = AP(y = 1[Delta_gt > 0], score = Delta_pred)
 
169
 
170
  ## Diagnostics
171
 
172
+ Missing or unparsable prediction rows are not silently filled. The report
173
+ includes coverage, missing final counts, duplicate prediction counts, unknown
174
+ episode ids, prediction frames outside the selected 1Hz evaluation points, and
175
+ counts for predictions outside the nominal `[0, 100]` range. The nominal range
176
+ counts are diagnostics only; predictions are not clipped unless `--clip-pred` is
177
+ set.
178
 
179
  ## Quick Checks
180
 
scripts/build_vlac_cut_eval_manifest.py CHANGED
@@ -21,6 +21,20 @@ from vpb_public_eval_utils import (
21
  selected_frames_for_row,
22
  )
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  def parse_args() -> argparse.Namespace:
26
  release_root = SCRIPT_DIR.parent
@@ -105,6 +119,7 @@ def build_record(
105
  sample_hz: float,
106
  ) -> dict[str, Any]:
107
  meta = dict(row.get("metadata") or {})
 
108
  record: dict[str, Any] = {
109
  "bucket": bucket,
110
  "row_index": row_idx,
@@ -114,7 +129,10 @@ def build_record(
114
  "image_path": str(image_path),
115
  "view": view,
116
  "task_instruction": str(meta.get("task_instruction") or ""),
117
- "task_description": str(meta.get("task_description") or ""),
 
 
 
118
  "is_terminal_point": bool(is_terminal_point),
119
  "selected_frame_count": int(selected_count),
120
  "eval_points": eval_points,
@@ -142,6 +160,7 @@ def build_trajectory_record(
142
  input_sample_hz: float,
143
  ) -> dict[str, Any]:
144
  meta = dict(row.get("metadata") or {})
 
145
  record: dict[str, Any] = {
146
  "bucket": bucket,
147
  "row_index": row_idx,
@@ -156,7 +175,10 @@ def build_trajectory_record(
156
  "eval_timestamps_sec": eval_timestamps_sec,
157
  "view": view,
158
  "task_instruction": str(meta.get("task_instruction") or ""),
159
- "task_description": str(meta.get("task_description") or ""),
 
 
 
160
  "terminal_frame": int(eval_frames[-1]) if eval_frames else None,
161
  "selected_frame_count": len(input_frames),
162
  "input_frame_count": len(input_frames),
 
21
  selected_frames_for_row,
22
  )
23
 
24
+ PROMPT_VARIANT = "chunk_all"
25
+ PROMPT_SOURCE = "task_description"
26
+
27
+
28
+ def build_vlac_cut_prompt(task_description: str) -> str:
29
+ task_and_plan = str(task_description or "").strip()
30
+ return (
31
+ f"任务描述和具体规划: {task_and_plan}\n\n"
32
+ "请根据任务描述和具体规划,找到并逐点生成视频中的关键动作点和相应的进度标注。"
33
+ "输出格式要求:每个关键点一行,格式为:\n"
34
+ "时间: X.Xs, 进度: Y%\n\n"
35
+ "请严格按照上述格式输出,不要输出额外说明。"
36
+ )
37
+
38
 
39
  def parse_args() -> argparse.Namespace:
40
  release_root = SCRIPT_DIR.parent
 
119
  sample_hz: float,
120
  ) -> dict[str, Any]:
121
  meta = dict(row.get("metadata") or {})
122
+ task_description = str(meta.get("task_description") or "")
123
  record: dict[str, Any] = {
124
  "bucket": bucket,
125
  "row_index": row_idx,
 
129
  "image_path": str(image_path),
130
  "view": view,
131
  "task_instruction": str(meta.get("task_instruction") or ""),
132
+ "task_description": task_description,
133
+ "vlac_cut_prompt": build_vlac_cut_prompt(task_description),
134
+ "prompt_variant": PROMPT_VARIANT,
135
+ "prompt_source": PROMPT_SOURCE,
136
  "is_terminal_point": bool(is_terminal_point),
137
  "selected_frame_count": int(selected_count),
138
  "eval_points": eval_points,
 
160
  input_sample_hz: float,
161
  ) -> dict[str, Any]:
162
  meta = dict(row.get("metadata") or {})
163
+ task_description = str(meta.get("task_description") or "")
164
  record: dict[str, Any] = {
165
  "bucket": bucket,
166
  "row_index": row_idx,
 
175
  "eval_timestamps_sec": eval_timestamps_sec,
176
  "view": view,
177
  "task_instruction": str(meta.get("task_instruction") or ""),
178
+ "task_description": task_description,
179
+ "vlac_cut_prompt": build_vlac_cut_prompt(task_description),
180
+ "prompt_variant": PROMPT_VARIANT,
181
+ "prompt_source": PROMPT_SOURCE,
182
  "terminal_frame": int(eval_frames[-1]) if eval_frames else None,
183
  "selected_frame_count": len(input_frames),
184
  "input_frame_count": len(input_frames),
scripts/evaluate_vpb_predictions.py CHANGED
@@ -54,7 +54,11 @@ def parse_args() -> argparse.Namespace:
54
  default=release_root / "benchmark_splits",
55
  help="Directory containing the benchmark split folders.",
56
  )
57
- parser.add_argument("--predictions", type=Path, help="Prediction JSONL or JSON file.")
 
 
 
 
58
  parser.add_argument("--out-json", type=Path, help="Output JSON report.")
59
  parser.add_argument("--out-md", type=Path, help="Output Markdown report.")
60
  parser.add_argument(
@@ -176,7 +180,7 @@ def parse_point_blocks(text: str) -> tuple[list[float], list[float]]:
176
  [float(time_val) for time_val, _ in inline_matches],
177
  [float(progress_val) for _, progress_val in inline_matches],
178
  )
179
- blocks = re.split(r"(?=时间[::]?\s*[0-9])", cleaned)
180
  times: list[float] = []
181
  values: list[float] = []
182
  for block in blocks:
@@ -264,113 +268,52 @@ def add_prediction(
264
  stats["valid_prediction_values"] += 1
265
 
266
 
267
- def add_sequence_predictions(
268
  pred_map: PredMap,
269
  *,
270
  gid: str,
271
- sequence: Any,
272
- traj: Trajectory,
273
- frame_sequence: Any,
274
  clip_range: tuple[float, float] | None,
275
  stats: Counter[str],
276
  ) -> None:
277
- if not isinstance(sequence, list):
278
- stats["invalid_sequence_predictions"] += 1
279
- return
280
- if isinstance(frame_sequence, list) and len(frame_sequence) == len(sequence):
281
- valid_frames: list[int] = []
282
- for raw_frame in frame_sequence:
283
- frame = finite_float(raw_frame)
284
- if frame is None:
285
- stats["invalid_sequence_frames"] += 1
286
- return
287
- valid_frames.append(int(frame))
288
- for frame, value in zip(valid_frames, sequence):
289
- add_prediction(
290
- pred_map,
291
- gid=gid,
292
- frame=frame,
293
- value=value,
294
- clip_range=clip_range,
295
- stats=stats,
296
- )
297
- stats["sequence_rows_aligned_by_row_frames"] += 1
298
  return
299
- if len(sequence) == len(traj.frames):
300
- for frame, value in zip(traj.frames, sequence):
301
- add_prediction(
302
- pred_map,
303
- gid=gid,
304
- frame=frame,
305
- value=value,
306
- clip_range=clip_range,
307
- stats=stats,
308
- )
309
- stats["sequence_rows_aligned_by_position"] += 1
310
  return
311
- if traj.frames and max(traj.frames) < len(sequence):
312
- for frame in traj.frames:
313
- add_prediction(
314
- pred_map,
315
- gid=gid,
316
- frame=frame,
317
- value=sequence[frame],
318
- clip_range=clip_range,
319
- stats=stats,
320
- )
321
- stats["sequence_rows_aligned_by_frame_id"] += 1
322
- return
323
- stats["sequence_length_mismatch"] += 1
324
-
325
 
326
- def add_vlac_keypoint_predictions(
327
- pred_map: PredMap,
328
- *,
329
- gid: str,
330
- row: dict[str, Any],
331
- traj: Trajectory,
332
- clip_range: tuple[float, float] | None,
333
- stats: Counter[str],
334
- ) -> bool:
335
- frame_sequence = row.get("frames") or row.get("input_frames")
336
- if not isinstance(frame_sequence, list) or not frame_sequence:
337
- return False
338
-
339
- raw_times: list[float] = []
340
- raw_values: list[float] = []
341
- if isinstance(row.get("pred_curve_point_times_sec"), list) and isinstance(row.get("pred_curve_point_progress"), list):
342
- for time_val, progress_val in zip(row["pred_curve_point_times_sec"], row["pred_curve_point_progress"]):
343
- time_num = finite_float(time_val)
344
- progress_num = finite_float(progress_val)
345
- if time_num is None or progress_num is None:
346
- continue
347
- raw_times.append(float(time_num))
348
- raw_values.append(float(progress_num))
349
- elif isinstance(row.get("response"), str):
350
- raw_times, raw_values = parse_point_blocks(str(row.get("response") or ""))
351
- else:
352
- return False
353
 
354
  if not raw_values:
355
- stats["vlac_keypoint_parse_failed"] += 1
356
- return True
357
 
358
- aligned = align_curve_to_length(raw_times, raw_values, len(frame_sequence))
359
  if not aligned:
360
- stats["vlac_keypoint_align_failed"] += 1
361
- return True
362
-
363
- add_sequence_predictions(
364
- pred_map,
365
- gid=gid,
366
- sequence=aligned,
367
- traj=traj,
368
- frame_sequence=frame_sequence,
369
- clip_range=clip_range,
370
- stats=stats,
371
- )
372
- stats["vlac_keypoint_rows_aligned_by_index"] += 1
373
- return True
374
 
375
 
376
  def load_predictions(
@@ -398,73 +341,10 @@ def load_predictions(
398
  unknown_examples.append(gid)
399
  continue
400
 
401
- by_frame = None
402
- for key in ("pred_progress_by_frame", "progress_by_frame", "predictions_by_frame"):
403
- value = row.get(key)
404
- if isinstance(value, dict):
405
- by_frame = value
406
- break
407
- if by_frame is not None:
408
- stats["episode_rows"] += 1
409
- for raw_frame, value in by_frame.items():
410
- frame = finite_float(raw_frame)
411
- if frame is None:
412
- stats["invalid_prediction_frames"] += 1
413
- continue
414
- add_prediction(
415
- pred_map,
416
- gid=gid,
417
- frame=int(frame),
418
- value=value,
419
- clip_range=clip_range,
420
- stats=stats,
421
- )
422
- continue
423
-
424
- if add_vlac_keypoint_predictions(
425
  pred_map,
426
  gid=gid,
427
  row=row,
428
- traj=traj,
429
- clip_range=clip_range,
430
- stats=stats,
431
- ):
432
- continue
433
-
434
- sequence = None
435
- for key in ("pred_progress_sequence", "pred_dense_progress_aligned_to_gt"):
436
- value = row.get(key)
437
- if isinstance(value, list):
438
- sequence = value
439
- break
440
- if sequence is not None:
441
- stats["sequence_rows"] += 1
442
- add_sequence_predictions(
443
- pred_map,
444
- gid=gid,
445
- sequence=sequence,
446
- traj=traj,
447
- frame_sequence=row.get("frames") or row.get("input_frames"),
448
- clip_range=clip_range,
449
- stats=stats,
450
- )
451
- continue
452
-
453
- frame = finite_float(row.get("frame"))
454
- value = None
455
- for key in ("pred_progress", "pred_progress_percent", "progress", "prediction"):
456
- if key in row:
457
- value = row.get(key)
458
- break
459
- if frame is None or value is None:
460
- stats["unrecognized_prediction_rows"] += 1
461
- continue
462
- stats["point_rows"] += 1
463
- add_prediction(
464
- pred_map,
465
- gid=gid,
466
- frame=int(frame),
467
- value=value,
468
  clip_range=clip_range,
469
  stats=stats,
470
  )
@@ -1065,12 +945,21 @@ def run_self_test() -> None:
1065
  with pred_path.open("w", encoding="utf-8") as f:
1066
  for rows in rows_by_bucket.values():
1067
  for item in rows:
 
 
 
 
1068
  f.write(
1069
  json.dumps(
1070
  {
1071
  "global_episode_id": item["global_episode_id"],
1072
- "pred_progress_by_frame": item["dense_kinematic_progress"],
1073
- }
 
 
 
 
 
1074
  )
1075
  + "\n"
1076
  )
 
54
  default=release_root / "benchmark_splits",
55
  help="Directory containing the benchmark split folders.",
56
  )
57
+ parser.add_argument(
58
+ "--predictions",
59
+ type=Path,
60
+ help="VLAC-Cut batch prediction JSONL with global_episode_id, frames, and response.",
61
+ )
62
  parser.add_argument("--out-json", type=Path, help="Output JSON report.")
63
  parser.add_argument("--out-md", type=Path, help="Output Markdown report.")
64
  parser.add_argument(
 
180
  [float(time_val) for time_val, _ in inline_matches],
181
  [float(progress_val) for _, progress_val in inline_matches],
182
  )
183
+ blocks = re.split(r"(?=(?:Time|时间)[::]?\s*[0-9])", cleaned, flags=re.IGNORECASE)
184
  times: list[float] = []
185
  values: list[float] = []
186
  for block in blocks:
 
268
  stats["valid_prediction_values"] += 1
269
 
270
 
271
+ def add_canonical_vlac_response_predictions(
272
  pred_map: PredMap,
273
  *,
274
  gid: str,
275
+ row: dict[str, Any],
 
 
276
  clip_range: tuple[float, float] | None,
277
  stats: Counter[str],
278
  ) -> None:
279
+ frame_sequence = row.get("frames")
280
+ if not isinstance(frame_sequence, list) or not frame_sequence:
281
+ stats["canonical_rows_missing_frames"] += 1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282
  return
283
+ valid_frames: list[int] = []
284
+ for raw_frame in frame_sequence:
285
+ frame = finite_float(raw_frame)
286
+ if frame is None:
287
+ stats["canonical_rows_invalid_frames"] += 1
288
+ return
289
+ valid_frames.append(int(frame))
290
+
291
+ response = row.get("response")
292
+ if not isinstance(response, str) or not response.strip():
293
+ stats["canonical_rows_missing_response"] += 1
294
  return
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
 
296
+ raw_times, raw_values = parse_point_blocks(response)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
 
298
  if not raw_values:
299
+ stats["canonical_response_parse_failed"] += 1
300
+ return
301
 
302
+ aligned = align_curve_to_length(raw_times, raw_values, len(valid_frames))
303
  if not aligned:
304
+ stats["canonical_response_align_failed"] += 1
305
+ return
306
+
307
+ for frame, value in zip(valid_frames, aligned):
308
+ add_prediction(
309
+ pred_map,
310
+ gid=gid,
311
+ frame=frame,
312
+ value=value,
313
+ clip_range=clip_range,
314
+ stats=stats,
315
+ )
316
+ stats["canonical_response_rows_aligned_by_index"] += 1
 
317
 
318
 
319
  def load_predictions(
 
341
  unknown_examples.append(gid)
342
  continue
343
 
344
+ add_canonical_vlac_response_predictions(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
345
  pred_map,
346
  gid=gid,
347
  row=row,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
348
  clip_range=clip_range,
349
  stats=stats,
350
  )
 
945
  with pred_path.open("w", encoding="utf-8") as f:
946
  for rows in rows_by_bucket.values():
947
  for item in rows:
948
+ points = sorted(
949
+ (int(frame), float(value))
950
+ for frame, value in item["dense_kinematic_progress"].items()
951
+ )
952
  f.write(
953
  json.dumps(
954
  {
955
  "global_episode_id": item["global_episode_id"],
956
+ "frames": [frame for frame, _value in points],
957
+ "response": "\n".join(
958
+ f"时间: {idx:.1f}s, 进度: {value:g}%"
959
+ for idx, (_frame, value) in enumerate(points)
960
+ ),
961
+ },
962
+ ensure_ascii=False,
963
  )
964
  + "\n"
965
  )
scripts/run_vlac_cut_batch.py ADDED
@@ -0,0 +1,352 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ from __future__ import annotations
3
+
4
+ import argparse
5
+ import json
6
+ import os
7
+ from pathlib import Path
8
+ from typing import Any
9
+
10
+
11
+ def parse_args() -> argparse.Namespace:
12
+ parser = argparse.ArgumentParser(
13
+ description="Run VLAC-Cut batch inference from a public VPB evaluation manifest."
14
+ )
15
+ parser.add_argument(
16
+ "--model-path",
17
+ type=Path,
18
+ required=True,
19
+ help="Path to the released VLAC-Cut model directory.",
20
+ )
21
+ parser.add_argument(
22
+ "--manifest",
23
+ type=Path,
24
+ required=True,
25
+ help="JSONL file produced by build_vlac_cut_eval_manifest.py.",
26
+ )
27
+ parser.add_argument(
28
+ "--out",
29
+ type=Path,
30
+ required=True,
31
+ help="Output prediction JSONL path.",
32
+ )
33
+ parser.add_argument(
34
+ "--limit",
35
+ type=int,
36
+ default=None,
37
+ help="Optional maximum number of manifest rows to run.",
38
+ )
39
+ parser.add_argument(
40
+ "--resume",
41
+ action="store_true",
42
+ help="Append to --out and skip global_episode_id values already present in it.",
43
+ )
44
+ parser.add_argument(
45
+ "--max-new-tokens",
46
+ type=int,
47
+ default=1024,
48
+ help="Generation cap for each response.",
49
+ )
50
+ parser.add_argument(
51
+ "--device-map",
52
+ default="auto",
53
+ help="Device map passed to Transformers from_pretrained.",
54
+ )
55
+ parser.add_argument(
56
+ "--dtype",
57
+ default=None,
58
+ help="Torch dtype passed to Transformers. Defaults to auto.",
59
+ )
60
+ parser.add_argument(
61
+ "--attn-implementation",
62
+ default=None,
63
+ help="Optional attention implementation passed to Transformers, for example flash_attention_2 or sdpa.",
64
+ )
65
+ parser.add_argument(
66
+ "--check-files",
67
+ action="store_true",
68
+ help="Fail before inference if any manifest image path is missing.",
69
+ )
70
+ return parser.parse_args()
71
+
72
+
73
+ def load_transformers_runtime():
74
+ os.environ.setdefault("PYTORCH_CUDA_ALLOC_CONF", "expandable_segments:True")
75
+ os.environ.setdefault("IMAGE_MAX_TOKEN_NUM", "256")
76
+ os.environ.setdefault("VIDEO_MAX_TOKEN_NUM", "256")
77
+ os.environ.setdefault("VIDEO_MIN_TOKEN_NUM", "4")
78
+ os.environ.setdefault("QWEN_VL_UTILS_MAX_FRAME_LIST", "0")
79
+
80
+ try:
81
+ import torch
82
+ except ImportError as exc:
83
+ raise SystemExit("Missing dependency: torch is required for VLAC-Cut inference.") from exc
84
+
85
+ try:
86
+ from transformers import AutoModelForImageTextToText, AutoProcessor
87
+ except ImportError as exc:
88
+ raise SystemExit("Missing dependency: transformers is required for VLAC-Cut inference.") from exc
89
+
90
+ return torch, AutoModelForImageTextToText, AutoProcessor
91
+
92
+
93
+ def iter_jsonl(path: Path):
94
+ with path.open("r", encoding="utf-8") as f:
95
+ for line_no, line in enumerate(f, start=1):
96
+ raw = line.strip()
97
+ if not raw:
98
+ continue
99
+ item = json.loads(raw)
100
+ if not isinstance(item, dict):
101
+ raise ValueError(f"{path}:{line_no} is not a JSON object")
102
+ yield line_no, item
103
+
104
+
105
+ def existing_global_episode_ids(path: Path) -> set[str]:
106
+ if not path.exists():
107
+ return set()
108
+ done: set[str] = set()
109
+ for _line_no, row in iter_jsonl(path):
110
+ gid = str(row.get("global_episode_id") or "").strip()
111
+ if gid:
112
+ done.add(gid)
113
+ return done
114
+
115
+
116
+ def require_manifest_row(row: dict[str, Any], line_no: int, *, check_files: bool) -> tuple[str, list[int], list[str], str, float]:
117
+ gid = str(row.get("global_episode_id") or "").strip()
118
+ if not gid:
119
+ raise ValueError(f"manifest line {line_no}: missing global_episode_id")
120
+
121
+ frames_raw = row.get("frames")
122
+ if not isinstance(frames_raw, list) or not frames_raw:
123
+ raise ValueError(f"manifest line {line_no}: missing non-empty frames")
124
+ try:
125
+ frames = [int(frame) for frame in frames_raw]
126
+ except (TypeError, ValueError) as exc:
127
+ raise ValueError(f"manifest line {line_no}: frames must be integers") from exc
128
+
129
+ image_paths_raw = row.get("image_paths")
130
+ if not isinstance(image_paths_raw, list) or len(image_paths_raw) != len(frames):
131
+ raise ValueError(f"manifest line {line_no}: image_paths must align with frames")
132
+ image_paths = [str(path) for path in image_paths_raw]
133
+ if check_files:
134
+ missing = [path for path in image_paths if not Path(path).exists()]
135
+ if missing:
136
+ preview = ", ".join(missing[:3])
137
+ raise FileNotFoundError(f"manifest line {line_no}: missing image files: {preview}")
138
+
139
+ prompt = str(row.get("vlac_cut_prompt") or "").strip()
140
+ if not prompt:
141
+ raise ValueError(f"manifest line {line_no}: missing vlac_cut_prompt")
142
+
143
+ sample_hz_raw = row.get("input_sample_hz", row.get("sample_hz", 2.0))
144
+ try:
145
+ sample_hz = float(sample_hz_raw)
146
+ except (TypeError, ValueError) as exc:
147
+ raise ValueError(f"manifest line {line_no}: invalid input_sample_hz") from exc
148
+ if sample_hz <= 0:
149
+ raise ValueError(f"manifest line {line_no}: input_sample_hz must be positive")
150
+ return gid, frames, image_paths, prompt, sample_hz
151
+
152
+
153
+ def load_model_and_processor(
154
+ *,
155
+ model_path: Path,
156
+ device_map: str,
157
+ dtype: str | None,
158
+ attn_implementation: str | None,
159
+ ):
160
+ _torch, AutoModelForImageTextToText, AutoProcessor = load_transformers_runtime()
161
+ processor = AutoProcessor.from_pretrained(str(model_path))
162
+
163
+ model_kwargs: dict[str, Any] = {
164
+ "device_map": device_map,
165
+ "dtype": dtype or "auto",
166
+ }
167
+ if attn_implementation:
168
+ model_kwargs["attn_implementation"] = attn_implementation
169
+
170
+ try:
171
+ model = AutoModelForImageTextToText.from_pretrained(str(model_path), **model_kwargs)
172
+ except TypeError as exc:
173
+ if "dtype" not in str(exc):
174
+ raise
175
+ model_kwargs["torch_dtype"] = model_kwargs.pop("dtype")
176
+ model = AutoModelForImageTextToText.from_pretrained(str(model_path), **model_kwargs)
177
+ if getattr(model, "generation_config", None) is not None:
178
+ for key in ("temperature", "top_p", "top_k"):
179
+ if hasattr(model.generation_config, key):
180
+ setattr(model.generation_config, key, None)
181
+ model.eval()
182
+ return model, processor
183
+
184
+
185
+ def infer_one(
186
+ *,
187
+ model,
188
+ processor,
189
+ image_paths: list[str],
190
+ prompt: str,
191
+ sample_hz: float,
192
+ max_new_tokens: int,
193
+ ) -> str:
194
+ messages = [
195
+ {
196
+ "role": "user",
197
+ "content": [
198
+ {"type": "video", "video": image_paths},
199
+ {"type": "text", "text": prompt},
200
+ ],
201
+ }
202
+ ]
203
+ text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
204
+ video_metadata = {
205
+ "total_num_frames": len(image_paths),
206
+ "fps": float(sample_hz),
207
+ "frames_indices": list(range(len(image_paths))),
208
+ }
209
+ inputs = processor(
210
+ text=[text],
211
+ videos=[[image_paths]],
212
+ padding=True,
213
+ return_tensors="pt",
214
+ return_metadata=True,
215
+ do_sample_frames=False,
216
+ video_metadata=video_metadata,
217
+ )
218
+ normalize_qwen3_video_grid(inputs)
219
+ inputs = inputs.to(model.device)
220
+ inputs.pop("video_metadata", None)
221
+
222
+ generated_ids = model.generate(
223
+ **inputs,
224
+ max_new_tokens=int(max_new_tokens),
225
+ do_sample=False,
226
+ )
227
+ generated_ids_trimmed = [
228
+ output_ids[len(input_ids) :] for input_ids, output_ids in zip(inputs.input_ids, generated_ids, strict=True)
229
+ ]
230
+ return str(
231
+ processor.batch_decode(
232
+ generated_ids_trimmed,
233
+ skip_special_tokens=True,
234
+ clean_up_tokenization_spaces=False,
235
+ )[0]
236
+ )
237
+
238
+
239
+ def count_token_type_spans(token_type_ids, token_type: int) -> int:
240
+ values = token_type_ids.tolist()
241
+ count = 0
242
+ previous = None
243
+ for value in values:
244
+ if value == token_type and previous != token_type:
245
+ count += 1
246
+ previous = value
247
+ return count
248
+
249
+
250
+ def normalize_qwen3_video_grid(inputs) -> None:
251
+ mm_token_type_ids = inputs.get("mm_token_type_ids")
252
+ video_grid_thw = inputs.get("video_grid_thw")
253
+ if mm_token_type_ids is None or video_grid_thw is None:
254
+ return
255
+ if len(mm_token_type_ids) != 1 or len(video_grid_thw) != 1:
256
+ return
257
+
258
+ video_span_count = count_token_type_spans(mm_token_type_ids[0], 2)
259
+ if video_span_count <= 1:
260
+ return
261
+
262
+ grid = video_grid_thw[0]
263
+ temporal = int(grid[0].item())
264
+ if temporal % video_span_count != 0:
265
+ return
266
+
267
+ split_temporal = temporal // video_span_count
268
+ expanded = grid.repeat(video_span_count, 1)
269
+ expanded[:, 0] = split_temporal
270
+ inputs["video_grid_thw"] = expanded
271
+
272
+
273
+ def main() -> int:
274
+ args = parse_args()
275
+ model_path = args.model_path.resolve()
276
+ manifest_path = args.manifest.resolve()
277
+ out_path = args.out.resolve()
278
+
279
+ if not model_path.exists():
280
+ raise SystemExit(f"Missing model path: {model_path}")
281
+ if not manifest_path.exists():
282
+ raise SystemExit(f"Missing manifest: {manifest_path}")
283
+ if args.limit is not None and args.limit <= 0:
284
+ raise SystemExit("--limit must be positive when provided")
285
+
286
+ done = existing_global_episode_ids(out_path) if args.resume else set()
287
+ out_path.parent.mkdir(parents=True, exist_ok=True)
288
+ mode = "a" if args.resume else "w"
289
+
290
+ model, processor = load_model_and_processor(
291
+ model_path=model_path,
292
+ device_map=str(args.device_map),
293
+ dtype=args.dtype,
294
+ attn_implementation=args.attn_implementation,
295
+ )
296
+
297
+ processed = 0
298
+ skipped = 0
299
+ with out_path.open(mode, encoding="utf-8") as out_f:
300
+ for line_no, row in iter_jsonl(manifest_path):
301
+ gid, frames, image_paths, prompt, sample_hz = require_manifest_row(
302
+ row,
303
+ line_no,
304
+ check_files=bool(args.check_files),
305
+ )
306
+ if gid in done:
307
+ skipped += 1
308
+ continue
309
+ if args.limit is not None and processed >= args.limit:
310
+ break
311
+
312
+ response = infer_one(
313
+ model=model,
314
+ processor=processor,
315
+ image_paths=image_paths,
316
+ prompt=prompt,
317
+ sample_hz=sample_hz,
318
+ max_new_tokens=int(args.max_new_tokens),
319
+ )
320
+ out_f.write(
321
+ json.dumps(
322
+ {
323
+ "global_episode_id": gid,
324
+ "frames": frames,
325
+ "response": str(response or ""),
326
+ },
327
+ ensure_ascii=False,
328
+ )
329
+ + "\n"
330
+ )
331
+ out_f.flush()
332
+ processed += 1
333
+ print(f"processed={processed} global_episode_id={gid}", flush=True)
334
+
335
+ print(
336
+ json.dumps(
337
+ {
338
+ "manifest": str(manifest_path),
339
+ "out": str(out_path),
340
+ "backend": "transformers",
341
+ "processed": processed,
342
+ "skipped_existing": skipped,
343
+ },
344
+ ensure_ascii=False,
345
+ indent=2,
346
+ )
347
+ )
348
+ return 0
349
+
350
+
351
+ if __name__ == "__main__":
352
+ raise SystemExit(main())