yhl826459 Claude Code commited on
Commit
e6d5a90
·
verified ·
1 Parent(s): 4e841fe

Fix the review's four findings in the VISOR v1.1 acceptance tools

Browse files

9 files rewritten, 0 added; the release's file set is unchanged (35726 paths).

Every finding is a checker gap or an evidence-overwrite path, not a defect in the published data. verify now resolves each contact relation target in the same frame (identity, name and source string), pins the raw archive identity for full runs, refuses an empty selection/census, and compares the complete source attribute set; validate and read_sequence apply the same relation and attribute checks. Non-formal runs can no longer write the publication manifest, the acceptance report, the review pages or the reader sweep. Defect-injection regression suite: tmp/visor-tools/test_v1_1_review_fixes.py (24 cases). Acceptance steps 2-8 re-run: data/** byte-identical, 0 files added or deleted.

Co-Authored-By: Claude Code <noreply@anthropic.com>

EPIC-KITCHENS-VISOR/shared-v1.1/doc/FULL_MIGRATION_SUMMARY.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "phase": "local_finalized_not_uploaded",
3
  "completed_views": 179,
4
- "created_utc": "2026-10-17T04:49:39.044050+00:00",
5
  "dataset_id": "EPIC-KITCHENS-VISOR",
6
  "release_id": "shared-v1.1",
7
  "final_root": "/data1/yanghonglei/Datasets/hand-warehouse/EPIC-KITCHENS-VISOR/shared-v1.1",
@@ -101,11 +101,11 @@
101
  "script/provenance/operations/build_visor_docs.py": "5a3e45bc7957975444f41b58dc84ca63b877312769f8d7c54ede22e5c631dc9e",
102
  "script/visor_v1_1/convert.py": "edf64d192966167b4598ab6840ca458948e27f415c25c752e211d3229c26612b",
103
  "script/visor_v1_1/media.py": "f6372167e59fe2be1d8786fd14aee5c3edfe8297d9d126848a09d2adab485650",
104
- "script/visor_v1_1/read_sequence.py": "24489f7b99398045af6dc84bc4f6691ee9e2e2e0b33c63548d99a9a712a248bc",
105
- "script/visor_v1_1/render.py": "b11ac823138bd5cb44aaa3c55e463ede97a810d8750a97afd64c9c7c42e3c554",
106
- "script/visor_v1_1/validate.py": "22a805a6a521a85039d0808e6fdf747a7d2c09cbd56024da4a5f64f8d96cad53",
107
- "script/visor_v1_1/verify.py": "0a70793b23214fd4d75f253e6ed46928f7e4aa2c94e2b13ec3e7a84d15e348a2",
108
- "script/visor_v1_1/visor_common.py": "e5a382a38430f487e27196fa0a8fa3e4c1bfe3a3e8aafad77b8b20c9d8c06ae6",
109
  "script/visor_v1_1/warehouse.py": "fe62f79f9228475e23764d57c923e781422951ad5ed6680337bf67e120a63db2"
110
  },
111
  "release_spec": {
@@ -199,7 +199,7 @@
199
  "source_files": 1,
200
  "source_bytes": 30572126007,
201
  "target_files": 35725,
202
- "target_bytes": 20364233254,
203
  "tree_totals_scope": "source_files/source_bytes are the one deposit archive the release was converted from (the archive is the source; no v1.0 tree exists). target_files counts every release file except this one, and target_bytes their bytes, with bytecode caches (__pycache__/) excluded exactly as the release manifest excludes them. The manifest is built last, so it also covers what is written after this line: its entry count is target_files plus manifest_extra_files.count, and its byte total exceeds target_bytes by this file plus the size deltas of the files rewritten after it (doc/validation/validate_report.json, which step 8 rewrites on both paths, and doc/CONTRACT.md, which step 7 rewrites from the canonical spec plus this dataset's section -- on a first full run the doc set does not exist yet, so its whole size is the delta). The review pages are rendered in step 5, before this file, so they are on both sides of that comparison",
204
  "manifest_extra_files": {
205
  "count": 1,
@@ -451,7 +451,7 @@
451
  },
452
  "failed": [],
453
  "passed": true,
454
- "wall_seconds": 128.58,
455
  "tool": "script/visor_v1_1/read_sequence.py",
456
  "driver": "tmp/visor-tools/read_sequence_sweep.py (outside the release)",
457
  "scope": "shared-v1.1 read through the released reader over its declared paths; RGB demuxed and first/last frame decoded, no polygon compared and no mask judged; the raw deposit is not opened here"
 
1
  {
2
  "phase": "local_finalized_not_uploaded",
3
  "completed_views": 179,
4
+ "created_utc": "2026-10-20T05:54:00.964996+00:00",
5
  "dataset_id": "EPIC-KITCHENS-VISOR",
6
  "release_id": "shared-v1.1",
7
  "final_root": "/data1/yanghonglei/Datasets/hand-warehouse/EPIC-KITCHENS-VISOR/shared-v1.1",
 
101
  "script/provenance/operations/build_visor_docs.py": "5a3e45bc7957975444f41b58dc84ca63b877312769f8d7c54ede22e5c631dc9e",
102
  "script/visor_v1_1/convert.py": "edf64d192966167b4598ab6840ca458948e27f415c25c752e211d3229c26612b",
103
  "script/visor_v1_1/media.py": "f6372167e59fe2be1d8786fd14aee5c3edfe8297d9d126848a09d2adab485650",
104
+ "script/visor_v1_1/read_sequence.py": "91617a19aeda714b3e71164b62be6693c9d26c7f765d19ec078af21b24ce0c14",
105
+ "script/visor_v1_1/render.py": "f1d15c10839a46aae35f910dc54563c90762f1d711f764a8de28b321969f6659",
106
+ "script/visor_v1_1/validate.py": "613678ea8ec9f8e4d48e1e6db9a2e1c0f2ca3f8f4f5df738843925b23819c40b",
107
+ "script/visor_v1_1/verify.py": "e3722458a600bf0cd84c21c5a9ad357ace95d8fa2107a598e22bdf330e52d4c7",
108
+ "script/visor_v1_1/visor_common.py": "7ca3958f0c28b25ddb5649439e24c9acbe4ab55559c42d9f157e12d940b56366",
109
  "script/visor_v1_1/warehouse.py": "fe62f79f9228475e23764d57c923e781422951ad5ed6680337bf67e120a63db2"
110
  },
111
  "release_spec": {
 
199
  "source_files": 1,
200
  "source_bytes": 30572126007,
201
  "target_files": 35725,
202
+ "target_bytes": 20364259941,
203
  "tree_totals_scope": "source_files/source_bytes are the one deposit archive the release was converted from (the archive is the source; no v1.0 tree exists). target_files counts every release file except this one, and target_bytes their bytes, with bytecode caches (__pycache__/) excluded exactly as the release manifest excludes them. The manifest is built last, so it also covers what is written after this line: its entry count is target_files plus manifest_extra_files.count, and its byte total exceeds target_bytes by this file plus the size deltas of the files rewritten after it (doc/validation/validate_report.json, which step 8 rewrites on both paths, and doc/CONTRACT.md, which step 7 rewrites from the canonical spec plus this dataset's section -- on a first full run the doc set does not exist yet, so its whole size is the delta). The review pages are rendered in step 5, before this file, so they are on both sides of that comparison",
204
  "manifest_extra_files": {
205
  "count": 1,
 
451
  },
452
  "failed": [],
453
  "passed": true,
454
+ "wall_seconds": 175.53,
455
  "tool": "script/visor_v1_1/read_sequence.py",
456
  "driver": "tmp/visor-tools/read_sequence_sweep.py (outside the release)",
457
  "scope": "shared-v1.1 read through the released reader over its declared paths; RGB demuxed and first/last frame decoded, no polygon compared and no mask judged; the raw deposit is not opened here"
EPIC-KITCHENS-VISOR/shared-v1.1/doc/PUBLICATION_PLAN.md CHANGED
@@ -37,13 +37,13 @@
37
 
38
  - **只新增 `EPIC-KITCHENS-VISOR/shared-v1.1/`**:`data/`(179 个视图)+ `script/visor_v1_1/`(含 `spec/` 原件)+ `doc/`。`raw/` 与其他数据集路径**一字不动**。
39
  - 媒体是**源 JPEG 码流的原样封装**(`media.py` 的包级 stream copy,不重编码、不缩放、不旋转),179 个视图的 `observation/rgb.mkv` 合计约等于源那 179 个帧图 zip 的未压缩字节 19,223,392,600 B。数值侧**零 bundle**:本发布唯一的 `.pt` 是逐帧独立有效性(`rgb_valid.pt`、`segment/mask_valid.pt`、`contact/relations_valid.pt`)。
40
- - **LFS 跟踪行**:仓库既有的 `.gitattributes` 已有通用 glob `*.zip`、`*.pt`、`*.png`、`*.jpg`(raw 整包与全部 `*_valid.pt` 因此已被覆盖),但 `*.mkv` **不是**通用 glob——每个带媒体的数据集各有一行 `<dataset>/shared-v1.1/**/*.mkv`。所以本次需要补**一行**:
41
 
42
  ```
43
  EPIC-KITCHENS-VISOR/shared-v1.1/**/*.mkv filter=lfs diff=lfs merge=lfs -text
44
  ```
45
 
46
- `doc/`、`script/` 与全部 JSON/JSONL/HTML 走普通 git(这些扩展名不在 LFS 里),逐字节可比、可 diff。
47
  - **发布清单不是发布内容**:它按已发布 H2O、dex-ycb 的约定保存在发布树**之外**的 `tmp/visor-tools/PUBLISH_MANIFEST.json`(树内副本无法描述自己的最终字节,见 `script/visor_v1_1/README.md` 的「收尾验收顺序」)。清单在最后一步由 `validate.py` 生成,覆盖它之前落盘的每一份最终字节。
48
 
49
  ## 工具链与验收顺序
 
37
 
38
  - **只新增 `EPIC-KITCHENS-VISOR/shared-v1.1/`**:`data/`(179 个视图)+ `script/visor_v1_1/`(含 `spec/` 原件)+ `doc/`。`raw/` 与其他数据集路径**一字不动**。
39
  - 媒体是**源 JPEG 码流的原样封装**(`media.py` 的包级 stream copy,不重编码、不缩放、不旋转),179 个视图的 `observation/rgb.mkv` 合计约等于源那 179 个帧图 zip 的未压缩字节 19,223,392,600 B。数值侧**零 bundle**:本发布唯一的 `.pt` 是逐帧独立有效性(`rgb_valid.pt`、`segment/mask_valid.pt`、`contact/relations_valid.pt`)。
40
+ - **LFS 跟踪行**:仓库既有的 `.gitattributes` 已有通用 glob `*.zip`、`*.pt`、`*.png`、`*.jpg`(raw 整包与全部 `*_valid.pt` 因此已被覆盖),但 `*.mkv` **不是**通用 glob——每个带媒体的数据集各有一行 `<dataset>/shared-v1.1/**/*.mkv`。本次手工补的是这一行:
41
 
42
  ```
43
  EPIC-KITCHENS-VISOR/shared-v1.1/**/*.mkv filter=lfs diff=lfs merge=lfs -text
44
  ```
45
 
46
+ 但这**不是**分支上的全部 VISOR 行:实测 PR 分支的 `.gitattributes` 有 **27** 条 VISOR 行 = 上面 1 条 MKV glob + Hub 在推送后自动追加的 **26** 条逐路径行(23 个 `annotation/segment/polygons.jsonl` + 3 个复核页 HTML,都是 >10 MiB、现有 glob 覆盖不到的文件)。`script/`、`.json` 与低于 10 MiB 的 JSONL/HTML 走普通 git,逐字节可比、可 diff;超过 10 MiB 的 JSONL/HTML 由 Hub 以**逐路径** LFS 跟踪。这 3 个复核页在普通克隆里是 LFS 指针,所以本轮**不**以它们作完整视觉验收依据(页面在带 LFS 的检出里可正常查看)。这份计划最初只写了「补一行」,是当时的计划而非事后实测,现按实测更正。
47
  - **发布清单不是发布内容**:它按已发布 H2O、dex-ycb 的约定保存在发布树**之外**的 `tmp/visor-tools/PUBLISH_MANIFEST.json`(树内副本无法描述自己的最终字节,见 `script/visor_v1_1/README.md` 的「收尾验收顺序」)。清单在最后一步由 `validate.py` 生成,覆盖它之前落盘的每一份最终字节。
48
 
49
  ## 工具链与验收顺序
EPIC-KITCHENS-VISOR/shared-v1.1/doc/validation/read_sequence_sweep.json CHANGED
@@ -26,7 +26,7 @@
26
  "view_types": [
27
  "ego"
28
  ],
29
- "wall_seconds": 128.58,
30
  "accepted": true,
31
  "failed": [],
32
  "records": [
 
26
  "view_types": [
27
  "ego"
28
  ],
29
+ "wall_seconds": 175.53,
30
  "accepted": true,
31
  "failed": [],
32
  "records": [
EPIC-KITCHENS-VISOR/shared-v1.1/script/visor_v1_1/README.md CHANGED
@@ -178,7 +178,7 @@ python shared-v1.1/script/visor_v1_1/validate.py --expect-views 179 --rewrite-ch
178
  - **许可证在源里就不一致,如实并列。** `README.txt` 声明 CC BY-NC 4.0,而同一份 `.info.json` 声明 Non-Commercial Government Licence。发布文档把两者并列写出,不替数据源选一个(记录在 `VISOR-deposit-record.json` 的 `declared_license`)。
179
  - **源自己的两处不干净,原样保留、不做清洗。** `on_which_hand` 在源里是列表或字符串两种类型,且存在官方拼写错误 `["left hand", "rigth hand"]`(13 条,`right` 拼成 `rigth`);另有 34 条直接写字符串 `"inconclusive"`。这些都在 `instances.jsonl` 的 `source_attributes` 里逐字保留——清洗会改语义。
180
  - **状态标志的含义要按字面读。** 逐视图的 `pilot: false`、`pilot_complete: true`、`pilot_human_review: "not_applicable"` 说的是本数据集没有派洛特阶段(没有过一版部分发布);`production_complete: true` 说的是「这个视图来自生产转换、不是试跑产物」,不是「整个发布已经验收完成」;发布级状态在汇总与清单里。`full_output_human_review` 仍是 `"pending"`、`upload_authorized` 仍是 `false`——人工真看过之前一个字都不改。
181
- - **反向对照(往副本里注入缺陷、确认校验器逐条具名抓到)还没有做。** ARCTIC 有一份 `negative_controls.txt`,本数据集目前没有。这里的对应证据是 `verify.py` 对 raw 档案本身的源真值比对——它读真实源字节、不是自证——但那证明的是「转换忠实」,不证明「校验器的检查不空转」。要做就做成往硬链接副本里注入缺陷、逐项确认具名失败的脚本,跑完再并入 `doc/validation/`。
182
 
183
  ## 证据
184
 
 
178
  - **许可证在源里就不一致,如实并列。** `README.txt` 声明 CC BY-NC 4.0,而同一份 `.info.json` 声明 Non-Commercial Government Licence。发布文档把两者并列写出,不替数据源选一个(记录在 `VISOR-deposit-record.json` 的 `declared_license`)。
179
  - **源自己的两处不干净,原样保留、不做清洗。** `on_which_hand` 在源里是列表或字符串两种类型,且存在官方拼写错误 `["left hand", "rigth hand"]`(13 条,`right` 拼成 `rigth`);另有 34 条直接写字符串 `"inconclusive"`。这些都在 `instances.jsonl` 的 `source_attributes` 里逐字保留——清洗会改语义。
180
  - **状态标志的含义要按字面读。** 逐视图的 `pilot: false`、`pilot_complete: true`、`pilot_human_review: "not_applicable"` 说的是本数据集没有派洛特阶段(没有过一版部分发布);`production_complete: true` 说的是「这个视图来自生产转换、不是试跑产物」,不是「整个发布已经验收完成」;发布级状态在汇总与清单里。`full_output_human_review` 仍是 `"pending"`、`upload_authorized` 仍是 `false`——人工真看过之前一个字都不改。
181
+ - **反向对照已补(PR #9 审查后)。** ARCTIC 有一份 `negative_controls.txt`;本数据集的对应物是**树外**的缺陷注入套件 `tmp/visor-tools/test_v1_1_review_fixes.py`(不随发布,因为它要改写发布副本)。它逐条复现审查提出的四个缺陷——接触目标错配、空归档/空选择被当成完整验收、源属性丢失、局部运行覆盖正式证据——并断言校验器**具名失败**;每组都用「未注入应通过、注入后必须失败」的正反例。`verify.py` 对 raw 档案的源真值比对证明「转换忠实」,这套件证明「检查器不空转」,两者不能互相替代。
182
 
183
  ## 证据
184
 
EPIC-KITCHENS-VISOR/shared-v1.1/script/visor_v1_1/read_sequence.py CHANGED
@@ -246,13 +246,14 @@ def read_view(view: Path, table: dict) -> dict:
246
  problem(f"rgb: decoded {list(shape[:2])}, storage declares {encoded}")
247
 
248
  #: the per-frame tables, which only an annotated view has
249
- frame_entities, objects = {}, set()
250
  if (components.get("segment") or {}).get("available", False):
251
- frame_entities, objects = check_segment(view, meta, rows, table, record, problem)
 
252
  elif (view / "annotation" / "segment").exists():
253
  problem("segment: not declared available but annotation/segment/ exists")
254
  if (components.get("relations") or {}).get("available", False):
255
- check_relations(view, meta, rows, frame_entities, record, problem)
256
  elif (view / "annotation" / "contact").exists():
257
  problem("relations: not declared available but annotation/contact/ exists")
258
  if (view / POLYGONS_REF).is_file() and not frame_entities:
@@ -318,8 +319,8 @@ def check_segment(view: Path, meta: dict, rows: list, table: dict, record: dict,
318
  if not (len(polygons) == len(instances) == frames):
319
  problem(f"segment: {len(polygons)} polygon rows and {len(instances)} instance rows "
320
  f"for {frames} frames")
321
- return {}, set()
322
- frame_entities, objects = {}, set()
323
  shapes_total = 0
324
  for index, (shape_row, label_row) in enumerate(zip(polygons, instances)):
325
  if shape_row.get("frame_index") != index or label_row.get("frame_index") != index:
@@ -338,6 +339,7 @@ def check_segment(view: Path, meta: dict, rows: list, table: dict, record: dict,
338
  subsequence = (rows[index].get("source_locator") or {}).get("subsequence") \
339
  if index < len(rows) else None
340
  frame_entities[index] = set()
 
341
  for label, shape in zip(labels, shapes):
342
  attributes = label.get("source_attributes") or {}
343
  name = attributes.get("name")
@@ -363,6 +365,12 @@ def check_segment(view: Path, meta: dict, rows: list, table: dict, record: dict,
363
  f"the (subsequence, entity name) identity {expected!r}")
364
  if label.get("entity_id"):
365
  frame_entities[index].add(label["entity_id"])
 
 
 
 
 
 
366
  for ring in shape.get("polygons") or []:
367
  shapes_total += 1
368
  if not isinstance(ring, list) or len(ring) < 3:
@@ -375,11 +383,11 @@ def check_segment(view: Path, meta: dict, rows: list, table: dict, record: dict,
375
  record["counts"].update({"rings": shapes_total, "objects": len(objects),
376
  "annotated_frames": sum(1 for index in frame_entities
377
  if frame_entities[index])})
378
- return frame_entities, objects
379
 
380
 
381
  def check_relations(view: Path, meta: dict, rows: list, frame_entities: dict,
382
- record: dict, problem) -> None:
383
  """The contact table: three states plus "no record", original string preserved."""
384
  path = view / RELATIONS_REF
385
  relations = vc.read_jsonl(path) if path.is_file() else []
@@ -416,20 +424,44 @@ def check_relations(view: Path, meta: dict, rows: list, frame_entities: dict,
416
  elif status == "positive":
417
  if not HEX32.match(value):
418
  problem(f"relations: frame {frame} positive contact drops the source id")
419
- if relation.get("object_id") not in frame_entities.get(frame, set()):
420
- problem(f"relations: frame {frame} target {relation.get('object_id')!r} "
421
- f"does not resolve inside the same frame")
 
 
 
 
 
 
 
 
422
  elif vc.CONTACT_STATUS.get(value) != status:
423
  problem(f"relations: frame {frame} source string {value!r} means a different "
424
  f"state than {status!r}")
425
  if locator.get("source_frame_name") != rows[frame].get("source_frame_id"):
426
  problem(f"relations: frame {frame} names source frame "
427
  f"{locator.get('source_frame_name')!r}")
 
 
 
428
  subject = relation.get("subject_id")
429
  if subject not in frame_entities.get(frame, set()):
430
  problem(f"relations: frame {frame} subject {subject!r} is not in that frame")
431
  elif not is_contact_subject(subject):
432
  problem(f"relations: frame {frame} subject {subject!r} is not a hand or glove")
 
 
 
 
 
 
 
 
 
 
 
 
 
433
  record["counts"].update({f"contact_{name}": value for name, value in counts.items()})
434
 
435
 
@@ -492,6 +524,12 @@ def main(argv=None):
492
 
493
  table = load_source_table()
494
  views = view_dirs(args.root, args.sequence)
 
 
 
 
 
 
495
  records = [read_view(view, table) for view in views]
496
 
497
  problems = check_recording(records)
@@ -531,7 +569,7 @@ def main(argv=None):
531
  "paths, media included; not visual acceptance, and not an independent "
532
  "check against the raw deposit (the converter owns that evidence)",
533
  }
534
- if args.report:
535
  args.report.parent.mkdir(parents=True, exist_ok=True)
536
  args.report.write_text(json.dumps(report, ensure_ascii=False, indent=2),
537
  encoding="utf-8")
 
246
  problem(f"rgb: decoded {list(shape[:2])}, storage declares {encoded}")
247
 
248
  #: the per-frame tables, which only an annotated view has
249
+ frame_entities, frame_labels, objects = {}, {}, set()
250
  if (components.get("segment") or {}).get("available", False):
251
+ frame_entities, frame_labels, objects = check_segment(
252
+ view, meta, rows, table, record, problem)
253
  elif (view / "annotation" / "segment").exists():
254
  problem("segment: not declared available but annotation/segment/ exists")
255
  if (components.get("relations") or {}).get("available", False):
256
+ check_relations(view, meta, rows, frame_entities, frame_labels, record, problem)
257
  elif (view / "annotation" / "contact").exists():
258
  problem("relations: not declared available but annotation/contact/ exists")
259
  if (view / POLYGONS_REF).is_file() and not frame_entities:
 
319
  if not (len(polygons) == len(instances) == frames):
320
  problem(f"segment: {len(polygons)} polygon rows and {len(instances)} instance rows "
321
  f"for {frames} frames")
322
+ return {}, {}, set()
323
+ frame_entities, frame_labels, objects = {}, {}, set()
324
  shapes_total = 0
325
  for index, (shape_row, label_row) in enumerate(zip(polygons, instances)):
326
  if shape_row.get("frame_index") != index or label_row.get("frame_index") != index:
 
339
  subsequence = (rows[index].get("source_locator") or {}).get("subsequence") \
340
  if index < len(rows) else None
341
  frame_entities[index] = set()
342
+ frame_labels[index] = {}
343
  for label, shape in zip(labels, shapes):
344
  attributes = label.get("source_attributes") or {}
345
  name = attributes.get("name")
 
365
  f"the (subsequence, entity name) identity {expected!r}")
366
  if label.get("entity_id"):
367
  frame_entities[index].add(label["entity_id"])
368
+ source_id = label.get("source_instance_id")
369
+ if isinstance(source_id, str):
370
+ if source_id in frame_labels[index]:
371
+ problem(f"segment: frame {index} repeats source instance {source_id}")
372
+ frame_labels[index][source_id] = {
373
+ "entity_id": label.get("entity_id"), "name": name}
374
  for ring in shape.get("polygons") or []:
375
  shapes_total += 1
376
  if not isinstance(ring, list) or len(ring) < 3:
 
383
  record["counts"].update({"rings": shapes_total, "objects": len(objects),
384
  "annotated_frames": sum(1 for index in frame_entities
385
  if frame_entities[index])})
386
+ return frame_entities, frame_labels, objects
387
 
388
 
389
  def check_relations(view: Path, meta: dict, rows: list, frame_entities: dict,
390
+ frame_labels: dict, record: dict, problem) -> None:
391
  """The contact table: three states plus "no record", original string preserved."""
392
  path = view / RELATIONS_REF
393
  relations = vc.read_jsonl(path) if path.is_file() else []
 
424
  elif status == "positive":
425
  if not HEX32.match(value):
426
  problem(f"relations: frame {frame} positive contact drops the source id")
427
+ #: the row must point at the instance the source id resolves to, not
428
+ #: merely at some instance that happens to exist in the frame
429
+ #: (PR #9 review finding 1)
430
+ target = frame_labels.get(frame, {}).get(value)
431
+ if target is None:
432
+ problem(f"relations: frame {frame} positive target {value!r} is not a "
433
+ f"source instance of the same frame")
434
+ elif relation.get("object_id") != target["entity_id"]:
435
+ problem(f"relations: frame {frame} positive target "
436
+ f"{relation.get('object_id')!r} is not the source instance's "
437
+ f"entity {target['entity_id']!r} ({value})")
438
  elif vc.CONTACT_STATUS.get(value) != status:
439
  problem(f"relations: frame {frame} source string {value!r} means a different "
440
  f"state than {status!r}")
441
  if locator.get("source_frame_name") != rows[frame].get("source_frame_id"):
442
  problem(f"relations: frame {frame} names source frame "
443
  f"{locator.get('source_frame_name')!r}")
444
+ if locator.get("source_annotation_index") != rows[frame].get("source_annotation_index"):
445
+ problem(f"relations: frame {frame} points at source annotation "
446
+ f"{locator.get('source_annotation_index')!r}")
447
  subject = relation.get("subject_id")
448
  if subject not in frame_entities.get(frame, set()):
449
  problem(f"relations: frame {frame} subject {subject!r} is not in that frame")
450
  elif not is_contact_subject(subject):
451
  problem(f"relations: frame {frame} subject {subject!r} is not a hand or glove")
452
+ source_id = locator.get("source_instance_id")
453
+ subject_label = frame_labels.get(frame, {}).get(source_id)
454
+ if subject_label is None:
455
+ problem(f"relations: frame {frame} does not name a source subject instance "
456
+ f"of its own frame ({source_id!r})")
457
+ else:
458
+ if subject != subject_label["entity_id"]:
459
+ problem(f"relations: frame {frame} subject {subject!r} is not the source "
460
+ f"instance's entity {subject_label['entity_id']!r} ({source_id})")
461
+ if locator.get("subject_entity_name") != subject_label["name"]:
462
+ problem(f"relations: frame {frame} subject name "
463
+ f"{locator.get('subject_entity_name')!r} is not the source "
464
+ f"instance's name {subject_label['name']!r} ({source_id})")
465
  record["counts"].update({f"contact_{name}": value for name, value in counts.items()})
466
 
467
 
 
524
 
525
  table = load_source_table()
526
  views = view_dirs(args.root, args.sequence)
527
+ if not views:
528
+ raise SystemExit(f"{args.root}/data/{args.sequence} has no view directory: "
529
+ "a run over nothing is not a pass")
530
+ #: 单序列读取器永远不是发布级验收:它的报告不得覆盖正式证据(finding 4)。
531
+ if args.report is not None:
532
+ vc.guard_output(args.report, False, set(), "read_sequence")
533
  records = [read_view(view, table) for view in views]
534
 
535
  problems = check_recording(records)
 
569
  "paths, media included; not visual acceptance, and not an independent "
570
  "check against the raw deposit (the converter owns that evidence)",
571
  }
572
+ if args.report is not None:
573
  args.report.parent.mkdir(parents=True, exist_ok=True)
574
  args.report.write_text(json.dumps(report, ensure_ascii=False, indent=2),
575
  encoding="utf-8")
EPIC-KITCHENS-VISOR/shared-v1.1/script/visor_v1_1/render.py CHANGED
@@ -67,9 +67,13 @@ from visor_common import (
67
  REGISTRY,
68
  RELEASE_ID,
69
  RELATIONS_REF,
 
 
70
  check_view,
 
71
  load,
72
  read_jsonl,
 
73
  save,
74
  )
75
  from warehouse import Registry
@@ -1185,7 +1189,19 @@ def main(argv=None):
1185
  parser.error("at most 8 workers and one decoder thread each")
1186
 
1187
  root = args.root.resolve()
1188
- destination = (args.out or root / "doc/validation").resolve()
 
 
 
 
 
 
 
 
 
 
 
 
1189
 
1190
  allocation = {"test": 2, "val": 4, "train": 6}
1191
  if sum(allocation.values()) != args.reference_sequences:
@@ -1195,7 +1211,7 @@ def main(argv=None):
1195
  )
1196
 
1197
  facts = {}
1198
- if args.views:
1199
  views = []
1200
  for token in args.views:
1201
  sequence, _, camera = token.partition("/")
@@ -1278,20 +1294,39 @@ def main(argv=None):
1278
  )
1279
  )
1280
 
1281
- report = {
1282
- "review_kind": "全量后抽样",
1283
- "views": len(views),
1284
- "sequences": len(sequences),
1285
- "dataset_id": DATASET_ID,
1286
- "release_id": RELEASE_ID,
1287
- "sampling": sampling,
1288
- "wall_seconds": round(time.monotonic() - start, 3),
1289
- "decode_scope": DECODE_SCOPE,
1290
- "reports": reports,
1291
- "scope": "post-full sampled complete sequences, all cameras (one ego view per "
1292
- "sequence), read directly from the release through visor_common.check_view; "
1293
- "evidence for human acceptance, not training input; manual review pending",
1294
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1295
  save(destination / "V1_1_VALIDATION.json", report)
1296
 
1297
  links = sorted(p.name for p in destination.glob("*.html") if p.name != "index.html")
@@ -1333,17 +1368,29 @@ def main(argv=None):
1333
  + "</td><td>" + html.escape(str(entry["camera"]["model"])) + "</td></tr>"
1334
  for entry in sorted(reports, key=lambda e: e["sequence_id"])
1335
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1336
  index = (
1337
  '<!doctype html><html lang="zh"><meta charset="utf-8">'
1338
  "<title>EPIC-KITCHENS-VISOR shared-v1.1 review</title><style>" + index_css + "</style>"
1339
- "<h1>EPIC-KITCHENS-VISOR shared-v1.1 全量后抽样人工复查</h1>"
1340
- "<p>数值按字节一致(CONTRACT §6 第 2 条);媒体不重新编码(第 4 条)。本页是第 5 条"
1341
- "要求的『用新读取器运行代表性完整序列』那一步:抽样规则、种子与每一段被抽中的原因见 "
1342
- "<code>V1_1_VALIDATION.json</code>,本页所列视图即全部入选视图:"
1343
- + str(len(views)) + " 个视图 / " + str(len(sequences)) + " 段,共抽样 "
1344
- + str(sampled) + " 帧,其中 " + str(unannotated) + " 段只有 RGB 与帧序(官方测试"
1345
- "标注未发布)。所有视图都没有相机标定(camera.model=unknown),页面因此不做任何 "
1346
- "3D 投影,叠加的是源自己的像素多边形。</p>"
1347
  + colour_legend()
1348
  + "<p>逐视图页面的每帧面板与逐帧数值都在页面内;抽样帧之外的帧不在页面里。"
1349
  "分割与接触的完整坐标在发布树的 <code>data/&lt;sequence&gt;/ego/annotation/</code> "
 
67
  REGISTRY,
68
  RELEASE_ID,
69
  RELATIONS_REF,
70
+ RELEASE_ROOT,
71
+ TMP_ROOT,
72
  check_view,
73
+ guard_directory,
74
  load,
75
  read_jsonl,
76
+ same_path,
77
  save,
78
  )
79
  from warehouse import Registry
 
1189
  parser.error("at most 8 workers and one decoder thread each")
1190
 
1191
  root = args.root.resolve()
1192
+ #: 发布级复核 = 正式树的抽样运行。``--views`` 是局部重渲:它既不是抽样,也不得
1193
+ #: 默认落进正式复核目录、更不得改写正式报告(PR #9 审查 finding 4)。
1194
+ explicit = args.views is not None
1195
+ formal = same_path(root, RELEASE_ROOT) and not explicit
1196
+ if args.out is not None:
1197
+ destination = args.out.resolve()
1198
+ elif formal:
1199
+ destination = (root / "doc" / "validation").resolve()
1200
+ else:
1201
+ destination = (TMP_ROOT / "render-partial").resolve()
1202
+ #: 在 ProcessPoolExecutor / mkdir 之前判定:局部运行不能借用正式证据目录,
1203
+ #: 别名、符号链接、硬链接都按解析后的实际路径拒绝。
1204
+ guard_directory(destination, formal, {"review pages"}, "render")
1205
 
1206
  allocation = {"test": 2, "val": 4, "train": 6}
1207
  if sum(allocation.values()) != args.reference_sequences:
 
1211
  )
1212
 
1213
  facts = {}
1214
+ if explicit:
1215
  views = []
1216
  for token in args.views:
1217
  sequence, _, camera = token.partition("/")
 
1294
  )
1295
  )
1296
 
1297
+ if explicit:
1298
+ #: 显式选视图的重渲不是发布级复核证据:``review_kind`` 明确区分,且不写
1299
+ #: ``sampling.seed``/``selections``,汇总工具无法把它当成抽样证据。
1300
+ report = {
1301
+ "review_kind": "显式视图重渲",
1302
+ "partial": True,
1303
+ "views": len(views),
1304
+ "sequences": len(sequences),
1305
+ "dataset_id": DATASET_ID,
1306
+ "release_id": RELEASE_ID,
1307
+ "sampling": sampling,
1308
+ "wall_seconds": round(time.monotonic() - start, 3),
1309
+ "decode_scope": DECODE_SCOPE,
1310
+ "reports": reports,
1311
+ "scope": "explicit view re-render; not the release-wide sampled review and not "
1312
+ "acceptance evidence; manual review pending",
1313
+ "output": str(destination),
1314
+ }
1315
+ else:
1316
+ report = {
1317
+ "review_kind": "全量后抽样",
1318
+ "views": len(views),
1319
+ "sequences": len(sequences),
1320
+ "dataset_id": DATASET_ID,
1321
+ "release_id": RELEASE_ID,
1322
+ "sampling": sampling,
1323
+ "wall_seconds": round(time.monotonic() - start, 3),
1324
+ "decode_scope": DECODE_SCOPE,
1325
+ "reports": reports,
1326
+ "scope": "post-full sampled complete sequences, all cameras (one ego view per "
1327
+ "sequence), read directly from the release through visor_common.check_view; "
1328
+ "evidence for human acceptance, not training input; manual review pending",
1329
+ }
1330
  save(destination / "V1_1_VALIDATION.json", report)
1331
 
1332
  links = sorted(p.name for p in destination.glob("*.html") if p.name != "index.html")
 
1368
  + "</td><td>" + html.escape(str(entry["camera"]["model"])) + "</td></tr>"
1369
  for entry in sorted(reports, key=lambda e: e["sequence_id"])
1370
  )
1371
+ if explicit:
1372
+ heading = "显式视图重渲(非发布证据)"
1373
+ intro = (
1374
+ "<p>本页由 <code>--views</code> 指定的视图生成,只用于复查这些视图;"
1375
+ "它不是发布级抽样复核,也不作为验收证据。抽样规则与入选序列见正式树的 "
1376
+ "<code>doc/validation/V1_1_VALIDATION.json</code>。</p>"
1377
+ )
1378
+ else:
1379
+ heading = "全量后抽样人工复查"
1380
+ intro = (
1381
+ "<p>数值按字节一致(CONTRACT §6 第 2 条);媒体不重新编码(第 4 条)。本页是第 5 条"
1382
+ "要求的『用新读取器运行代表性完整序列』那一步:抽样规则、种子与每一段被抽中的原因见 "
1383
+ "<code>V1_1_VALIDATION.json</code>,本页所列视图即全部入选视图:"
1384
+ + str(len(views)) + " 个视图 / " + str(len(sequences)) + " 段,共抽样 "
1385
+ + str(sampled) + " 帧,其中 " + str(unannotated) + " 段只有 RGB 与帧序(官方测试"
1386
+ "标注未发布)。所有视图都没有相机标定(camera.model=unknown),页面因此不做任何 "
1387
+ "3D 投影,叠加的是源自己的像素多边形。</p>"
1388
+ )
1389
  index = (
1390
  '<!doctype html><html lang="zh"><meta charset="utf-8">'
1391
  "<title>EPIC-KITCHENS-VISOR shared-v1.1 review</title><style>" + index_css + "</style>"
1392
+ "<h1>EPIC-KITCHENS-VISOR shared-v1.1 " + heading + "</h1>"
1393
+ + intro
 
 
 
 
 
 
1394
  + colour_legend()
1395
  + "<p>逐视图页面的每帧面板与逐帧数值都在页面内;抽样帧之外的帧不在页面里。"
1396
  "分割与接触的完整坐标在发布树的 <code>data/&lt;sequence&gt;/ego/annotation/</code> "
EPIC-KITCHENS-VISOR/shared-v1.1/script/visor_v1_1/validate.py CHANGED
@@ -89,10 +89,10 @@ from visor_common import ( # noqa: E402
89
  #: The full release's census. Claims about the *whole* release, so they are asserted on
90
  #: a full run only; a --views/--limit run checks its own selection and says so in every
91
  #: place its result is reported.
92
- EXPECTED_VIEWS = 179
93
- EXPECTED_SEQUENCES = 179
94
  EXPECTED_SPLITS = {"train": 115, "val": 43, "test": 21}
95
- EXPECTED_ANNOTATED_VIEWS = 158
96
 
97
  CONTACT_STATUSES = {"positive", "negative", "target_unannotated", "unknown"}
98
  #: Measured over every released annotation: only hands and gloves ever carry an
@@ -188,14 +188,16 @@ def check_segment(view_dir, meta, rows, table):
188
 
189
  每个标签的 ``entity_id`` 必须与同帧的 ``subsequence`` 加实体名推出的身份一致——
190
  这是"帧序 / 身份 / 分割"三条线唯一能对上账的地方,也正是 (subsequence, 实体名)
191
- 这个身份规则的可验证形式。返回 ``({frame_index: {entity_id}}, {object_id})``。
 
 
192
  """
193
  polygons = read_jsonl(view_dir / POLYGONS_REF)
194
  instances = read_jsonl(view_dir / INSTANCES_REF)
195
  valid = torch.load(view_dir / SEGMENT_VALID_REF, map_location="cpu", weights_only=True)
196
  assert len(polygons) == len(instances) == meta["num_frames"], (
197
  view_dir, len(polygons), len(instances), meta["num_frames"])
198
- frame_entities, objects = {}, set()
199
  for index, (polygon_row, instance_row) in enumerate(zip(polygons, instances)):
200
  assert polygon_row["frame_index"] == index == instance_row["frame_index"], (view_dir, index)
201
  labels, shapes = instance_row["labels"], polygon_row["instances"]
@@ -207,6 +209,7 @@ def check_segment(view_dir, meta, rows, table):
207
  assert bool(valid[index]) == bool(shapes), (
208
  view_dir, index, "segment validity must be source_annotation_present")
209
  frame_entities[index] = set()
 
210
  subsequence = rows[index]["source_locator"].get("subsequence")
211
  for label, shape in zip(labels, shapes):
212
  for key in ("mask_value", "category_id", "entity_id", "part_id",
@@ -227,6 +230,11 @@ def check_segment(view_dir, meta, rows, table):
227
  view_dir, index, "entity id must follow (subsequence, entity name)",
228
  label["entity_id"], expected)
229
  frame_entities[index].add(expected)
 
 
 
 
 
230
  for ring in shape["polygons"]:
231
  assert isinstance(ring, list), (view_dir, index, type(ring))
232
  for point in ring:
@@ -234,10 +242,10 @@ def check_segment(view_dir, meta, rows, table):
234
  assert all(isinstance(value, (int, float)) for value in point), (view_dir, index, point)
235
  assert all(value == value and abs(value) != float("inf") for value in point), (
236
  view_dir, index, "non-finite polygon coordinate", point)
237
- return frame_entities, objects
238
 
239
 
240
- def check_relations(view_dir, meta, rows, frame_entities):
241
  """接触关系:三态映射、原始字符串保留、positive 必须同帧可解析。
242
 
243
  ``relations.jsonl`` 只为"有源记录"的帧写行,所以它的 ``frame_index`` 是帧范围的子集;
@@ -275,15 +283,40 @@ def check_relations(view_dir, meta, rows, frame_entities):
275
  assert isinstance(value, str), (view_dir, frame, value)
276
  if status == "positive":
277
  assert HEX32.match(value), (view_dir, frame, "a positive contact keeps the source mask id", value)
278
- assert relation["object_id"] in frame_entities[frame], (
279
- view_dir, frame, "a positive target must resolve inside the same frame",
280
- relation["object_id"])
 
 
 
 
 
 
 
281
  else:
282
  assert vc.CONTACT_STATUS.get(value) == status, (
283
  view_dir, frame, "the original string must be preserved verbatim", value, status)
284
  subject = relation["subject_id"]
285
  assert subject in frame_entities[frame], (view_dir, frame, subject)
286
  assert is_contact_subject(subject), (view_dir, frame, "unexpected contact subject", subject)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
287
  counts[status] += 1
288
  return counts
289
 
@@ -394,31 +427,46 @@ def main(argv=None):
394
  help=f"do not rebuild the release manifest ({MANIFEST_PATH})")
395
  args = parser.parse_args(argv)
396
 
 
 
 
 
 
 
 
397
  root = args.root
398
  if root.resolve() != RELEASE_ROOT.resolve():
399
- assert args.views or args.limit, (
400
  f"--root points at {root}, so pass --views/--limit: the release-wide census "
401
  "and the release manifest are claims about the adjacent release")
402
  all_views = sorted((root / "data").glob("*/*/metainfo.json"))
403
- wanted = set(args.views) if args.views else None
 
 
404
  if wanted is not None:
405
  known = {view.parent.parent.name for view in all_views}
406
  assert wanted <= known, ("no such view", sorted(wanted - known))
407
  views = [view for view in all_views if view.parent.parent.name in wanted]
408
  else:
409
  views = all_views
410
- if args.limit:
411
  views = views[: args.limit]
 
 
412
 
413
- full = wanted is None and not args.limit
414
  expect_views = args.expect_views if args.expect_views is not None else (
415
  EXPECTED_VIEWS if full else len(views))
416
  full_release_root = root.resolve() == RELEASE_ROOT.resolve()
417
- report_path = args.report or (ACCEPTANCE_REPORT if (full and full_release_root) else PARTIAL_REPORT)
418
- assert full or report_path.resolve() != ACCEPTANCE_REPORT.resolve(), (
419
- f"--report names the release's acceptance report ({ACCEPTANCE_REPORT}), but "
420
- "--views/--limit makes this a subset run; drop --report to write "
421
- f"{PARTIAL_REPORT} instead, or drop the selection to run the acceptance pass")
 
 
 
 
422
 
423
  table = load_source_table()
424
  counts, sequences, flags = collections.Counter(), {}, {}
@@ -443,13 +491,13 @@ def main(argv=None):
443
  rows = check_frames(view_dir, meta)
444
  consumed, fields, _ = check_view(view_dir, meta, REGISTRY)
445
 
446
- frame_entities = {}
447
  objects = set()
448
  if vc.published(meta["components"], "segment"):
449
- frame_entities, objects = check_segment(view_dir, meta, rows, table)
450
  assert vc.published(meta["components"], "relations"), (
451
  path, "an annotated view must also publish its contact records")
452
- contact.update(check_relations(view_dir, meta, rows, frame_entities))
453
  else:
454
  assert not (view_dir / POLYGONS_REF).exists(), (path, "image-only view has segment files")
455
  assert not (view_dir / RELATIONS_REF).exists(), (path, "image-only view has relation files")
@@ -525,6 +573,7 @@ def main(argv=None):
525
  print(json.dumps(result, ensure_ascii=False, indent=2))
526
  return 0 if result["passed"] else 1
527
 
 
528
  result["release_manifest"] = {
529
  "path": str(MANIFEST_PATH),
530
  "in_release_tree": False,
 
89
  #: The full release's census. Claims about the *whole* release, so they are asserted on
90
  #: a full run only; a --views/--limit run checks its own selection and says so in every
91
  #: place its result is reported.
92
+ EXPECTED_VIEWS = vc.EXPECTED_SOURCE_SEQUENCES
93
+ EXPECTED_SEQUENCES = vc.EXPECTED_SOURCE_SEQUENCES
94
  EXPECTED_SPLITS = {"train": 115, "val": 43, "test": 21}
95
+ EXPECTED_ANNOTATED_VIEWS = vc.EXPECTED_SOURCE_ANNOTATED
96
 
97
  CONTACT_STATUSES = {"positive", "negative", "target_unannotated", "unknown"}
98
  #: Measured over every released annotation: only hands and gloves ever carry an
 
188
 
189
  每个标签的 ``entity_id`` 必须与同帧的 ``subsequence`` 加实体名推出的身份一致——
190
  这是"帧序 / 身份 / 分割"三条线唯一能对上账的地方,也正是 (subsequence, 实体名)
191
+ 这个身份规则的可验证形式。返回
192
+ ``({frame_index: {entity_id}}, {frame_index: {source_instance_id: label}}, {object_id})``:
193
+ 第二张表让接触关系能按源实例 ID 核对真实目标,而不只是"目标在同帧存在"。
194
  """
195
  polygons = read_jsonl(view_dir / POLYGONS_REF)
196
  instances = read_jsonl(view_dir / INSTANCES_REF)
197
  valid = torch.load(view_dir / SEGMENT_VALID_REF, map_location="cpu", weights_only=True)
198
  assert len(polygons) == len(instances) == meta["num_frames"], (
199
  view_dir, len(polygons), len(instances), meta["num_frames"])
200
+ frame_entities, frame_labels, objects = {}, {}, set()
201
  for index, (polygon_row, instance_row) in enumerate(zip(polygons, instances)):
202
  assert polygon_row["frame_index"] == index == instance_row["frame_index"], (view_dir, index)
203
  labels, shapes = instance_row["labels"], polygon_row["instances"]
 
209
  assert bool(valid[index]) == bool(shapes), (
210
  view_dir, index, "segment validity must be source_annotation_present")
211
  frame_entities[index] = set()
212
+ frame_labels[index] = {}
213
  subsequence = rows[index]["source_locator"].get("subsequence")
214
  for label, shape in zip(labels, shapes):
215
  for key in ("mask_value", "category_id", "entity_id", "part_id",
 
230
  view_dir, index, "entity id must follow (subsequence, entity name)",
231
  label["entity_id"], expected)
232
  frame_entities[index].add(expected)
233
+ assert label["source_instance_id"] not in frame_labels[index], (
234
+ view_dir, index, "source instance id repeats inside a frame",
235
+ label["source_instance_id"])
236
+ frame_labels[index][label["source_instance_id"]] = {
237
+ "entity_id": expected, "name": name}
238
  for ring in shape["polygons"]:
239
  assert isinstance(ring, list), (view_dir, index, type(ring))
240
  for point in ring:
 
242
  assert all(isinstance(value, (int, float)) for value in point), (view_dir, index, point)
243
  assert all(value == value and abs(value) != float("inf") for value in point), (
244
  view_dir, index, "non-finite polygon coordinate", point)
245
+ return frame_entities, frame_labels, objects
246
 
247
 
248
+ def check_relations(view_dir, meta, rows, frame_entities, frame_labels):
249
  """接触关系:三态映射、原始字符串保留、positive 必须同帧可解析。
250
 
251
  ``relations.jsonl`` 只为"有源记录"的帧写行,所以它的 ``frame_index`` 是帧范围的子集;
 
283
  assert isinstance(value, str), (view_dir, frame, value)
284
  if status == "positive":
285
  assert HEX32.match(value), (view_dir, frame, "a positive contact keeps the source mask id", value)
286
+ #: "target exists in the frame" was not enough: any other instance of the
287
+ #: same frame passed (PR #9 review finding 1). Resolve the declared source
288
+ #: instance and compare the entity the row actually points at.
289
+ target = frame_labels[frame].get(value)
290
+ assert target is not None, (
291
+ view_dir, frame, "a positive contact target must be a source instance "
292
+ "of the same frame", value)
293
+ assert relation["object_id"] == target["entity_id"], (
294
+ view_dir, frame, "a positive contact must point at the source target",
295
+ relation["object_id"], target["entity_id"], value)
296
  else:
297
  assert vc.CONTACT_STATUS.get(value) == status, (
298
  view_dir, frame, "the original string must be preserved verbatim", value, status)
299
  subject = relation["subject_id"]
300
  assert subject in frame_entities[frame], (view_dir, frame, subject)
301
  assert is_contact_subject(subject), (view_dir, frame, "unexpected contact subject", subject)
302
+ #: the locator names the source subject instance; it must be an instance of
303
+ #: this same frame and agree with the released subject_id / entity name
304
+ source_id = locator.get("source_instance_id")
305
+ assert isinstance(source_id, str) and HEX32.match(source_id), (
306
+ view_dir, frame, "the locator must name its source subject instance", source_id)
307
+ subject_label = frame_labels[frame].get(source_id)
308
+ assert subject_label is not None, (
309
+ view_dir, frame, "the source subject instance must be an instance of the same frame",
310
+ source_id)
311
+ assert subject == subject_label["entity_id"], (
312
+ view_dir, frame, "subject_id does not match the source subject instance",
313
+ subject, subject_label["entity_id"])
314
+ assert locator.get("subject_entity_name") == subject_label["name"], (
315
+ view_dir, frame, "subject name does not match the source subject instance",
316
+ locator.get("subject_entity_name"), subject_label["name"])
317
+ assert locator.get("source_annotation_index") == rows[frame]["source_annotation_index"], (
318
+ view_dir, frame, "the locator must point at its own frame's source annotation",
319
+ locator.get("source_annotation_index"), rows[frame]["source_annotation_index"])
320
  counts[status] += 1
321
  return counts
322
 
 
427
  help=f"do not rebuild the release manifest ({MANIFEST_PATH})")
428
  args = parser.parse_args(argv)
429
 
430
+ #: ``nargs="*"`` 的空列表、``--limit 0`` 都能解析成功,但它们不是"选了东西";
431
+ #: 以前会被当成假值→全量运行(PR #9 审查 finding 2)。
432
+ if args.views is not None and not args.views:
433
+ parser.error("--views needs at least one view; an empty selection cannot pass")
434
+ if args.limit is not None and args.limit < 1:
435
+ parser.error("--limit must be positive")
436
+
437
  root = args.root
438
  if root.resolve() != RELEASE_ROOT.resolve():
439
+ assert args.views is not None or args.limit is not None, (
440
  f"--root points at {root}, so pass --views/--limit: the release-wide census "
441
  "and the release manifest are claims about the adjacent release")
442
  all_views = sorted((root / "data").glob("*/*/metainfo.json"))
443
+ if not all_views:
444
+ raise SystemExit(f"no views under {root / 'data'}: a run over nothing is not a pass")
445
+ wanted = set(args.views) if args.views is not None else None
446
  if wanted is not None:
447
  known = {view.parent.parent.name for view in all_views}
448
  assert wanted <= known, ("no such view", sorted(wanted - known))
449
  views = [view for view in all_views if view.parent.parent.name in wanted]
450
  else:
451
  views = all_views
452
+ if args.limit is not None:
453
  views = views[: args.limit]
454
+ if not views:
455
+ raise SystemExit("the selection resolved to no views: a run over nothing is not a pass")
456
 
457
+ full = wanted is None and args.limit is None
458
  expect_views = args.expect_views if args.expect_views is not None else (
459
  EXPECTED_VIEWS if full else len(views))
460
  full_release_root = root.resolve() == RELEASE_ROOT.resolve()
461
+ if full and full_release_root:
462
+ assert len(all_views) == EXPECTED_VIEWS, (
463
+ "a release-wide run must see the full census", len(all_views), EXPECTED_VIEWS)
464
+ formal = full and full_release_root and len(views) == EXPECTED_VIEWS
465
+ report_path = args.report if args.report is not None else (
466
+ ACCEPTANCE_REPORT if formal else PARTIAL_REPORT)
467
+ #: 局部运行(以及任何 --report 别名)都不得覆盖正式验收报告;渲染/校验的默认
468
+ #: 输出同样先过守卫,��� mkdir/写盘(PR #9 审查 finding 4)。
469
+ vc.guard_output(report_path, formal, {"validate report"}, "validate")
470
 
471
  table = load_source_table()
472
  counts, sequences, flags = collections.Counter(), {}, {}
 
491
  rows = check_frames(view_dir, meta)
492
  consumed, fields, _ = check_view(view_dir, meta, REGISTRY)
493
 
494
+ frame_entities, frame_labels = {}, {}
495
  objects = set()
496
  if vc.published(meta["components"], "segment"):
497
+ frame_entities, frame_labels, objects = check_segment(view_dir, meta, rows, table)
498
  assert vc.published(meta["components"], "relations"), (
499
  path, "an annotated view must also publish its contact records")
500
+ contact.update(check_relations(view_dir, meta, rows, frame_entities, frame_labels))
501
  else:
502
  assert not (view_dir / POLYGONS_REF).exists(), (path, "image-only view has segment files")
503
  assert not (view_dir / RELATIONS_REF).exists(), (path, "image-only view has relation files")
 
573
  print(json.dumps(result, ensure_ascii=False, indent=2))
574
  return 0 if result["passed"] else 1
575
 
576
+ vc.guard_output(MANIFEST_PATH, formal, {"publication manifest"}, "validate")
577
  result["release_manifest"] = {
578
  "path": str(MANIFEST_PATH),
579
  "in_release_tree": False,
EPIC-KITCHENS-VISOR/shared-v1.1/script/visor_v1_1/verify.py CHANGED
@@ -26,8 +26,9 @@ What it proves, per view, against real source bytes:
26
  ``id``, ``class_id`` and the same attribute values including ``exhaustive``,
27
  ``in_contact_object`` and ``on_which_hand`` -- verbatim, source typos included.
28
  5. **relations** -- the released rows are exactly the source instances that carry a
29
- contact verdict, with the same per-frame status, and every positive target resolves
30
- inside its own frame.
 
31
  6. **metainfo** -- ``num_frames``, ``sampling.type``, the absent calibration and the
32
  split are the source's own facts, not the converter's choices.
33
 
@@ -37,6 +38,9 @@ and it is not human visual acceptance (CONTRACT 6.5).
37
 
38
  Run: python shared-v1.1/script/visor_v1_1/verify.py --raw raw/data/'EPIC-KITCHENS VISOR.zip'
39
  A run restricted with ``--views``/``--sample`` is a partial run and says so in its report.
 
 
 
40
  """
41
 
42
  from __future__ import annotations
@@ -253,7 +257,9 @@ def check_frames(view, rows, source, mapping, record, problem) -> None:
253
 
254
  def check_polygons(view, rows, source, released, record, problem) -> None:
255
  """Claim 3: the geometry is the source's, to the bit."""
 
256
  if len(released) != len(rows):
 
257
  problem(f"polygons: {len(released)} rows for {len(rows)} frames")
258
  return
259
  rings = points = 0
@@ -262,6 +268,7 @@ def check_polygons(view, rows, source, released, record, problem) -> None:
262
  annotations = source[source_index]["annotations"]
263
  shapes = polygon_row["instances"]
264
  if len(shapes) != len(annotations):
 
265
  problem(f"segment: frame {polygon_row['frame_index']} has {len(shapes)} shapes for "
266
  f"{len(annotations)} source instances")
267
  continue
@@ -269,12 +276,14 @@ def check_polygons(view, rows, source, released, record, problem) -> None:
269
  expected = annotation.get("segments") or []
270
  actual = shape.get("polygons") or []
271
  if len(actual) != len(expected):
 
272
  problem(f"segment: frame {polygon_row['frame_index']} instance "
273
  f"{shape.get('mask_value')} has {len(actual)} rings, source {len(expected)}")
274
  continue
275
  for ring_index, (ring, expected_ring) in enumerate(zip(actual, expected)):
276
  rings += 1
277
  if len(ring) != len(expected_ring):
 
278
  problem(f"segment: frame {polygon_row['frame_index']} ring {ring_index} has "
279
  f"{len(ring)} points, source {len(expected_ring)}")
280
  continue
@@ -282,11 +291,12 @@ def check_polygons(view, rows, source, released, record, problem) -> None:
282
  points += 1
283
  if len(point) != 2 or bits(point[0]) != bits(expected_point[0]) \
284
  or bits(point[1]) != bits(expected_point[1]):
 
285
  problem(f"segment: frame {polygon_row['frame_index']} ring {ring_index} "
286
  f"point {point_index} is not the source coordinate")
287
  break
288
  record["polygons"] = {"rows": len(released), "rings": rings, "points": points,
289
- "bit_identical": True}
290
 
291
 
292
  def check_instances(view, rows, source, released, record, problem, table) -> None:
@@ -315,16 +325,25 @@ def check_instances(view, rows, source, released, record, problem, table) -> Non
315
  if label.get("category_id") not in table:
316
  problem(f"identity: frame {label_row['frame_index']} class_id is not in the noun table")
317
  #: the attributes are the source's own keys, with the source's own values --
318
- #: including the source's typos; nothing is normalized or added
 
 
 
 
 
319
  attributes = label.get("source_attributes") or {}
320
- for key, value in attributes.items():
321
- if key not in annotation:
322
- problem(f"identity: frame {label_row['frame_index']} adds attribute {key!r} "
323
- f"the source does not carry")
324
- continue
325
- if annotation[key] != value:
 
 
 
 
326
  problem(f"identity: frame {label_row['frame_index']} attribute {key!r} "
327
- f"is {value!r}, source {annotation[key]!r}")
328
  expected_name = annotation["name"]
329
  expected = HAND_ENTITY_BY_NAME.get(expected_name) or vc.object_id(expected_name, subsequence)
330
  if label.get("entity_id") != expected:
@@ -334,36 +353,136 @@ def check_instances(view, rows, source, released, record, problem, table) -> Non
334
  "entities": len(entities)}
335
 
336
 
 
 
 
 
 
337
  def check_relations(view, rows, source, released, record, problem) -> None:
338
- """Claim 5: the rows are exactly the source's verdicts, status by status."""
339
- expected = collections.Counter()
 
 
 
 
 
 
 
340
  for row in rows:
341
- if row["source_locator"].get("source_annotation_index") is None:
 
342
  continue
343
- annotations = source[row["source_locator"]["source_annotation_index"]]["annotations"]
 
 
 
 
 
 
 
 
 
 
344
  for annotation in annotations:
345
  value = annotation.get("in_contact_object")
346
  status, resolves = vc.contact_status(value)
347
  if status is None:
348
  continue
349
- expected[(row["frame_index"], annotation["name"], status)] += 1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
350
  #: relations.jsonl is one row per frame, with that frame's relations inside it; the
351
  #: comparison is on the relations themselves, since a frame's row exists precisely
352
  #: when the source recorded something there
353
- found = collections.Counter()
354
  entries = 0
355
  for row in released:
 
356
  for relation in row.get("relations") or []:
357
  entries += 1
358
- name = (relation.get("source_locator") or {}).get("subject_entity_name")
359
- found[(row["frame_index"], name, relation["status"])] += 1
360
- record["relations"] = {"frames_with_rows": len(released), "relations": entries,
361
- "by_status": dict(collections.Counter(k[2] for k in found.elements()))}
362
- if expected != found:
363
- missing = expected - found
364
- extra = found - expected
365
- problem(f"relations: the released verdicts are not the source's; "
366
- f"missing {dict(list(missing.items())[:4])}, extra {dict(list(extra.items())[:4])}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
367
 
368
 
369
  def check_view(archive, view, view_dir, mapping, table) -> dict:
@@ -403,6 +522,38 @@ def check_view(archive, view, view_dir, mapping, table) -> dict:
403
  return record
404
 
405
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
406
  def main(argv=None):
407
  parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
408
  parser.add_argument("--raw", type=Path, default=vc.RAW_ARCHIVE,
@@ -417,25 +568,55 @@ def main(argv=None):
417
  parser.add_argument("--report", type=Path, help="write the acceptance report here")
418
  args = parser.parse_args(argv)
419
 
 
 
 
 
 
 
 
420
  if not args.raw.is_file():
421
  raise SystemExit(f"the raw deposit is not there: {args.raw}")
422
  census = deposit_census(args.raw)
423
- print(f"deposit: {len(census)} sequences, "
424
- f"{sum(1 for v in census.values() if v.annotated)} annotated")
 
 
 
425
 
426
  wanted = sorted(census)
427
- if args.views:
428
  unknown = sorted(set(args.views) - set(census))
429
  if unknown:
430
  raise SystemExit(f"not sequences of this deposit: {unknown}")
431
  wanted = sorted(args.views)
432
- if args.sample:
 
 
433
  wanted = wanted[: args.sample]
434
 
435
- mapping = vc.load(RELEASE_ROOT / "script" / "source_evidence" / "VISOR-frame_mapping.json")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
436
  table = {}
437
- with open(RELEASE_ROOT / "script" / "source_evidence" / "VISOR-noun-classes.csv",
438
- encoding="utf-8-sig") as handle:
439
  for row in csv.DictReader(handle):
440
  try:
441
  table[int(row["id"])] = row["key"].strip()
@@ -462,26 +643,55 @@ def main(argv=None):
462
  for sequence_id in absent:
463
  print(f"ABSENT {sequence_id}: not in the release", file=sys.stderr)
464
 
 
 
 
 
 
465
  report = {
466
  "raw": str(args.raw),
467
  "release": str(args.release),
468
  "raw_size": args.raw.stat().st_size,
469
  "deposit_sequences": len(census),
 
470
  "checked": [record["view"] for record in records],
471
  "absent": absent,
472
  "views": records,
473
  "problems": {record["view"]: record["problems"] for record in records},
474
- "accepted": not problems and not absent,
475
- "partial": bool(args.views or args.sample),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
476
  "scope": "the released numbers are the deposit's numbers, per view and per packet; "
477
  "not a judgement of source annotation correctness and not visual acceptance",
478
  }
479
- if args.report:
480
  args.report.parent.mkdir(parents=True, exist_ok=True)
481
  args.report.write_text(json.dumps(report, ensure_ascii=False, indent=2), encoding="utf-8")
482
  print(f"wrote {args.report}")
483
- print("VERIFY_PASS" if report["accepted"] else "VERIFY_FAIL")
484
- return 0 if report["accepted"] else 1
 
 
 
 
 
485
 
486
 
487
  if __name__ == "__main__":
 
26
  ``id``, ``class_id`` and the same attribute values including ``exhaustive``,
27
  ``in_contact_object`` and ``on_which_hand`` -- verbatim, source typos included.
28
  5. **relations** -- the released rows are exactly the source instances that carry a
29
+ contact verdict, keyed on the source instance id, with the same per-frame status and
30
+ source string, and every positive target is the entity that the *declared* source
31
+ target resolves to -- not merely some instance that happens to exist in the frame.
32
  6. **metainfo** -- ``num_frames``, ``sampling.type``, the absent calibration and the
33
  split are the source's own facts, not the converter's choices.
34
 
 
38
 
39
  Run: python shared-v1.1/script/visor_v1_1/verify.py --raw raw/data/'EPIC-KITCHENS VISOR.zip'
40
  A run restricted with ``--views``/``--sample`` is a partial run and says so in its report.
41
+ A *formal* run is one with no selection whose archive matches the published deposit in
42
+ size and SHA-256 and whose census is the published 179 sequences / 158 annotated views;
43
+ anything else is reported as ``partial`` and is never ``accepted``.
44
  """
45
 
46
  from __future__ import annotations
 
257
 
258
  def check_polygons(view, rows, source, released, record, problem) -> None:
259
  """Claim 3: the geometry is the source's, to the bit."""
260
+ bit_ok = True
261
  if len(released) != len(rows):
262
+ bit_ok = False
263
  problem(f"polygons: {len(released)} rows for {len(rows)} frames")
264
  return
265
  rings = points = 0
 
268
  annotations = source[source_index]["annotations"]
269
  shapes = polygon_row["instances"]
270
  if len(shapes) != len(annotations):
271
+ bit_ok = False
272
  problem(f"segment: frame {polygon_row['frame_index']} has {len(shapes)} shapes for "
273
  f"{len(annotations)} source instances")
274
  continue
 
276
  expected = annotation.get("segments") or []
277
  actual = shape.get("polygons") or []
278
  if len(actual) != len(expected):
279
+ bit_ok = False
280
  problem(f"segment: frame {polygon_row['frame_index']} instance "
281
  f"{shape.get('mask_value')} has {len(actual)} rings, source {len(expected)}")
282
  continue
283
  for ring_index, (ring, expected_ring) in enumerate(zip(actual, expected)):
284
  rings += 1
285
  if len(ring) != len(expected_ring):
286
+ bit_ok = False
287
  problem(f"segment: frame {polygon_row['frame_index']} ring {ring_index} has "
288
  f"{len(ring)} points, source {len(expected_ring)}")
289
  continue
 
291
  points += 1
292
  if len(point) != 2 or bits(point[0]) != bits(expected_point[0]) \
293
  or bits(point[1]) != bits(expected_point[1]):
294
+ bit_ok = False
295
  problem(f"segment: frame {polygon_row['frame_index']} ring {ring_index} "
296
  f"point {point_index} is not the source coordinate")
297
  break
298
  record["polygons"] = {"rows": len(released), "rings": rings, "points": points,
299
+ "bit_identical": bit_ok}
300
 
301
 
302
  def check_instances(view, rows, source, released, record, problem, table) -> None:
 
325
  if label.get("category_id") not in table:
326
  problem(f"identity: frame {label_row['frame_index']} class_id is not in the noun table")
327
  #: the attributes are the source's own keys, with the source's own values --
328
+ #: including the source's typos; nothing is normalized, added **or dropped**.
329
+ #: Compare both directions, because iterating only the released keys let a
330
+ #: converter silently discard ``exhaustive``/``on_which_hand``/
331
+ #: ``in_contact_object`` (PR #9 review finding 3). ``id`` and ``segments``
332
+ #: have dedicated fields (``source_instance_id`` / the polygons row) and are
333
+ #: the only source keys intentionally not repeated here.
334
  attributes = label.get("source_attributes") or {}
335
+ expected_attributes = {key: value for key, value in annotation.items()
336
+ if key not in {"id", "segments"}}
337
+ for key in sorted(set(expected_attributes) - set(attributes)):
338
+ problem(f"identity: frame {label_row['frame_index']} drops source attribute "
339
+ f"{key!r} (source value {expected_attributes[key]!r})")
340
+ for key in sorted(set(attributes) - set(expected_attributes)):
341
+ problem(f"identity: frame {label_row['frame_index']} adds attribute {key!r} "
342
+ f"the source does not carry")
343
+ for key in sorted(set(expected_attributes) & set(attributes)):
344
+ if not vc.same_json(attributes[key], expected_attributes[key]):
345
  problem(f"identity: frame {label_row['frame_index']} attribute {key!r} "
346
+ f"is {attributes[key]!r}, source {expected_attributes[key]!r}")
347
  expected_name = annotation["name"]
348
  expected = HAND_ENTITY_BY_NAME.get(expected_name) or vc.object_id(expected_name, subsequence)
349
  if label.get("entity_id") != expected:
 
353
  "entities": len(entities)}
354
 
355
 
356
+ def frame_entity_id(name, subsequence):
357
+ """源实体名 → 本发布的 entity_id(手映射到固定槽,其余按 ``(name, subsequence)``)。"""
358
+ return HAND_ENTITY_BY_NAME.get(name) or vc.object_id(name, subsequence)
359
+
360
+
361
  def check_relations(view, rows, source, released, record, problem) -> None:
362
+ """Claim 5: the rows are exactly the source's verdicts, subject *and* target.
363
+
364
+ Counting ``(frame, subject name, status)`` was not enough: a released row could
365
+ point at any other instance of the same frame and still match (PR #9 review
366
+ finding 1). The key here is the source instance id, and every field of the row is
367
+ compared -- status, raw source value (type-strict), subject id/name, and, for a
368
+ positive verdict, the target entity resolved from the declared source instance.
369
+ """
370
+ expected: dict[tuple[int, str], dict] = {}
371
  for row in rows:
372
+ locator = row["source_locator"]
373
+ if locator.get("source_annotation_index") is None:
374
  continue
375
+ frame_index = row["frame_index"]
376
+ subsequence = locator["subsequence"]
377
+ source_frame = source[locator["source_annotation_index"]]
378
+ annotations = source_frame["annotations"]
379
+ frame_name = (source_frame.get("image") or {}).get("name")
380
+ by_id: dict[str, dict] = {}
381
+ for annotation in annotations:
382
+ if annotation["id"] in by_id:
383
+ problem(f"relations: frame {frame_index} repeats source instance id "
384
+ f"{annotation['id']!r}")
385
+ by_id[annotation["id"]] = annotation
386
  for annotation in annotations:
387
  value = annotation.get("in_contact_object")
388
  status, resolves = vc.contact_status(value)
389
  if status is None:
390
  continue
391
+ target = None
392
+ if resolves:
393
+ target = by_id.get(value)
394
+ if target is None:
395
+ problem(f"relations: frame {frame_index} source contact target {value!r} "
396
+ "does not resolve to an instance of its own frame")
397
+ continue
398
+ key = (frame_index, annotation["id"])
399
+ if key in expected:
400
+ problem(f"relations: frame {frame_index} source instance {annotation['id']!r} "
401
+ "carries more than one contact verdict")
402
+ expected[key] = {
403
+ "status": status,
404
+ "source_value": value,
405
+ "subject_entity_name": annotation["name"],
406
+ "subject_id": frame_entity_id(annotation["name"], subsequence),
407
+ "target_source_instance_id": value if resolves else None,
408
+ "target_entity_id": frame_entity_id(target["name"], subsequence)
409
+ if resolves else None,
410
+ "source_annotation_index": locator["source_annotation_index"],
411
+ "source_frame_name": frame_name,
412
+ }
413
  #: relations.jsonl is one row per frame, with that frame's relations inside it; the
414
  #: comparison is on the relations themselves, since a frame's row exists precisely
415
  #: when the source recorded something there
416
+ found: dict[tuple[int, str], dict] = {}
417
  entries = 0
418
  for row in released:
419
+ frame_index = row["frame_index"]
420
  for relation in row.get("relations") or []:
421
  entries += 1
422
+ locator = relation.get("source_locator") or {}
423
+ source_id = locator.get("source_instance_id")
424
+ key = (frame_index, source_id)
425
+ if key in found:
426
+ problem(f"relations: frame {frame_index} releases source instance "
427
+ f"{source_id!r} more than once")
428
+ found[key] = {
429
+ "status": relation.get("status"),
430
+ "source_value": locator.get("source_value"),
431
+ "subject_entity_name": locator.get("subject_entity_name"),
432
+ "subject_id": relation.get("subject_id"),
433
+ "object_id": relation.get("object_id"),
434
+ "source_annotation_index": locator.get("source_annotation_index"),
435
+ "source_frame_name": locator.get("source_frame_name"),
436
+ }
437
+ record["relations"] = {
438
+ "frames_with_rows": len(released),
439
+ "relations": entries,
440
+ "by_status": dict(collections.Counter(item["status"] for item in found.values())),
441
+ }
442
+
443
+ for key in sorted(set(expected) - set(found)):
444
+ problem(f"relations: frame {key[0]} source instance {key[1]!r} "
445
+ f"({expected[key]['subject_entity_name']}, {expected[key]['status']}) "
446
+ "is missing from the release")
447
+ for key in sorted(set(found) - set(expected)):
448
+ problem(f"relations: frame {key[0]} source instance {key[1]!r} has a released "
449
+ f"verdict ({found[key]['status']}) the source does not carry")
450
+ for key in sorted(set(expected) & set(found)):
451
+ wanted, actual = expected[key], found[key]
452
+ frame_index, source_id = key
453
+ if actual["status"] != wanted["status"]:
454
+ problem(f"relations: frame {frame_index} source instance {source_id!r} is "
455
+ f"{actual['status']!r}, source {wanted['status']!r}")
456
+ if not vc.same_json(actual["source_value"], wanted["source_value"]):
457
+ problem(f"relations: frame {frame_index} source instance {source_id!r} keeps "
458
+ f"source value {actual['source_value']!r}, source {wanted['source_value']!r}")
459
+ if actual["subject_entity_name"] != wanted["subject_entity_name"]:
460
+ problem(f"relations: frame {frame_index} source instance {source_id!r} has "
461
+ f"subject name {actual['subject_entity_name']!r}, source "
462
+ f"{wanted['subject_entity_name']!r}")
463
+ if actual["subject_id"] != wanted["subject_id"]:
464
+ problem(f"relations: frame {frame_index} source instance {source_id!r} has "
465
+ f"subject_id {actual['subject_id']!r}, expected {wanted['subject_id']!r}")
466
+ if actual["source_annotation_index"] != wanted["source_annotation_index"]:
467
+ problem(f"relations: frame {frame_index} source instance {source_id!r} points at "
468
+ f"source annotation {actual['source_annotation_index']!r}, expected "
469
+ f"{wanted['source_annotation_index']!r}")
470
+ if wanted["source_frame_name"] is None:
471
+ problem(f"relations: frame {frame_index} has no source image name to compare "
472
+ "the locator against")
473
+ elif actual["source_frame_name"] != wanted["source_frame_name"]:
474
+ problem(f"relations: frame {frame_index} source instance {source_id!r} names "
475
+ f"source frame {actual['source_frame_name']!r}, expected "
476
+ f"{wanted['source_frame_name']!r}")
477
+ if wanted["status"] == "positive":
478
+ if actual["object_id"] != wanted["target_entity_id"]:
479
+ problem(f"relations: frame {frame_index} subject {source_id!r} "
480
+ f"({wanted['subject_entity_name']}) targets {actual['object_id']!r}, "
481
+ f"source target {wanted['target_entity_id']!r} "
482
+ f"(source instance {wanted['target_source_instance_id']})")
483
+ elif actual["object_id"] is not None:
484
+ problem(f"relations: frame {frame_index} source instance {source_id!r} is "
485
+ f"{wanted['status']!r} but carries a target {actual['object_id']!r}")
486
 
487
 
488
  def check_view(archive, view, view_dir, mapping, table) -> dict:
 
522
  return record
523
 
524
 
525
+ def source_evidence(release):
526
+ """映射表随发布树走;沙盒副本没带 ``script/source_evidence`` 时才回退到正式树。
527
+
528
+ 以前无条件从 ``RELEASE_ROOT`` 读:``--release`` 指向沙盒时,检查的是沙盒的数据、
529
+ 却悄悄借用正式树的证据(PR #9 审查 finding 1 的复现条件之一)。"""
530
+ evidence = Path(release) / "script" / "source_evidence"
531
+ return evidence if evidence.is_dir() else RELEASE_ROOT / "script" / "source_evidence"
532
+
533
+
534
+ def archive_identity(raw, check_digest):
535
+ """源归档身份:大小永远核对;完整运行(没有选择参数)还必须核对摘要。
536
+
537
+ 30.6 GB 顺序读一次约 1–4 分钟,只在正式运行时做。返回的 ``trusted`` 是报告里
538
+ ``formal`` 的必要条件——截取过的有效 ZIP 通不过它。"""
539
+ size = raw.stat().st_size
540
+ identity = {
541
+ "size": size,
542
+ "expected_size": vc.RAW_ARCHIVE_SIZE,
543
+ "digest": None,
544
+ "expected_digest": vc.RAW_ARCHIVE_SHA256,
545
+ "digest_checked": bool(check_digest),
546
+ "trusted": False,
547
+ }
548
+ if check_digest:
549
+ print(f"hashing the source archive ({size} bytes) ...", flush=True)
550
+ identity["digest"] = vc.stream_sha256(
551
+ raw, progress=lambda done: print(f" hashed {done / 1024**3:.1f} GiB", flush=True))
552
+ identity["trusted"] = size == vc.RAW_ARCHIVE_SIZE and (
553
+ not check_digest or identity["digest"] == vc.RAW_ARCHIVE_SHA256)
554
+ return identity
555
+
556
+
557
  def main(argv=None):
558
  parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
559
  parser.add_argument("--raw", type=Path, default=vc.RAW_ARCHIVE,
 
568
  parser.add_argument("--report", type=Path, help="write the acceptance report here")
569
  args = parser.parse_args(argv)
570
 
571
+ #: ``nargs="*"`` 的空列表与 ``--sample 0`` 都是合法的解析结果,但都不是「选了东西」。
572
+ if args.views is not None and not args.views:
573
+ parser.error("--views needs at least one sequence id; an empty selection "
574
+ "cannot report a pass over nothing")
575
+ if args.sample is not None and args.sample < 1:
576
+ parser.error("--sample must be positive")
577
+
578
  if not args.raw.is_file():
579
  raise SystemExit(f"the raw deposit is not there: {args.raw}")
580
  census = deposit_census(args.raw)
581
+ if not census:
582
+ raise SystemExit(f"the deposit census is empty: {args.raw} -- a probe archive "
583
+ "is never a full acceptance source")
584
+ annotated = sum(1 for view in census.values() if view.annotated)
585
+ print(f"deposit: {len(census)} sequences, {annotated} annotated")
586
 
587
  wanted = sorted(census)
588
+ if args.views is not None:
589
  unknown = sorted(set(args.views) - set(census))
590
  if unknown:
591
  raise SystemExit(f"not sequences of this deposit: {unknown}")
592
  wanted = sorted(args.views)
593
+ if args.sample is not None:
594
+ if args.sample > len(wanted):
595
+ parser.error(f"--sample {args.sample} exceeds the {len(wanted)} selected sequences")
596
  wanted = wanted[: args.sample]
597
 
598
+ no_selection = args.views is None and args.sample is None
599
+ identity = archive_identity(args.raw, check_digest=no_selection)
600
+ if no_selection and not identity["trusted"]:
601
+ raise SystemExit(
602
+ f"the archive is not the published deposit (size {identity['size']} vs "
603
+ f"{identity['expected_size']}, sha256 {identity['digest']} vs "
604
+ f"{identity['expected_digest']}); restricted runs must use --views/--sample "
605
+ "and are reported as partial"
606
+ )
607
+ census_ok = (len(census) == vc.EXPECTED_SOURCE_SEQUENCES
608
+ and annotated == vc.EXPECTED_SOURCE_ANNOTATED)
609
+ #: 只有「没有选择参数 + 正式树 + 可信归档 + 完整普查」才是正式验收;其余一律
610
+ #: partial,报告与退出码都不再声称 accepted(PR #9 审查 finding 2)。
611
+ formal = no_selection and vc.same_path(args.release, RELEASE_ROOT) \
612
+ and identity["trusted"] and census_ok
613
+ if args.report is not None:
614
+ vc.guard_output(args.report, formal, {"verify acceptance"}, "verify")
615
+
616
+ evidence = source_evidence(args.release)
617
+ mapping = vc.load(evidence / "VISOR-frame_mapping.json")
618
  table = {}
619
+ with open(evidence / "VISOR-noun-classes.csv", encoding="utf-8-sig") as handle:
 
620
  for row in csv.DictReader(handle):
621
  try:
622
  table[int(row["id"])] = row["key"].strip()
 
643
  for sequence_id in absent:
644
  print(f"ABSENT {sequence_id}: not in the release", file=sys.stderr)
645
 
646
+ #: 「没有发现问题」不等于「检查确实做完了」:records 必须覆盖被选中的每一个序列,
647
+ #: 且没有 absent。accepted 还要求这是正式运行(findings 2 / 4)。
648
+ passed = (bool(records) and not problems and not absent
649
+ and len(records) == len(wanted))
650
+ accepted = passed and formal
651
  report = {
652
  "raw": str(args.raw),
653
  "release": str(args.release),
654
  "raw_size": args.raw.stat().st_size,
655
  "deposit_sequences": len(census),
656
+ "deposit_annotated": annotated,
657
  "checked": [record["view"] for record in records],
658
  "absent": absent,
659
  "views": records,
660
  "problems": {record["view"]: record["problems"] for record in records},
661
+ "accepted": accepted,
662
+ "partial": not formal,
663
+ "formal": formal,
664
+ "passed": passed,
665
+ "archive_identity": identity,
666
+ "coverage": {
667
+ "expected_sequences": vc.EXPECTED_SOURCE_SEQUENCES,
668
+ "expected_annotated": vc.EXPECTED_SOURCE_ANNOTATED,
669
+ "census_sequences": len(census),
670
+ "census_annotated": annotated,
671
+ "views_selected": len(wanted),
672
+ "views_checked": len(records),
673
+ "selection": "all" if no_selection else "restricted",
674
+ },
675
+ "checks": {
676
+ "problem_count": len(problems),
677
+ "absent_count": len(absent),
678
+ "views_checked": len(records),
679
+ "views_selected": len(wanted),
680
+ },
681
  "scope": "the released numbers are the deposit's numbers, per view and per packet; "
682
  "not a judgement of source annotation correctness and not visual acceptance",
683
  }
684
+ if args.report is not None:
685
  args.report.parent.mkdir(parents=True, exist_ok=True)
686
  args.report.write_text(json.dumps(report, ensure_ascii=False, indent=2), encoding="utf-8")
687
  print(f"wrote {args.report}")
688
+ if accepted:
689
+ print("VERIFY_PASS")
690
+ elif passed:
691
+ print("VERIFY_PARTIAL_PASS")
692
+ else:
693
+ print("VERIFY_FAIL")
694
+ return 0 if passed else 1
695
 
696
 
697
  if __name__ == "__main__":
EPIC-KITCHENS-VISOR/shared-v1.1/script/visor_v1_1/visor_common.py CHANGED
@@ -36,6 +36,7 @@ from __future__ import annotations
36
  import collections
37
  import hashlib
38
  import json
 
39
  import re
40
  import sys
41
  import zipfile
@@ -73,6 +74,10 @@ RAW_ARCHIVE_REF = "raw/data/EPIC-KITCHENS VISOR.zip"
73
  RAW_ARCHIVE = DATASET_ROOT / RAW_ARCHIVE_REF
74
  RAW_ARCHIVE_SIZE = 30_572_126_007
75
  RAW_ARCHIVE_SHA256 = "9e15bb03b408acd28b5ef54f1b752c18909fd995464f1267dc3081711c2e0a7c"
 
 
 
 
76
  #: 整包所有成员都裹在这个平台上导出目录下(Figshare record id),成员名以它开头。
77
  DEPOSIT_ROOT = "2v6cgv1x04ol22qp9rm9x2j6a7/"
78
 
@@ -177,6 +182,41 @@ def sha256(path):
177
  return sha256_file(Path(path))
178
 
179
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
  # --------------------------------------------------------------------------- 源
181
  class SequenceSource:
182
  """一个 EPIC 视频在源里的三条成员路径(标注 / 稀疏帧图 / 密集插值)。"""
@@ -480,6 +520,93 @@ STATUS_FLAGS = (
480
  MANIFEST_PATH = TMP_ROOT / "PUBLISH_MANIFEST.json"
481
 
482
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
483
  def published(components, name):
484
  """该视图是否提供了这个组件:没有,或提供了但标 unavailable。"""
485
  component = components.get(name)
 
36
  import collections
37
  import hashlib
38
  import json
39
+ import os
40
  import re
41
  import sys
42
  import zipfile
 
74
  RAW_ARCHIVE = DATASET_ROOT / RAW_ARCHIVE_REF
75
  RAW_ARCHIVE_SIZE = 30_572_126_007
76
  RAW_ARCHIVE_SHA256 = "9e15bb03b408acd28b5ef54f1b752c18909fd995464f1267dc3081711c2e0a7c"
77
+ #: 全量源应有的视图数 / 标注段数。正式验收要求恰好这么多:截取过的归档即便能解析,
78
+ #: 也只能产出 partial 报告(PR #9 审查 finding 2)。
79
+ EXPECTED_SOURCE_SEQUENCES = 179
80
+ EXPECTED_SOURCE_ANNOTATED = 158
81
  #: 整包所有成员都裹在这个平台上导出目录下(Figshare record id),成员名以它开头。
82
  DEPOSIT_ROOT = "2v6cgv1x04ol22qp9rm9x2j6a7/"
83
 
 
182
  return sha256_file(Path(path))
183
 
184
 
185
+ def stream_sha256(path, chunk=64 * 1024**2, progress=None):
186
+ """分块顺序哈希:30.6 GB 的源归档不能一次读进内存。``progress`` 每 2 GiB 调一次。"""
187
+ digest = hashlib.sha256()
188
+ done = 0
189
+ step = 2 * 1024**3
190
+ next_report = step
191
+ with Path(path).open("rb") as handle:
192
+ while True:
193
+ block = handle.read(chunk)
194
+ if not block:
195
+ break
196
+ digest.update(block)
197
+ done += len(block)
198
+ if progress is not None and done >= next_report:
199
+ progress(done)
200
+ next_report += step
201
+ return digest.hexdigest()
202
+
203
+
204
+ def same_json(left, right):
205
+ """JSON 值严格相等:键集合、列表长度、**类型**和值都要一致。
206
+
207
+ 普通的 ``==`` 会把 ``True``/``1``、``1``/``1.0`` 混为一谈;源属性里有 ``None``
208
+ 与字符串之分,不能靠它判断"原样保留"。"""
209
+ if isinstance(left, dict) or isinstance(right, dict):
210
+ if not (isinstance(left, dict) and isinstance(right, dict)):
211
+ return False
212
+ return set(left) == set(right) and all(same_json(left[k], right[k]) for k in left)
213
+ if isinstance(left, list) or isinstance(right, list):
214
+ if not (isinstance(left, list) and isinstance(right, list)):
215
+ return False
216
+ return len(left) == len(right) and all(same_json(a, b) for a, b in zip(left, right))
217
+ return type(left) is type(right) and left == right
218
+
219
+
220
  # --------------------------------------------------------------------------- 源
221
  class SequenceSource:
222
  """一个 EPIC 视频在源里的三条成员路径(标注 / 稀疏帧图 / 密集插值)。"""
 
520
  MANIFEST_PATH = TMP_ROOT / "PUBLISH_MANIFEST.json"
521
 
522
 
523
+ # ----------------------------------------------------------- 正式证据的输出守卫
524
+ #: PR #9 审查 finding 4:局部调试运行可以覆盖发布清单与正式复核报告。这里把**正式
525
+ #: 验收证据**登记成只读角色;每个写盘的工具在 mkdir/写文件之前先过守卫。判定按解析
526
+ #: 后的实际路径(``resolve()`` + ``samefile``),符号链接、硬链接、``..`` 别名都拦得住。
527
+ def protected_outputs():
528
+ """角色 → 正式证据文件。每次调用现算,测试可 monkeypatch ``RELEASE_ROOT``。"""
529
+ review = RELEASE_ROOT / "doc" / "validation"
530
+ return {
531
+ "publication manifest": MANIFEST_PATH,
532
+ "validate report": review / "validate_report.json",
533
+ "review report": review / "V1_1_VALIDATION.json",
534
+ "review index": review / "index.html",
535
+ "reader sweep": review / "read_sequence_sweep.json",
536
+ "verify acceptance": TMP_ROOT / "acceptance.json",
537
+ }
538
+
539
+
540
+ def protected_directories():
541
+ return {"review pages": RELEASE_ROOT / "doc" / "validation"}
542
+
543
+
544
+ def same_path(left, right):
545
+ """解析后相等,或指向同一个 inode(硬链接、符号链接别名)。"""
546
+ left, right = Path(left).resolve(), Path(right).resolve()
547
+ if left == right:
548
+ return True
549
+ try:
550
+ return left.exists() and right.exists() and os.path.samefile(left, right)
551
+ except OSError:
552
+ return False
553
+
554
+
555
+ def _within(path, directory):
556
+ path, directory = Path(path).resolve(), Path(directory).resolve()
557
+ return path == directory or directory in path.parents
558
+
559
+
560
+ def _protected_roles(path):
561
+ return [role for role, value in protected_outputs().items() if same_path(path, value)]
562
+
563
+
564
+ def guard_output(path, formal, writable, label):
565
+ """拒绝会覆盖正式验收证据的文件输出。必须在任何 ``mkdir`` 之前调用。
566
+
567
+ ``formal=False`` 的运行一个字节都不得落到正式证据上;``formal=True`` 也只能写
568
+ ``writable`` 点名的角色。写到保护目录里的新文件同样拒绝——那会破坏"目录内容
569
+ 与报告自洽"的前提。
570
+ """
571
+ target = Path(path)
572
+ roles = _protected_roles(target)
573
+ if roles:
574
+ if formal and set(writable).intersection(roles):
575
+ return
576
+ reason = "正式运行不改写该角色" if formal else "局部运行不得写正式证据"
577
+ raise SystemExit(f"{label}: {reason} {roles[0]} -> {target}(写到 {TMP_ROOT})")
578
+ for name, directory in protected_directories().items():
579
+ if _within(target, directory):
580
+ raise SystemExit(
581
+ f"{label}: {name} 目录内只允许正式运行按角色写文件 -> {target}"
582
+ )
583
+ for value in protected_outputs().values():
584
+ if _within(value, target):
585
+ raise SystemExit(f"{label}: 目标包含正式证据 {value} -> {target}")
586
+
587
+
588
+ def guard_directory(path, formal, writable, label):
589
+ """目录输出版(``render.py``)。规则同 :func:`guard_output`,另外拒绝把整个
590
+ 正式证据目录当渲染输出目录,以及把它的父目录交给局部运行。"""
591
+ target = Path(path)
592
+ roles = _protected_roles(target)
593
+ if roles:
594
+ raise SystemExit(f"{label}: 目标是文件不是输出目录 {roles[0]} -> {target}")
595
+ for name, directory in protected_directories().items():
596
+ if same_path(target, directory):
597
+ if formal and set(writable).intersection({name}):
598
+ return
599
+ reason = "正式运行不改写该角色" if formal else "局部运行不得写正式证据"
600
+ raise SystemExit(f"{label}: {reason} {name} -> {target}(写到 {TMP_ROOT})")
601
+ if _within(target, directory):
602
+ raise SystemExit(f"{label}: 正式证据目录只允许正式运行按角色写 -> {target}")
603
+ if _within(directory, target):
604
+ raise SystemExit(f"{label}: 输出目录包含正式证据 {directory} -> {target}")
605
+ for value in protected_outputs().values():
606
+ if _within(value, target):
607
+ raise SystemExit(f"{label}: 输出目录包含正式证据 {value} -> {target}")
608
+
609
+
610
  def published(components, name):
611
  """该视图是否提供了这个组件:没有,或提供了但标 unavailable。"""
612
  component = components.get(name)