Stage H2O shared-v1.1 13449/13457
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- H2O/shared-v1.1/doc/validation/subject4_h1_7_cam2.html +0 -0
- H2O/shared-v1.1/doc/validation/subject4_h1_7_cam2.report.json +81 -0
- H2O/shared-v1.1/doc/validation/subject4_h1_7_cam3.html +0 -0
- H2O/shared-v1.1/doc/validation/subject4_h1_7_cam3.report.json +81 -0
- H2O/shared-v1.1/doc/validation/subject4_h1_7_cam4.html +0 -0
- H2O/shared-v1.1/doc/validation/subject4_h1_7_cam4.report.json +81 -0
- H2O/shared-v1.1/script/h2o_v1_1/README.md +90 -0
- H2O/shared-v1.1/script/h2o_v1_1/full.py +701 -0
- H2O/shared-v1.1/script/h2o_v1_1/pilot.py +344 -0
- H2O/shared-v1.1/script/h2o_v1_1/render.py +176 -0
- H2O/shared-v1.1/script/h2o_v1_1/spec/CONTRACT.md +161 -0
- H2O/shared-v1.1/script/h2o_v1_1/spec/MIGRATION.md +68 -0
- H2O/shared-v1.1/script/h2o_v1_1/spec/schema.json +1590 -0
- H2O/shared-v1.1/script/h2o_v1_1/warehouse.py +201 -0
- H2O/shared-v1.1/script/provenance/operations/publish_h2o_v1_1.py +234 -0
- H2O/shared-v1.1/script/v1_0_snapshot/doc/CONTRACT.md +457 -0
- H2O/shared-v1.1/script/v1_0_snapshot/doc/schema.json +869 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/check_dexycb_projection.py +31 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/config.json +24 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/convert_dexycb_v1.0.py +349 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/convert_h2o_v1.0.py +678 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/convert_hoi4d_v1.0.py +595 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/convert_visor_v1.0.py +271 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/operations/h2o-check-fallback.py +137 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/operations/h2o-finalize-quick-validation.py +39 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/operations/h2o-pipeline-bench-job.sh +25 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/operations/h2o-pipeline-benchmark.py +48 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/operations/h2o-pipeline-process-benchmark.py +48 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/operations/h2o-prepare-pipeline-bench.py +28 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/operations/h2o-prepare-process-full.py +45 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/operations/h2o-process-final-tests.log +39 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/operations/h2o-quick-validation.py +161 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/operations/h2o-shared-final-tests.log +1 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/operations/h2o-switch-process-full.sh +12 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/operations/watch-steady-cpu.py +38 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/docs/CONTRACT.md +457 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/docs/h2o-RAW_TO_SHARED.md +48 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/docs/schema.json +869 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/full.log +61 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/full.status +7 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/run-full.sh +26 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/script/check_dexycb_projection.py +31 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/script/config.json +17 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/script/convert_dexycb_v1.0.py +349 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/script/convert_h2o_v1.0.py +545 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/script/convert_hoi4d_v1.0.py +595 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/script/convert_visor_v1.0.py +271 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/script/provenance/operations/h2o-benchmark-decode.py +74 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/script/provenance/operations/h2o-prepare-d10.py +55 -0
- H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/script/provenance/operations/h2o-switch-d10.sh +16 -0
H2O/shared-v1.1/doc/validation/subject4_h1_7_cam2.html
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
H2O/shared-v1.1/doc/validation/subject4_h1_7_cam2.report.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"num_frames": 584,
|
| 3 |
+
"numeric_components": {
|
| 4 |
+
"intrinsic": {
|
| 5 |
+
"shape": [
|
| 6 |
+
584,
|
| 7 |
+
3,
|
| 8 |
+
3
|
| 9 |
+
],
|
| 10 |
+
"dtype": "torch.float32",
|
| 11 |
+
"valid_true": 584,
|
| 12 |
+
"valid_total": 584
|
| 13 |
+
},
|
| 14 |
+
"extrinsic": {
|
| 15 |
+
"shape": [
|
| 16 |
+
584,
|
| 17 |
+
4,
|
| 18 |
+
4
|
| 19 |
+
],
|
| 20 |
+
"dtype": "torch.float32",
|
| 21 |
+
"valid_true": 584,
|
| 22 |
+
"valid_total": 584
|
| 23 |
+
},
|
| 24 |
+
"mano": {
|
| 25 |
+
"shape": [
|
| 26 |
+
584,
|
| 27 |
+
2,
|
| 28 |
+
61
|
| 29 |
+
],
|
| 30 |
+
"dtype": "torch.float32",
|
| 31 |
+
"valid_true": 1168,
|
| 32 |
+
"valid_total": 1168
|
| 33 |
+
},
|
| 34 |
+
"keypoints_xyz": {
|
| 35 |
+
"shape": [
|
| 36 |
+
584,
|
| 37 |
+
2,
|
| 38 |
+
21,
|
| 39 |
+
3
|
| 40 |
+
],
|
| 41 |
+
"dtype": "torch.float32",
|
| 42 |
+
"valid_true": 24528,
|
| 43 |
+
"valid_total": 24528
|
| 44 |
+
},
|
| 45 |
+
"pose_cocoa": {
|
| 46 |
+
"shape": [
|
| 47 |
+
584,
|
| 48 |
+
4,
|
| 49 |
+
4
|
| 50 |
+
],
|
| 51 |
+
"dtype": "torch.float32",
|
| 52 |
+
"valid_true": 584,
|
| 53 |
+
"valid_total": 584
|
| 54 |
+
},
|
| 55 |
+
"points_cocoa": {
|
| 56 |
+
"shape": [
|
| 57 |
+
584,
|
| 58 |
+
21,
|
| 59 |
+
3
|
| 60 |
+
],
|
| 61 |
+
"dtype": "torch.float32",
|
| 62 |
+
"valid_true": 12264,
|
| 63 |
+
"valid_total": 12264
|
| 64 |
+
}
|
| 65 |
+
},
|
| 66 |
+
"bundle_files": 4,
|
| 67 |
+
"scope": "v1.1 registry, keys, shapes, validity and timeline; not a media pixel comparison",
|
| 68 |
+
"selected_frames": [
|
| 69 |
+
0,
|
| 70 |
+
146,
|
| 71 |
+
292,
|
| 72 |
+
438,
|
| 73 |
+
583
|
| 74 |
+
],
|
| 75 |
+
"preview_media": [
|
| 76 |
+
"rgb",
|
| 77 |
+
"depth",
|
| 78 |
+
"depth_valid"
|
| 79 |
+
],
|
| 80 |
+
"decode_scope": "only selected frames emitted; sequential decoding may traverse earlier frames, no full-video pixel comparison"
|
| 81 |
+
}
|
H2O/shared-v1.1/doc/validation/subject4_h1_7_cam3.html
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
H2O/shared-v1.1/doc/validation/subject4_h1_7_cam3.report.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"num_frames": 584,
|
| 3 |
+
"numeric_components": {
|
| 4 |
+
"intrinsic": {
|
| 5 |
+
"shape": [
|
| 6 |
+
584,
|
| 7 |
+
3,
|
| 8 |
+
3
|
| 9 |
+
],
|
| 10 |
+
"dtype": "torch.float32",
|
| 11 |
+
"valid_true": 584,
|
| 12 |
+
"valid_total": 584
|
| 13 |
+
},
|
| 14 |
+
"extrinsic": {
|
| 15 |
+
"shape": [
|
| 16 |
+
584,
|
| 17 |
+
4,
|
| 18 |
+
4
|
| 19 |
+
],
|
| 20 |
+
"dtype": "torch.float32",
|
| 21 |
+
"valid_true": 584,
|
| 22 |
+
"valid_total": 584
|
| 23 |
+
},
|
| 24 |
+
"mano": {
|
| 25 |
+
"shape": [
|
| 26 |
+
584,
|
| 27 |
+
2,
|
| 28 |
+
61
|
| 29 |
+
],
|
| 30 |
+
"dtype": "torch.float32",
|
| 31 |
+
"valid_true": 1168,
|
| 32 |
+
"valid_total": 1168
|
| 33 |
+
},
|
| 34 |
+
"keypoints_xyz": {
|
| 35 |
+
"shape": [
|
| 36 |
+
584,
|
| 37 |
+
2,
|
| 38 |
+
21,
|
| 39 |
+
3
|
| 40 |
+
],
|
| 41 |
+
"dtype": "torch.float32",
|
| 42 |
+
"valid_true": 24528,
|
| 43 |
+
"valid_total": 24528
|
| 44 |
+
},
|
| 45 |
+
"pose_cocoa": {
|
| 46 |
+
"shape": [
|
| 47 |
+
584,
|
| 48 |
+
4,
|
| 49 |
+
4
|
| 50 |
+
],
|
| 51 |
+
"dtype": "torch.float32",
|
| 52 |
+
"valid_true": 584,
|
| 53 |
+
"valid_total": 584
|
| 54 |
+
},
|
| 55 |
+
"points_cocoa": {
|
| 56 |
+
"shape": [
|
| 57 |
+
584,
|
| 58 |
+
21,
|
| 59 |
+
3
|
| 60 |
+
],
|
| 61 |
+
"dtype": "torch.float32",
|
| 62 |
+
"valid_true": 12264,
|
| 63 |
+
"valid_total": 12264
|
| 64 |
+
}
|
| 65 |
+
},
|
| 66 |
+
"bundle_files": 4,
|
| 67 |
+
"scope": "v1.1 registry, keys, shapes, validity and timeline; not a media pixel comparison",
|
| 68 |
+
"selected_frames": [
|
| 69 |
+
0,
|
| 70 |
+
146,
|
| 71 |
+
292,
|
| 72 |
+
438,
|
| 73 |
+
583
|
| 74 |
+
],
|
| 75 |
+
"preview_media": [
|
| 76 |
+
"rgb",
|
| 77 |
+
"depth",
|
| 78 |
+
"depth_valid"
|
| 79 |
+
],
|
| 80 |
+
"decode_scope": "only selected frames emitted; sequential decoding may traverse earlier frames, no full-video pixel comparison"
|
| 81 |
+
}
|
H2O/shared-v1.1/doc/validation/subject4_h1_7_cam4.html
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
H2O/shared-v1.1/doc/validation/subject4_h1_7_cam4.report.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"num_frames": 584,
|
| 3 |
+
"numeric_components": {
|
| 4 |
+
"intrinsic": {
|
| 5 |
+
"shape": [
|
| 6 |
+
584,
|
| 7 |
+
3,
|
| 8 |
+
3
|
| 9 |
+
],
|
| 10 |
+
"dtype": "torch.float32",
|
| 11 |
+
"valid_true": 584,
|
| 12 |
+
"valid_total": 584
|
| 13 |
+
},
|
| 14 |
+
"extrinsic": {
|
| 15 |
+
"shape": [
|
| 16 |
+
584,
|
| 17 |
+
4,
|
| 18 |
+
4
|
| 19 |
+
],
|
| 20 |
+
"dtype": "torch.float32",
|
| 21 |
+
"valid_true": 584,
|
| 22 |
+
"valid_total": 584
|
| 23 |
+
},
|
| 24 |
+
"mano": {
|
| 25 |
+
"shape": [
|
| 26 |
+
584,
|
| 27 |
+
2,
|
| 28 |
+
61
|
| 29 |
+
],
|
| 30 |
+
"dtype": "torch.float32",
|
| 31 |
+
"valid_true": 1168,
|
| 32 |
+
"valid_total": 1168
|
| 33 |
+
},
|
| 34 |
+
"keypoints_xyz": {
|
| 35 |
+
"shape": [
|
| 36 |
+
584,
|
| 37 |
+
2,
|
| 38 |
+
21,
|
| 39 |
+
3
|
| 40 |
+
],
|
| 41 |
+
"dtype": "torch.float32",
|
| 42 |
+
"valid_true": 24528,
|
| 43 |
+
"valid_total": 24528
|
| 44 |
+
},
|
| 45 |
+
"pose_cocoa": {
|
| 46 |
+
"shape": [
|
| 47 |
+
584,
|
| 48 |
+
4,
|
| 49 |
+
4
|
| 50 |
+
],
|
| 51 |
+
"dtype": "torch.float32",
|
| 52 |
+
"valid_true": 584,
|
| 53 |
+
"valid_total": 584
|
| 54 |
+
},
|
| 55 |
+
"points_cocoa": {
|
| 56 |
+
"shape": [
|
| 57 |
+
584,
|
| 58 |
+
21,
|
| 59 |
+
3
|
| 60 |
+
],
|
| 61 |
+
"dtype": "torch.float32",
|
| 62 |
+
"valid_true": 12264,
|
| 63 |
+
"valid_total": 12264
|
| 64 |
+
}
|
| 65 |
+
},
|
| 66 |
+
"bundle_files": 4,
|
| 67 |
+
"scope": "v1.1 registry, keys, shapes, validity and timeline; not a media pixel comparison",
|
| 68 |
+
"selected_frames": [
|
| 69 |
+
0,
|
| 70 |
+
146,
|
| 71 |
+
292,
|
| 72 |
+
438,
|
| 73 |
+
583
|
| 74 |
+
],
|
| 75 |
+
"preview_media": [
|
| 76 |
+
"rgb",
|
| 77 |
+
"depth",
|
| 78 |
+
"depth_valid"
|
| 79 |
+
],
|
| 80 |
+
"decode_scope": "only selected frames emitted; sequential decoding may traverse earlier frames, no full-video pixel comparison"
|
| 81 |
+
}
|
H2O/shared-v1.1/script/h2o_v1_1/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# H2O v1.0 → v1.1 — gated migration pilot
|
| 2 |
+
|
| 3 |
+
This is a storage-only migration of the audited H2O release, not a raw reconverter.
|
| 4 |
+
It supports the six native numeric component types actually present: intrinsic,
|
| 5 |
+
extrinsic, MANO, hand XYZ, object pose and object XYZ. Unsupported fields,
|
| 6 |
+
attributes, object IDs and orphan tensors fail closed.
|
| 7 |
+
|
| 8 |
+
- `warehouse.py`: CPU/weights-only cached bundle reader; exact contiguous-byte
|
| 9 |
+
comparison including NaN payloads/signed zero; registry, references, timeline,
|
| 10 |
+
shapes and validity validation. All five camera roles are checked.
|
| 11 |
+
- `pilot.py`: selects complete sequences covering subjects, splits, eight object
|
| 12 |
+
classes, historical validity combinations, frame-length extremes and the
|
| 13 |
+
registered H.264 fallback. Read-only HF requests compare every pilot source
|
| 14 |
+
file against a fixed commit. Source files are hashed once, not per frame.
|
| 15 |
+
Unchanged media/validity/assets are hardlinked into an isolated pilot on the
|
| 16 |
+
same filesystem; never edit these hardlinks. Only new bundles/metadata are written.
|
| 17 |
+
- `render.py`: directly reads new bundles and samples native RGB, depth and
|
| 18 |
+
depth-valid; shows native XYZ projected for preview only, all numeric values,
|
| 19 |
+
validity, cameras, MANO, object pose/points/assets and provenance. Source-missing
|
| 20 |
+
UV/segmentation/contact remain missing. FFmpeg emits only selected frames;
|
| 21 |
+
sequential decoding can still traverse earlier frames. No media re-encoding
|
| 22 |
+
or full-video pixel equality check is done during migration.
|
| 23 |
+
- `spec/`: exact supplied v1.1 documents. Published `doc/CONTRACT.md` repairs the
|
| 24 |
+
original draft-relative semantic link to the bundled `V1_0_SEMANTICS.md`.
|
| 25 |
+
|
| 26 |
+
Run on 101 under tmux `Data`, using the project environment:
|
| 27 |
+
|
| 28 |
+
```bash
|
| 29 |
+
ROOT=/home/xuzhefeng/Datasets/uni-hoi-h2o-full-20260930-process16-pipe/H2O
|
| 30 |
+
W="$ROOT/tmp/migration-v1.1-pilot-20261010"
|
| 31 |
+
mkdir -p "$W"
|
| 32 |
+
.venv/bin/python scripts/h2o_v1_1/pilot.py \
|
| 33 |
+
--source "$ROOT/shared-v1.0" --out "$W/shared-v1.1" \
|
| 34 |
+
--source-revision 2d78ce6422a5db77f6d64c2fb88770ab6e55ae0d --workers 4
|
| 35 |
+
.venv/bin/python "$W/shared-v1.1/script/h2o_v1_1/render.py" \
|
| 36 |
+
"$W/shared-v1.1" --workers 4
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
`PILOT_JOURNAL.json` stays outside the pilot release. It records fixed source
|
| 40 |
+
revision, raw/source tree OIDs, tool fingerprints, exact changed/deletion paths,
|
| 41 |
+
source/unchanged/new file hashes and numerical comparisons. Original v1.0
|
| 42 |
+
scripts/schema and selected build receipts are retained as history, not relabelled
|
| 43 |
+
as v1.1 approval. Pilot HTML and registry checks are not human approval.
|
| 44 |
+
|
| 45 |
+
The pilot CLI has no upload/delete/full-run switch. The separately gated
|
| 46 |
+
`full.py` now implements the user-approved local full migration; HF publication
|
| 47 |
+
remains behind the post-full human review gate. No changes are made to local or remote raw, existing v1.0, other datasets,
|
| 48 |
+
or the project's concurrently edited global contract/schema.
|
| 49 |
+
|
| 50 |
+
Tests: `.venv/bin/python -m unittest discover -s tests -p test_h2o_v1_1.py -v`.
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
## User-approved full migration (October 10, 2026)
|
| 54 |
+
|
| 55 |
+
`full.py` acquires a dataset lock, checks same-user consumers, records the fixed HF
|
| 56 |
+
source and exact tool/inventory fingerprints, and enters maintenance. Each view
|
| 57 |
+
first passes the pilot writer and exact checks in private staging; original
|
| 58 |
+
numerical tensors/metadata are fsynced hardlink backups outside the release.
|
| 59 |
+
New bundles then metadata are atomically installed, and only the recorded old
|
| 60 |
+
numerical paths are removed. Prepared checkpoints recover partial installs;
|
| 61 |
+
completed checkpoints rehash inputs/output and compare rollback tensors on resume.
|
| 62 |
+
|
| 63 |
+
Run from a frozen copy of this directory under `H2O/tmp`, not code being edited:
|
| 64 |
+
|
| 65 |
+
```bash
|
| 66 |
+
python full.py --source /data/xuzhefeng/Datasets/uni-hoi-h2o-full-20260930-process16-pipe/H2O/shared-v1.0 \
|
| 67 |
+
--work /data/xuzhefeng/Datasets/uni-hoi-h2o-full-20260930-process16-pipe/H2O/tmp/migration-v1.1-full-20261010 \
|
| 68 |
+
--source-revision 2d78ce6422a5db77f6d64c2fb88770ab6e55ae0d \
|
| 69 |
+
--pilot-summary /data/xuzhefeng/Datasets/uni-hoi-h2o-full-20260930-process16-pipe/H2O/tmp/migration-v1.1-pilot-20261010/shared-v1.1/doc/validation/PILOT_FINAL_CHECK.json \
|
| 70 |
+
--human-pilot-approved --workers 4
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
The final pass rehashes all changed bundles/metadata and checks their complete
|
| 74 |
+
numeric bytes against backups. Unchanged media were already hashed against the
|
| 75 |
+
fixed HF source; inode/size/mtime are rechecked under maintenance rather than
|
| 76 |
+
reading the entire media corpus a second time. Resume does perform fresh hashes
|
| 77 |
+
for completed views. Root historical docs/scripts are also preserved and checked.
|
| 78 |
+
|
| 79 |
+
`RUN.json` is live progress/ETA; `checkpoints/` is recovery state;
|
| 80 |
+
`PUBLISH_MANIFEST.json` records exact publishable paths, sizes and SHA256s outside
|
| 81 |
+
the release. All 184 sequences, 920 views and 571,645 view-frame entries must pass.
|
| 82 |
+
Post-full HTML uses seeded complete sequences covering every subject/object/split
|
| 83 |
+
and codec fallback. Human review must pass before the separate local rename
|
| 84 |
+
(`--finalize-after-review`); neither mode writes to HF or modifies raw.
|
| 85 |
+
|
| 86 |
+
During migration the `shared-v1.0` name can contain maintained v1.1 views. Do not
|
| 87 |
+
train, convert or publish from it. Backups and checkpoints are retained, never
|
| 88 |
+
deleted to make space. The remote v1.0 remains available until a later authorized
|
| 89 |
+
publication. Source `doc/history-v1.0` and `script/v1_0_snapshot` are historical,
|
| 90 |
+
not falsely relabelled v1.1 validation or conversion tools.
|
H2O/shared-v1.1/script/h2o_v1_1/full.py
ADDED
|
@@ -0,0 +1,701 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Locked, recoverable in-place H2O v1.1 migration; no HF write operations."""
|
| 3 |
+
import argparse
|
| 4 |
+
import ctypes
|
| 5 |
+
from concurrent.futures import FIRST_COMPLETED, ProcessPoolExecutor, wait
|
| 6 |
+
from contextlib import contextmanager
|
| 7 |
+
from datetime import datetime, timezone
|
| 8 |
+
import fcntl
|
| 9 |
+
import hashlib
|
| 10 |
+
import json
|
| 11 |
+
import multiprocessing
|
| 12 |
+
import os
|
| 13 |
+
from pathlib import Path
|
| 14 |
+
import random
|
| 15 |
+
import shutil
|
| 16 |
+
import subprocess
|
| 17 |
+
import sys
|
| 18 |
+
import time
|
| 19 |
+
import urllib.request
|
| 20 |
+
|
| 21 |
+
if __package__:
|
| 22 |
+
from .pilot import BASE_DOC_HASHES, PREFIX, REPO, migrate_view, tree, verify_source_file, write_json, stamp
|
| 23 |
+
else:
|
| 24 |
+
from pilot import BASE_DOC_HASHES, PREFIX, REPO, migrate_view, tree, verify_source_file, write_json, stamp
|
| 25 |
+
if __package__:
|
| 26 |
+
from .warehouse import Reader, exact, layout, resolve, sha256, validate_view, exact_metadata
|
| 27 |
+
else:
|
| 28 |
+
from warehouse import Reader, exact, layout, resolve, sha256, validate_view, exact_metadata
|
| 29 |
+
|
| 30 |
+
HERE = Path(__file__).resolve().parent
|
| 31 |
+
MARKER = 'MIGRATION_MAINTENANCE.json'
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def sync_dir(path):
|
| 35 |
+
fd = os.open(path, os.O_RDONLY | os.O_DIRECTORY)
|
| 36 |
+
try:
|
| 37 |
+
os.fsync(fd)
|
| 38 |
+
finally:
|
| 39 |
+
os.close(fd)
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def durable_json(path, value):
|
| 43 |
+
write_json(path, value)
|
| 44 |
+
with Path(path).open('rb') as f:
|
| 45 |
+
os.fsync(f.fileno())
|
| 46 |
+
sync_dir(Path(path).parent)
|
| 47 |
+
sync_dir(Path(path).parent.parent)
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
@contextmanager
|
| 51 |
+
def lock(path):
|
| 52 |
+
path = Path(path)
|
| 53 |
+
path.parent.mkdir(parents=True, exist_ok=True)
|
| 54 |
+
with path.open('a+') as stream:
|
| 55 |
+
try:
|
| 56 |
+
fcntl.flock(stream, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
| 57 |
+
except BlockingIOError as exc:
|
| 58 |
+
raise RuntimeError(f'another migrator holds lock: {path}') from exc
|
| 59 |
+
try:
|
| 60 |
+
yield
|
| 61 |
+
finally:
|
| 62 |
+
fcntl.flock(stream, fcntl.LOCK_UN)
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
def tools():
|
| 66 |
+
return {p.relative_to(HERE).as_posix(): sha256(p) for p in sorted(HERE.rglob('*'))
|
| 67 |
+
if p.is_file() and '__pycache__' not in p.parts and p.suffix != '.pyc'}
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
def checked_id(view):
|
| 71 |
+
parts = Path(view).parts
|
| 72 |
+
if len(parts) != 3 or parts[0] != 'data' or any(x in ('', '.', '..') or '\\' in x for x in parts):
|
| 73 |
+
raise ValueError(f'invalid view ID: {view}')
|
| 74 |
+
return parts[1:]
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
def paths(ctx, view):
|
| 78 |
+
seq, cam = checked_id(view)
|
| 79 |
+
work = Path(ctx['work'])
|
| 80 |
+
source = Path(ctx['source']) / view
|
| 81 |
+
stage, backup = work / 'staged' / view, work / 'backups' / view
|
| 82 |
+
if any(p.is_symlink() for p in (source, source.parent, source.parent.parent)) or not source.resolve().is_relative_to(Path(ctx['source']).resolve()):
|
| 83 |
+
raise ValueError('source view escapes the release')
|
| 84 |
+
if not stage.resolve().is_relative_to(work) or not backup.resolve().is_relative_to(work):
|
| 85 |
+
raise ValueError('staging/backup path escapes work directory')
|
| 86 |
+
return (source, stage, backup, work / 'checkpoints' / seq / (cam + '.json'))
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def view_files(view):
|
| 90 |
+
found = set()
|
| 91 |
+
for root, directories, files in os.walk(view, followlinks=False):
|
| 92 |
+
for name in directories + files:
|
| 93 |
+
if (Path(root) / name).is_symlink():
|
| 94 |
+
raise ValueError('symlinks are not permitted inside a migration view')
|
| 95 |
+
found.update((Path(root) / name).relative_to(view).as_posix() for name in files)
|
| 96 |
+
return found
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
def checked_hash(path, expected):
|
| 100 |
+
if path.is_symlink() or not path.is_file() or sha256(path) != expected:
|
| 101 |
+
raise ValueError(f'missing/modified recovery artifact: {path}')
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
def verify_done(ctx, record, rehash_unchanged=True):
|
| 105 |
+
source, _, backup, _ = paths(ctx, record['view'])
|
| 106 |
+
if record['context'] != ctx:
|
| 107 |
+
raise ValueError('checkpoint input/tool fingerprint mismatch')
|
| 108 |
+
expected = set(record['unchanged_sha256']) | set(record['changed_sha256'])
|
| 109 |
+
if view_files(source) != expected:
|
| 110 |
+
raise ValueError('completed view file set mismatch')
|
| 111 |
+
for ref, digest in record['changed_sha256'].items():
|
| 112 |
+
checked_hash(resolve(source, ref), digest)
|
| 113 |
+
for ref,digest in record['unchanged_sha256'].items():
|
| 114 |
+
path = resolve(source, ref)
|
| 115 |
+
if rehash_unchanged:
|
| 116 |
+
checked_hash(path, digest)
|
| 117 |
+
elif list(stamp(path)) != record['unchanged_stamp'][ref]:
|
| 118 |
+
raise ValueError(f'unchanged file modified since fixed-HF hash check: {path}')
|
| 119 |
+
for ref in ['metainfo.json', *record['removed_numeric_paths']]:
|
| 120 |
+
checked_hash(resolve(backup, ref), record['source_sha256'][ref])
|
| 121 |
+
validate_view(source, ctx['schema'])
|
| 122 |
+
old = json.loads((backup / 'metainfo.json').read_text())
|
| 123 |
+
new = json.loads((source / 'metainfo.json').read_text())
|
| 124 |
+
exact_metadata(old, new)
|
| 125 |
+
old_reader, new_reader = Reader(backup), Reader(source)
|
| 126 |
+
for name, c in old['components'].items():
|
| 127 |
+
if c.get('available') and c['data_ref'].endswith('.pt'):
|
| 128 |
+
for kind in ('data', 'valid'):
|
| 129 |
+
exact(old_reader.field(c, kind), new_reader.field(new['components'][name], kind))
|
| 130 |
+
return record
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
def install_file(stage, dest, digest):
|
| 134 |
+
if dest.exists():
|
| 135 |
+
checked_hash(dest, digest)
|
| 136 |
+
return
|
| 137 |
+
checked_hash(stage, digest)
|
| 138 |
+
dest.parent.mkdir(parents=True, exist_ok=True)
|
| 139 |
+
with stage.open('rb') as f:
|
| 140 |
+
os.fsync(f.fileno())
|
| 141 |
+
os.replace(stage, dest)
|
| 142 |
+
sync_dir(dest.parent)
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
def complete_prepared(ctx, record):
|
| 146 |
+
source, stage, backup, checkpoint = paths(ctx, record['view'])
|
| 147 |
+
if record['context'] != ctx:
|
| 148 |
+
raise ValueError('prepared checkpoint input/tool fingerprint mismatch')
|
| 149 |
+
old = json.loads((backup / 'metainfo.json').read_text())
|
| 150 |
+
numeric = {c[k] for c in old['components'].values() if c.get('available') and c['data_ref'].endswith('.pt')
|
| 151 |
+
for k in ('data_ref', 'valid_ref')}
|
| 152 |
+
if numeric != set(record['removed_numeric_paths']):
|
| 153 |
+
raise ValueError('unsafe numerical deletion manifest')
|
| 154 |
+
for ref in ['metainfo.json', *sorted(numeric)]:
|
| 155 |
+
checked_hash(resolve(backup, ref), record['source_sha256'][ref])
|
| 156 |
+
for ref in record['new_bundle_paths']:
|
| 157 |
+
if ref in numeric:
|
| 158 |
+
raise ValueError('new bundle collides with an old numerical file')
|
| 159 |
+
install_file(stage / ref, source / ref, record['changed_sha256'][ref])
|
| 160 |
+
current_hash = sha256(source / 'metainfo.json')
|
| 161 |
+
expected_hash = record['changed_sha256']['metainfo.json']
|
| 162 |
+
if current_hash != expected_hash:
|
| 163 |
+
if current_hash != record['source_sha256']['metainfo.json']:
|
| 164 |
+
raise ValueError('metadata changed outside migration')
|
| 165 |
+
checked_hash(stage / 'metainfo.json', expected_hash)
|
| 166 |
+
with (stage / 'metainfo.json').open('rb') as f:
|
| 167 |
+
os.fsync(f.fileno())
|
| 168 |
+
os.replace(stage / 'metainfo.json', source / 'metainfo.json')
|
| 169 |
+
sync_dir(source)
|
| 170 |
+
new = json.loads((source / 'metainfo.json').read_text())
|
| 171 |
+
exact_metadata(old, new)
|
| 172 |
+
old_reader, new_reader = Reader(backup), Reader(source)
|
| 173 |
+
for name, c in old['components'].items():
|
| 174 |
+
if c.get('available') and c['data_ref'].endswith('.pt'):
|
| 175 |
+
for kind in ('data', 'valid'):
|
| 176 |
+
exact(old_reader.field(c, kind), new_reader.field(new['components'][name], kind))
|
| 177 |
+
# Only exact manifest entries can be removed; independent media/JSONL valid survives.
|
| 178 |
+
parents = set()
|
| 179 |
+
for ref in sorted(numeric):
|
| 180 |
+
path = source / ref
|
| 181 |
+
if path.exists():
|
| 182 |
+
checked_hash(resolve(source, ref), record['source_sha256'][ref])
|
| 183 |
+
path.unlink()
|
| 184 |
+
parents.add(path.parent)
|
| 185 |
+
for parent in parents:
|
| 186 |
+
sync_dir(parent)
|
| 187 |
+
validation = validate_view(source, ctx['schema'])
|
| 188 |
+
if view_files(source) != set(record['unchanged_sha256']) | set(record['changed_sha256']):
|
| 189 |
+
raise ValueError('installed view file set mismatch')
|
| 190 |
+
for ref in record['unchanged_sha256']:
|
| 191 |
+
if list(stamp(source / ref)) != record['unchanged_stamp'][ref]:
|
| 192 |
+
raise ValueError('unchanged file changed during view commit')
|
| 193 |
+
record.update(phase='complete', validation=validation)
|
| 194 |
+
durable_json(checkpoint, record)
|
| 195 |
+
if stage.exists():
|
| 196 |
+
if not stage.resolve().is_relative_to(Path(ctx['work']) / 'staged'):
|
| 197 |
+
raise ValueError('unsafe staging cleanup')
|
| 198 |
+
shutil.rmtree(stage) # Owned hardlinks only; original media bytes are never changed.
|
| 199 |
+
return record
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
def worker(task):
|
| 203 |
+
import torch
|
| 204 |
+
torch.set_num_threads(1)
|
| 205 |
+
if torch.get_num_interop_threads() != 1:
|
| 206 |
+
torch.set_num_interop_threads(1)
|
| 207 |
+
ctx, view, inventory = task
|
| 208 |
+
source, stage, backup, checkpoint = paths(ctx, view)
|
| 209 |
+
with lock(Path(ctx['work']) / 'view-locks' / (view.replace('/', '__') + '.lock')):
|
| 210 |
+
if checkpoint.exists():
|
| 211 |
+
record = json.loads(checkpoint.read_text())
|
| 212 |
+
if record['phase'] == 'complete':
|
| 213 |
+
result = verify_done(ctx, record)
|
| 214 |
+
if stage.exists():
|
| 215 |
+
shutil.rmtree(stage)
|
| 216 |
+
return result
|
| 217 |
+
if record['phase'] == 'prepared':
|
| 218 |
+
return complete_prepared(ctx, record)
|
| 219 |
+
raise ValueError('unknown checkpoint phase')
|
| 220 |
+
view_files(source)
|
| 221 |
+
# An uncommitted stage may be discarded only after confirming the source is v1.0.
|
| 222 |
+
meta = json.loads((source / 'metainfo.json').read_text())
|
| 223 |
+
if meta['schema_version'] != 'hand-warehouse/1.0':
|
| 224 |
+
raise ValueError('migrated view has no recoverable checkpoint')
|
| 225 |
+
for candidate in (stage, stage.with_name('.tmp-' + stage.name)):
|
| 226 |
+
if candidate.exists():
|
| 227 |
+
if not candidate.resolve().is_relative_to(Path(ctx['work']) / 'staged'):
|
| 228 |
+
raise ValueError('unsafe incomplete-stage cleanup')
|
| 229 |
+
shutil.rmtree(candidate)
|
| 230 |
+
record = migrate_view((str(source), str(stage), ctx['schema'], inventory))
|
| 231 |
+
for ref in ['metainfo.json', *record['removed_numeric_paths']]:
|
| 232 |
+
dest = backup / ref
|
| 233 |
+
dest.parent.mkdir(parents=True, exist_ok=True)
|
| 234 |
+
if not dest.exists():
|
| 235 |
+
os.link(resolve(source, ref), dest)
|
| 236 |
+
checked_hash(dest, record['source_sha256'][ref])
|
| 237 |
+
for directory, _, _ in os.walk(backup, topdown=False):
|
| 238 |
+
sync_dir(directory)
|
| 239 |
+
for directory in (backup.parent, backup.parent.parent, backup.parent.parent.parent):
|
| 240 |
+
sync_dir(directory)
|
| 241 |
+
record.update(phase='prepared', context=ctx)
|
| 242 |
+
durable_json(checkpoint, record)
|
| 243 |
+
sync_dir(Path(ctx['work']))
|
| 244 |
+
return complete_prepared(ctx, record)
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
|
| 248 |
+
def audit_worker(task):
|
| 249 |
+
import torch
|
| 250 |
+
torch.set_num_threads(1)
|
| 251 |
+
ctx, view, _ = task
|
| 252 |
+
checkpoint = paths(ctx, view)[-1]
|
| 253 |
+
record = json.loads(checkpoint.read_text())
|
| 254 |
+
if record['phase'] != 'complete':
|
| 255 |
+
raise ValueError('final audit requires a completed checkpoint')
|
| 256 |
+
return verify_done(ctx, record, rehash_unchanged=False)
|
| 257 |
+
|
| 258 |
+
def current_remote(revision):
|
| 259 |
+
fixed = tree(revision, 'H2O')
|
| 260 |
+
with urllib.request.urlopen('https://huggingface.co/api/datasets/' + REPO + '?expand=sha', timeout=90) as response:
|
| 261 |
+
head = json.load(response)['sha']
|
| 262 |
+
live = tree(head, 'H2O')
|
| 263 |
+
for name in ('raw', 'shared-v1.0'):
|
| 264 |
+
path = 'H2O/' + name
|
| 265 |
+
if fixed[path]['oid'] != live[path]['oid']:
|
| 266 |
+
raise ValueError(f'HF {path} changed since source revision; investigate before migration')
|
| 267 |
+
return {'head': head, 'raw_tree_oid': fixed['H2O/raw']['oid'],
|
| 268 |
+
'source_tree_oid': fixed[PREFIX]['oid']}
|
| 269 |
+
|
| 270 |
+
|
| 271 |
+
|
| 272 |
+
def check_consumers(source):
|
| 273 |
+
executable = shutil.which('lsof')
|
| 274 |
+
if not executable:
|
| 275 |
+
raise RuntimeError('lsof required to check active dataset readers before maintenance')
|
| 276 |
+
result = subprocess.run([executable, '-u', str(os.getuid()), '-F', 'pn'],
|
| 277 |
+
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, timeout=60)
|
| 278 |
+
if result.returncode not in (0, 1):
|
| 279 |
+
raise RuntimeError('could not check dataset readers with lsof')
|
| 280 |
+
readers, pid = set(), None
|
| 281 |
+
prefix = str(source / 'data') + '/'
|
| 282 |
+
for line in result.stdout.splitlines():
|
| 283 |
+
if line.startswith('p'):
|
| 284 |
+
pid = line[1:]
|
| 285 |
+
elif line.startswith('n' + prefix) and not Path(line[1:]).is_dir():
|
| 286 |
+
readers.add(pid)
|
| 287 |
+
if readers:
|
| 288 |
+
raise RuntimeError('close active readers/converters before migration; PIDs: ' + ','.join(sorted(readers)))
|
| 289 |
+
|
| 290 |
+
|
| 291 |
+
def prepare(source, work, revision, approval):
|
| 292 |
+
for name, expected in BASE_DOC_HASHES.items():
|
| 293 |
+
checked_hash(source / 'doc' / name, expected)
|
| 294 |
+
approved = json.loads(approval.read_text())
|
| 295 |
+
if (not approved.get('passed') or approved['source_revision'] != revision
|
| 296 |
+
or approved.get('views') != 50 or approved.get('numeric_components') != 300):
|
| 297 |
+
raise ValueError('approved pilot must have passed automated checks on the same fixed source')
|
| 298 |
+
check_consumers(source)
|
| 299 |
+
remote = current_remote(revision)
|
| 300 |
+
marker = source / MARKER
|
| 301 |
+
if marker.exists():
|
| 302 |
+
raise ValueError('unregistered source maintenance marker')
|
| 303 |
+
root_hashes = {}
|
| 304 |
+
for folder in ('doc', 'script'):
|
| 305 |
+
prefix = PREFIX + '/'
|
| 306 |
+
entries = tree(revision, prefix + folder, recursive=True)
|
| 307 |
+
expected_files = {k.removeprefix(prefix):v for k,v in entries.items() if v['type'] == 'file'}
|
| 308 |
+
actual = {folder + '/' + f.relative_to(source / folder).as_posix()
|
| 309 |
+
for f in (source / folder).rglob('*') if f.is_file() and f.suffix != '.pyc'}
|
| 310 |
+
if actual != set(expected_files):
|
| 311 |
+
raise ValueError('root document/script file set differs from fixed HF')
|
| 312 |
+
for ref,entry in expected_files.items():
|
| 313 |
+
root_hashes[ref] = verify_source_file(resolve(source, ref), entry)
|
| 314 |
+
work.mkdir(parents=True, exist_ok=True)
|
| 315 |
+
if source.stat().st_dev != work.stat().st_dev:
|
| 316 |
+
raise ValueError('source, work and rollback backups must share a filesystem')
|
| 317 |
+
(work / 'inventory').mkdir(exist_ok=True)
|
| 318 |
+
for name in ('data', 'doc', 'script'):
|
| 319 |
+
if (source / name).is_symlink():
|
| 320 |
+
raise ValueError('source release directories must not be symlinks')
|
| 321 |
+
seqs = sorted(p.name for p in (source / 'data').iterdir() if p.is_dir())
|
| 322 |
+
if len(seqs) != 184:
|
| 323 |
+
raise ValueError('full H2O migration requires exactly 184 sequences')
|
| 324 |
+
for seq in seqs:
|
| 325 |
+
views = sorted((source / 'data' / seq).iterdir())
|
| 326 |
+
if [p.name for p in views] != [f'cam{i}' for i in range(5)] or any(not p.is_dir() or not (p / 'metainfo.json').is_file() for p in views):
|
| 327 |
+
raise ValueError('full H2O migration requires five complete cameras per sequence')
|
| 328 |
+
plan = {'source': str(source), 'source_revision': revision, 'sequences': seqs,
|
| 329 |
+
'tool_sha256': tools(), 'remote_baseline': remote, 'root_source_sha256': root_hashes, 'pilot_summary_sha256': sha256(approval),
|
| 330 |
+
'human_pilot_approval': {'date': '2026-10-10', 'scope': 'user reviewed index.html; individual page coverage unspecified',
|
| 331 |
+
'authorization': '我看了index.html没有问题。试点通过,开始全量'}, 'views': 920}
|
| 332 |
+
durable_json(work / 'PLAN.json', plan)
|
| 333 |
+
durable_json(work / 'RUN.json', {'phase': 'preparing_inventory', 'completed_views': 0,
|
| 334 |
+
'created_utc': datetime.now(timezone.utc).isoformat()})
|
| 335 |
+
return plan
|
| 336 |
+
|
| 337 |
+
|
| 338 |
+
def prepare_inventory(plan, work):
|
| 339 |
+
index_path = work / 'INVENTORY_INDEX.json'
|
| 340 |
+
index = json.loads(index_path.read_text()) if index_path.exists() else {}
|
| 341 |
+
for i, seq in enumerate(plan['sequences']):
|
| 342 |
+
path = work / 'inventory' / (seq + '.json')
|
| 343 |
+
if seq in index:
|
| 344 |
+
checked_hash(path, index[seq])
|
| 345 |
+
else:
|
| 346 |
+
rows = tree(plan['source_revision'], PREFIX + '/data/' + seq, recursive=True)
|
| 347 |
+
files = {k.removeprefix(PREFIX + '/'): v for k, v in rows.items() if v['type'] == 'file'}
|
| 348 |
+
durable_json(path, {'revision': plan['source_revision'], 'files': files})
|
| 349 |
+
index[seq] = sha256(path)
|
| 350 |
+
durable_json(index_path, index)
|
| 351 |
+
if (i + 1) % 50 == 0:
|
| 352 |
+
print('FULL_INVENTORY', i + 1, '/', len(plan['sequences']), flush=True)
|
| 353 |
+
if set(index) != set(plan['sequences']):
|
| 354 |
+
raise ValueError('inventory sequence set mismatch')
|
| 355 |
+
return index
|
| 356 |
+
|
| 357 |
+
|
| 358 |
+
def tasks(plan, work, index):
|
| 359 |
+
ctx = {'source': plan['source'], 'work': str(work), 'schema': str(HERE / 'spec/schema.json'),
|
| 360 |
+
'source_revision': plan['source_revision'], 'tool_sha256': plan['tool_sha256']}
|
| 361 |
+
for seq in plan['sequences']:
|
| 362 |
+
path = work / 'inventory' / (seq + '.json')
|
| 363 |
+
checked_hash(path, index[seq])
|
| 364 |
+
inventory = json.loads(path.read_text())
|
| 365 |
+
if inventory['revision'] != plan['source_revision']:
|
| 366 |
+
raise ValueError('inventory revision mismatch')
|
| 367 |
+
for cam in sorted((Path(plan['source']) / 'data' / seq).iterdir()):
|
| 368 |
+
if not cam.is_dir():
|
| 369 |
+
raise ValueError('unexpected sequence entry')
|
| 370 |
+
view = 'data/' + seq + '/' + cam.name
|
| 371 |
+
prefix = view + '/'
|
| 372 |
+
files = {k.removeprefix(prefix): v for k, v in inventory['files'].items() if k.startswith(prefix)}
|
| 373 |
+
yield (ctx | {'inventory_sha256': index[seq]}, view, files)
|
| 374 |
+
|
| 375 |
+
|
| 376 |
+
def bounded_pool(jobs, workers, on_result, worker_fn=worker):
|
| 377 |
+
iterator = iter(jobs)
|
| 378 |
+
pool = ProcessPoolExecutor(max_workers=workers, mp_context=multiprocessing.get_context('spawn'))
|
| 379 |
+
active = {}
|
| 380 |
+
try:
|
| 381 |
+
for _ in range(workers):
|
| 382 |
+
task = next(iterator, None)
|
| 383 |
+
if task is not None:
|
| 384 |
+
active[pool.submit(worker_fn, task)] = task[1]
|
| 385 |
+
while active:
|
| 386 |
+
done, _ = wait(active, return_when=FIRST_COMPLETED)
|
| 387 |
+
# Check all finished futures before scheduling any new work after a failure.
|
| 388 |
+
results = [(f, f.result()) for f in done]
|
| 389 |
+
for future, result in results:
|
| 390 |
+
del active[future]
|
| 391 |
+
on_result(result)
|
| 392 |
+
task = next(iterator, None)
|
| 393 |
+
if task is not None:
|
| 394 |
+
active[pool.submit(worker_fn, task)] = task[1]
|
| 395 |
+
finally:
|
| 396 |
+
for future in active:
|
| 397 |
+
future.cancel()
|
| 398 |
+
pool.shutdown(wait=True, cancel_futures=True)
|
| 399 |
+
|
| 400 |
+
|
| 401 |
+
def post_sample(source, seed):
|
| 402 |
+
rng = random.Random(seed)
|
| 403 |
+
candidates = []
|
| 404 |
+
for seq in sorted((source / 'data').iterdir()):
|
| 405 |
+
meta = json.loads((seq / 'cam0/metainfo.json').read_text())
|
| 406 |
+
features = {'subject:' + seq.name.split('_')[0], 'split:' + meta['split']}
|
| 407 |
+
features |= {'object:' + name.removeprefix('pose_') for name,c in meta['components'].items()
|
| 408 |
+
if name.startswith('pose_') and c.get('available')}
|
| 409 |
+
if seq.name == 'subject1_k2_6':
|
| 410 |
+
features.add('rgb:h264_fallback')
|
| 411 |
+
candidates.append((seq.name, features))
|
| 412 |
+
rng.shuffle(candidates)
|
| 413 |
+
remaining = set().union(*(features for _,features in candidates))
|
| 414 |
+
chosen = []
|
| 415 |
+
while remaining:
|
| 416 |
+
name, features = max((item for item in candidates if item[0] not in chosen),
|
| 417 |
+
key=lambda item: len(item[1] & remaining))
|
| 418 |
+
chosen.append(name)
|
| 419 |
+
remaining -= features
|
| 420 |
+
return {'sequences': sorted(chosen), 'seed': seed,
|
| 421 |
+
'scope': 'seeded representative complete sequences covering subjects, splits, all object classes and codec fallback; all five cameras'}
|
| 422 |
+
|
| 423 |
+
|
| 424 |
+
def install_documents(source, work, plan, summary):
|
| 425 |
+
# Root doc/script switches are recoverable two-step renames under maintenance.
|
| 426 |
+
pending = work / 'new-doc'
|
| 427 |
+
history = work / 'old-doc'
|
| 428 |
+
doc_installed = (source / 'doc/history-v1.0/schema.json').is_file()
|
| 429 |
+
if doc_installed and sha256(source / 'doc/schema.json') != sha256(HERE / 'spec/schema.json'):
|
| 430 |
+
raise ValueError('unexpected existing documentation history')
|
| 431 |
+
if not doc_installed and not history.exists() and not (pending / 'history-v1.0').exists():
|
| 432 |
+
if pending.exists():
|
| 433 |
+
shutil.rmtree(pending)
|
| 434 |
+
if not pending.exists():
|
| 435 |
+
pending.mkdir()
|
| 436 |
+
for name in ('schema.json', 'MIGRATION.md'):
|
| 437 |
+
shutil.copyfile(HERE / 'spec' / name, pending / name)
|
| 438 |
+
original_contract = (source / 'doc/CONTRACT.md').read_bytes()
|
| 439 |
+
(pending / 'V1_0_SEMANTICS.md').write_bytes(original_contract)
|
| 440 |
+
contract = (HERE / 'spec/CONTRACT.md').read_text().replace('../hand-warehouse-1.0/CONTRACT.md', 'V1_0_SEMANTICS.md')
|
| 441 |
+
contract = '\n'.join('状态:H2O v1.1 配套注册表与读写工具已适配;本地全量自动验收完成后仍须人工复查,HF 尚未发布。' if line.startswith('状态:合同草案') else line for line in contract.splitlines())
|
| 442 |
+
(pending / 'CONTRACT.md').write_text('> H2O v1.1 本地全量迁移;当前等待人工复查,尚未正式发布。\n\n' + contract)
|
| 443 |
+
pilot_doc = Path(plan['pilot_root']) / 'doc/RAW_TO_SHARED.md'
|
| 444 |
+
mapping = pilot_doc.read_text().replace('试点未修改源发布或 HF。', '本次仅原地调整 shared 数值存储,不修改 raw,不重编码媒体。')
|
| 445 |
+
mapping = mapping.replace('(迁移试点)', '(本地全量迁移)').replace('当前为 v1.1 存储迁移试点。', '当前为 v1.1 本地全量存储迁移。').replace('全量迁移和发布仍待人工批准。', '全量自动检查完成;全量后人工复查和 HF 发布尚待批准。')
|
| 446 |
+
(pending / 'RAW_TO_SHARED.md').write_text(mapping + '\n\n全量入口:script/h2o_v1_1/full.py。原 v1.0 文档及构建记录保留于 history-v1.0/;旧转换实现及配套规范在 script/v1_0_snapshot/。\n')
|
| 447 |
+
for f in pending.rglob('*'):
|
| 448 |
+
if f.is_file():
|
| 449 |
+
with f.open('rb') as stream:
|
| 450 |
+
os.fsync(stream.fileno())
|
| 451 |
+
sync_dir(pending)
|
| 452 |
+
os.replace(source / 'doc', history)
|
| 453 |
+
sync_dir(source)
|
| 454 |
+
sync_dir(work)
|
| 455 |
+
if history.exists() and not (pending / 'history-v1.0').exists() and pending.exists():
|
| 456 |
+
os.replace(history, pending / 'history-v1.0')
|
| 457 |
+
sync_dir(pending)
|
| 458 |
+
sync_dir(work)
|
| 459 |
+
if pending.exists():
|
| 460 |
+
if (source / 'doc').exists():
|
| 461 |
+
raise ValueError('refuse to overwrite unexpected doc directory')
|
| 462 |
+
os.replace(pending, source / 'doc')
|
| 463 |
+
sync_dir(source)
|
| 464 |
+
if not (source / 'doc/history-v1.0/schema.json').is_file():
|
| 465 |
+
raise ValueError('original documentation history missing')
|
| 466 |
+
old_script, new_script = work / 'old-script', work / 'new-script'
|
| 467 |
+
if not old_script.exists():
|
| 468 |
+
if new_script.exists():
|
| 469 |
+
shutil.rmtree(new_script)
|
| 470 |
+
if not new_script.exists():
|
| 471 |
+
new_script.mkdir()
|
| 472 |
+
shutil.copytree(HERE, new_script / 'h2o_v1_1', ignore=shutil.ignore_patterns('__pycache__', '*.pyc'))
|
| 473 |
+
shutil.copytree(source / 'script', new_script / 'v1_0_snapshot/script', ignore=shutil.ignore_patterns('__pycache__', '*.pyc'))
|
| 474 |
+
(new_script / 'v1_0_snapshot/doc').mkdir()
|
| 475 |
+
for name in BASE_DOC_HASHES:
|
| 476 |
+
shutil.copyfile(source / 'doc/history-v1.0' / name, new_script / 'v1_0_snapshot/doc' / name)
|
| 477 |
+
for f in new_script.rglob('*'):
|
| 478 |
+
if f.is_file():
|
| 479 |
+
with f.open('rb') as stream:
|
| 480 |
+
os.fsync(stream.fileno())
|
| 481 |
+
for directory, _, _ in os.walk(new_script, topdown=False):
|
| 482 |
+
sync_dir(directory)
|
| 483 |
+
os.replace(source / 'script', old_script)
|
| 484 |
+
sync_dir(source)
|
| 485 |
+
sync_dir(work)
|
| 486 |
+
if new_script.exists():
|
| 487 |
+
if (source / 'script').exists():
|
| 488 |
+
raise ValueError('refuse to overwrite unexpected script directory')
|
| 489 |
+
os.replace(new_script, source / 'script')
|
| 490 |
+
sync_dir(source)
|
| 491 |
+
for ref,digest in plan.get('root_source_sha256', {}).items():
|
| 492 |
+
folder,relative = ref.split('/',1)
|
| 493 |
+
path = (source / 'doc/history-v1.0' / relative if folder == 'doc' else
|
| 494 |
+
source / 'script/v1_0_snapshot/script' / relative)
|
| 495 |
+
checked_hash(path, digest)
|
| 496 |
+
durable_json(source / 'doc/FULL_MIGRATION_SUMMARY.json', summary)
|
| 497 |
+
|
| 498 |
+
|
| 499 |
+
|
| 500 |
+
|
| 501 |
+
def publish_manifest(source, work, plan, state):
|
| 502 |
+
"""Reuse the already-checked media digest; do not read 644 GB a second time."""
|
| 503 |
+
files = {}
|
| 504 |
+
for seq in plan['sequences']:
|
| 505 |
+
for cam in range(5):
|
| 506 |
+
record = json.loads((work / 'checkpoints' / seq / f'cam{cam}.json').read_text())
|
| 507 |
+
if record['phase'] != 'complete':
|
| 508 |
+
raise ValueError('release manifest requires all completed views')
|
| 509 |
+
for ref,digest in (record['unchanged_sha256'] | record['changed_sha256']).items():
|
| 510 |
+
key = record['view'] + '/' + ref
|
| 511 |
+
if key in files:
|
| 512 |
+
raise ValueError('duplicate release path')
|
| 513 |
+
files[key] = {'sha256':digest, 'size':(source / key).stat().st_size}
|
| 514 |
+
for folder in ('doc','script'):
|
| 515 |
+
for path in sorted((source / folder).rglob('*')):
|
| 516 |
+
if path.is_file() and path.suffix != '.pyc' and '__pycache__' not in path.parts:
|
| 517 |
+
if path.is_symlink():
|
| 518 |
+
raise ValueError('symlinks cannot be published')
|
| 519 |
+
files[path.relative_to(source).as_posix()] = {'sha256':sha256(path), 'size':path.stat().st_size}
|
| 520 |
+
actual = {p.relative_to(source).as_posix() for p in source.rglob('*') if p.is_file()
|
| 521 |
+
and p.name != MARKER and p.suffix != '.pyc' and '__pycache__' not in p.parts}
|
| 522 |
+
if actual != set(files):
|
| 523 |
+
raise ValueError('release manifest file set mismatch')
|
| 524 |
+
durable_json(work / 'PUBLISH_MANIFEST.json', {'release_id':'shared-v1.1',
|
| 525 |
+
'source_revision':plan['source_revision'], 'raw_tree_oid':plan['remote_baseline']['raw_tree_oid'],
|
| 526 |
+
'phase':state['phase'], 'files':files, 'file_count':len(files),
|
| 527 |
+
'excluded_runtime_files':['*.pyc','__pycache__',MARKER],
|
| 528 |
+
'scope':'data hashes verified against fixed HF / exact new bundles; docs and code freshly hashed; publication not performed'})
|
| 529 |
+
|
| 530 |
+
def rename_no_replace(source, target):
|
| 531 |
+
# Linux renameat2 keeps the no-overwrite rule atomic, even for an empty target.
|
| 532 |
+
fn = ctypes.CDLL(None, use_errno=True).renameat2
|
| 533 |
+
fn.argtypes = [ctypes.c_int, ctypes.c_char_p, ctypes.c_int, ctypes.c_char_p, ctypes.c_uint]
|
| 534 |
+
fn.restype = ctypes.c_int
|
| 535 |
+
if fn(-100, os.fsencode(source), -100, os.fsencode(target), 1) != 0:
|
| 536 |
+
code = ctypes.get_errno()
|
| 537 |
+
raise OSError(code, os.strerror(code), str(target))
|
| 538 |
+
|
| 539 |
+
|
| 540 |
+
def main(argv=None):
|
| 541 |
+
p = argparse.ArgumentParser(description=__doc__)
|
| 542 |
+
p.add_argument('--source', type=Path, required=True)
|
| 543 |
+
p.add_argument('--work', type=Path, required=True)
|
| 544 |
+
p.add_argument('--source-revision', required=True)
|
| 545 |
+
p.add_argument('--pilot-summary', type=Path, required=True)
|
| 546 |
+
p.add_argument('--workers', type=int, default=4)
|
| 547 |
+
p.add_argument('--human-pilot-approved', action='store_true')
|
| 548 |
+
p.add_argument('--finalize-after-review', action='store_true')
|
| 549 |
+
args = p.parse_args(argv)
|
| 550 |
+
if not args.human_pilot_approved and not args.finalize_after_review:
|
| 551 |
+
p.error('explicit --human-pilot-approved required before full migration')
|
| 552 |
+
source, work = args.source.resolve(), args.work.resolve()
|
| 553 |
+
if (source.name != 'shared-v1.0' or source.parent.name != 'H2O'
|
| 554 |
+
or not work.is_relative_to(source.parent / 'tmp') or work == source.parent / 'tmp'):
|
| 555 |
+
p.error('require H2O/shared-v1.0 and a dedicated work directory under H2O/tmp')
|
| 556 |
+
if not 1 <= args.workers <= 8:
|
| 557 |
+
p.error('1–8 view workers; one Torch thread per worker')
|
| 558 |
+
target = source.with_name('shared-v1.1')
|
| 559 |
+
recovering_rename = (args.finalize_after_review and not source.exists() and target.is_dir()
|
| 560 |
+
and (work / 'RUN.json').is_file()
|
| 561 |
+
and json.loads((work / 'RUN.json').read_text())['phase'] in
|
| 562 |
+
('finalizing_local', 'local_finalized_not_uploaded'))
|
| 563 |
+
if (not source.is_dir() or target.exists()) and not recovering_rename:
|
| 564 |
+
p.error('source missing or target shared-v1.1 already exists; do not overwrite/merge')
|
| 565 |
+
if shutil.disk_usage(source.parent).free < 20 * 1024**3:
|
| 566 |
+
p.error('need at least 20 GiB free for bundles, checkpoints and rollback')
|
| 567 |
+
if work.exists() and not (work / 'PLAN.json').exists():
|
| 568 |
+
p.error('existing unregistered work directory; refuse to overwrite')
|
| 569 |
+
for key in ('OMP_NUM_THREADS', 'MKL_NUM_THREADS', 'OPENBLAS_NUM_THREADS', 'NUMEXPR_NUM_THREADS', 'HAND_WAREHOUSE_FFMPEG_THREADS'):
|
| 570 |
+
os.environ[key] = '1'
|
| 571 |
+
with lock(source.parent / 'tmp/H2O_V1_1.lock'):
|
| 572 |
+
if (work / 'PLAN.json').exists():
|
| 573 |
+
plan = json.loads((work / 'PLAN.json').read_text())
|
| 574 |
+
if plan['source'] != str(source) or plan['source_revision'] != args.source_revision or plan['tool_sha256'] != tools():
|
| 575 |
+
raise ValueError('resume source/tool fingerprint mismatch')
|
| 576 |
+
else:
|
| 577 |
+
plan = prepare(source, work, args.source_revision, args.pilot_summary.resolve())
|
| 578 |
+
plan['pilot_root'] = str(args.pilot_summary.resolve().parents[2])
|
| 579 |
+
durable_json(work / 'PLAN.json', plan)
|
| 580 |
+
state = json.loads((work / 'RUN.json').read_text())
|
| 581 |
+
if state['phase'] == 'local_finalized_not_uploaded':
|
| 582 |
+
final_marker = target / MARKER
|
| 583 |
+
if final_marker.exists():
|
| 584 |
+
if json.loads(final_marker.read_text())['work'] != str(work):
|
| 585 |
+
raise ValueError('foreign maintenance marker on final target')
|
| 586 |
+
final_marker.unlink(); sync_dir(target)
|
| 587 |
+
print('LOCAL_FINALIZED', state['final_root'], 'HF publication not performed', flush=True)
|
| 588 |
+
return
|
| 589 |
+
marker = (target if recovering_rename else source) / MARKER
|
| 590 |
+
if recovering_rename and not marker.is_file():
|
| 591 |
+
raise ValueError('renamed target lacks its owned recovery marker')
|
| 592 |
+
if marker.exists() and json.loads(marker.read_text())['work'] != str(work):
|
| 593 |
+
raise ValueError('another work directory owns maintenance state')
|
| 594 |
+
durable_json(marker, {'work': str(work), 'phase': state['phase'], 'source_revision': args.source_revision,
|
| 595 |
+
'notice': 'maintenance: no training/conversion/upload; HTML review only'})
|
| 596 |
+
if args.finalize_after_review:
|
| 597 |
+
if state['phase'] not in ('awaiting_full_human_review', 'finalizing_local'):
|
| 598 |
+
raise ValueError('finalize requires completed full checks and separate human approval')
|
| 599 |
+
if source.exists():
|
| 600 |
+
check_consumers(source)
|
| 601 |
+
manifest = json.loads((work / 'PUBLISH_MANIFEST.json').read_text())
|
| 602 |
+
for ref,entry in manifest['files'].items():
|
| 603 |
+
if not ref.startswith('data/'):
|
| 604 |
+
checked_hash(resolve(source, ref), entry['sha256'])
|
| 605 |
+
index = json.loads((work / 'INVENTORY_INDEX.json').read_text())
|
| 606 |
+
bounded_pool(tasks(plan, work, index), args.workers, lambda _:None, audit_worker)
|
| 607 |
+
state['phase'] = 'finalizing_local'
|
| 608 |
+
durable_json(work / 'RUN.json', state)
|
| 609 |
+
rename_no_replace(source, target)
|
| 610 |
+
elif not marker.is_file() or json.loads(marker.read_text())['work'] != str(work):
|
| 611 |
+
raise ValueError('renamed target is not owned by this maintenance operation')
|
| 612 |
+
sync_dir(source.parent)
|
| 613 |
+
state.update(phase='local_finalized_not_uploaded', final_root=str(target))
|
| 614 |
+
state['human_full_approval'] = {'authorization':'--finalize-after-review', 'recorded_utc':datetime.now(timezone.utc).isoformat()}
|
| 615 |
+
state['index_html'] = str(source.with_name('shared-v1.1') / 'doc/validation/index.html')
|
| 616 |
+
summary_path = source.with_name('shared-v1.1') / 'doc/validation/FULL_MIGRATION_SUMMARY.json'
|
| 617 |
+
summary = json.loads(summary_path.read_text())
|
| 618 |
+
durable_json(summary_path, summary | state)
|
| 619 |
+
final_root = source.with_name('shared-v1.1')
|
| 620 |
+
durable_json(final_root / 'doc/FULL_MIGRATION_SUMMARY.json', summary | state)
|
| 621 |
+
publish_manifest(final_root, work, plan, state)
|
| 622 |
+
durable_json(work / 'RUN.json', state)
|
| 623 |
+
(final_root / MARKER).unlink()
|
| 624 |
+
sync_dir(final_root)
|
| 625 |
+
print('LOCAL_FINALIZED', state['final_root'], 'HF upload still requires separate authorization', flush=True)
|
| 626 |
+
return
|
| 627 |
+
if state['phase'] == 'awaiting_full_human_review':
|
| 628 |
+
print('AWAITING_FULL_HUMAN_REVIEW', source / 'doc/validation/index.html', flush=True)
|
| 629 |
+
return
|
| 630 |
+
try:
|
| 631 |
+
started = time.monotonic()
|
| 632 |
+
if state.get('inventory_index_sha256'):
|
| 633 |
+
checked_hash(work / 'INVENTORY_INDEX.json', state['inventory_index_sha256'])
|
| 634 |
+
index = prepare_inventory(plan, work)
|
| 635 |
+
state.update(phase='migrating', completed_views=0, workers=args.workers,
|
| 636 |
+
inventory_index_sha256=sha256(work / 'INVENTORY_INDEX.json'))
|
| 637 |
+
durable_json(work / 'RUN.json', state)
|
| 638 |
+
durable_json(marker, {'work': str(work), 'phase': 'migrating', 'source_revision': args.source_revision,
|
| 639 |
+
'notice': 'maintenance: no training/conversion/upload; HTML review only'})
|
| 640 |
+
totals = {'num_frames': 0, 'source_files': 0, 'target_files': 0}
|
| 641 |
+
def progress(record):
|
| 642 |
+
state['completed_views'] += 1
|
| 643 |
+
for k in totals:
|
| 644 |
+
totals[k] += record[k]
|
| 645 |
+
if state['completed_views'] % 10 == 0:
|
| 646 |
+
state.update(totals, elapsed_seconds=time.monotonic() - started)
|
| 647 |
+
durable_json(work / 'RUN.json', state)
|
| 648 |
+
state['estimated_remaining_seconds'] = state['elapsed_seconds'] * (920-state['completed_views']) / state['completed_views']
|
| 649 |
+
durable_json(work / 'RUN.json', state)
|
| 650 |
+
print('FULL_PROGRESS', state['completed_views'], '/ 920', round(state['elapsed_seconds'], 1), 'seconds', 'ETA', round(state['estimated_remaining_seconds']), flush=True)
|
| 651 |
+
bounded_pool(tasks(plan, work, index), args.workers, progress)
|
| 652 |
+
if state['completed_views'] != 920 or totals['num_frames'] != 571645:
|
| 653 |
+
raise ValueError('full view/frame coverage mismatch')
|
| 654 |
+
state.update(phase='final_verification', **totals, elapsed_seconds=time.monotonic() - started)
|
| 655 |
+
durable_json(work / 'RUN.json', state)
|
| 656 |
+
# Second pass checks current output hashes, all keys and rollback numerical bytes.
|
| 657 |
+
verified = 0
|
| 658 |
+
def verified_progress(_):
|
| 659 |
+
nonlocal verified
|
| 660 |
+
verified += 1
|
| 661 |
+
if verified % 100 == 0:
|
| 662 |
+
print('FULL_VERIFIED', verified, '/ 920', flush=True)
|
| 663 |
+
bounded_pool(tasks(plan, work, index), args.workers, verified_progress, audit_worker)
|
| 664 |
+
if verified != 920:
|
| 665 |
+
raise ValueError('final verification incomplete')
|
| 666 |
+
summary = state | {'phase': 'full_numeric_passed_pending_post_sample',
|
| 667 |
+
'source_revision': args.source_revision, 'raw_tree_oid': plan['remote_baseline']['raw_tree_oid'],
|
| 668 |
+
'all_numeric_bytes_exact': True, 'all_source_data_files_match_fixed_hf': True,
|
| 669 |
+
'all_changed_file_hashes_verified': True, 'unchanged_file_fingerprints_stable': True,
|
| 670 |
+
'media_verification': 'one encoded-file hash pass against fixed HF; unchanged inode/size/mtime rechecked under maintenance; no all-video pixel comparison', 'backup_root': str(work / 'backups'),
|
| 671 |
+
'saved_data_files': totals['source_files'] - totals['target_files'],
|
| 672 |
+
'scope': '184 sequences, 920 cameras, 571645 view-frame entries (114329 synchronized frames); human post-full review and HF publication pending'}
|
| 673 |
+
state['phase'] = 'installing_documents'
|
| 674 |
+
durable_json(work / 'RUN.json', state)
|
| 675 |
+
install_documents(source, work, plan, summary)
|
| 676 |
+
sampled = post_sample(source, args.source_revision + ':post-full:2026-10-10')
|
| 677 |
+
durable_json(work / 'POST_FULL_SAMPLE.json', sampled)
|
| 678 |
+
state['phase'] = 'rendering_post_full_sample'
|
| 679 |
+
durable_json(work / 'RUN.json', state)
|
| 680 |
+
subprocess.run([sys.executable, str(source / 'script/h2o_v1_1/render.py'), str(source),
|
| 681 |
+
'--workers', str(args.workers), '--sequences-file', str(work / 'POST_FULL_SAMPLE.json')], check=True)
|
| 682 |
+
current = current_remote(args.source_revision)
|
| 683 |
+
if current['raw_tree_oid'] != plan['remote_baseline']['raw_tree_oid']:
|
| 684 |
+
raise ValueError('HF raw tree changed')
|
| 685 |
+
state.update(phase='awaiting_full_human_review', elapsed_seconds=time.monotonic() - started,
|
| 686 |
+
index_html=str(source / 'doc/validation/index.html'), hf_writes=False)
|
| 687 |
+
durable_json(work / 'RUN.json', state)
|
| 688 |
+
durable_json(source / 'doc/validation/FULL_MIGRATION_SUMMARY.json', summary | state)
|
| 689 |
+
durable_json(source / 'doc/FULL_MIGRATION_SUMMARY.json', summary | state)
|
| 690 |
+
publish_manifest(source, work, plan, state)
|
| 691 |
+
durable_json(marker, {'work': str(work), 'phase': state['phase'], 'notice': 'full local checks passed; await human post-full review before rename/upload'})
|
| 692 |
+
print('FULL_LOCAL_DONE_AWAITING_REVIEW', state['index_html'], flush=True)
|
| 693 |
+
except Exception as exc:
|
| 694 |
+
state.update(failed_phase=state['phase'], phase='failed', error=repr(exc))
|
| 695 |
+
durable_json(work / 'RUN.json', state)
|
| 696 |
+
print('FULL_FAILED_RECOVERABLE', repr(exc), 'work', work, flush=True)
|
| 697 |
+
raise
|
| 698 |
+
|
| 699 |
+
|
| 700 |
+
if __name__ == '__main__':
|
| 701 |
+
main()
|
H2O/shared-v1.1/script/h2o_v1_1/pilot.py
ADDED
|
@@ -0,0 +1,344 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Read-only-source H2O v1.1 pilot; HF is read-only, full migration is gated."""
|
| 3 |
+
import argparse
|
| 4 |
+
from concurrent.futures import ProcessPoolExecutor, as_completed
|
| 5 |
+
from datetime import datetime, timezone
|
| 6 |
+
import hashlib
|
| 7 |
+
import fcntl
|
| 8 |
+
import json
|
| 9 |
+
import multiprocessing
|
| 10 |
+
import os
|
| 11 |
+
from pathlib import Path
|
| 12 |
+
import re
|
| 13 |
+
import shutil
|
| 14 |
+
import time
|
| 15 |
+
import urllib.parse
|
| 16 |
+
import urllib.request
|
| 17 |
+
import urllib.error
|
| 18 |
+
|
| 19 |
+
if __package__:
|
| 20 |
+
from .warehouse import PROFILE, Reader, exact, layout, resolve, sha256, validate_view, exact_metadata
|
| 21 |
+
else:
|
| 22 |
+
from warehouse import PROFILE, Reader, exact, layout, resolve, sha256, validate_view, exact_metadata
|
| 23 |
+
|
| 24 |
+
REPO = 'ParityLab/Hand-Datasets-Raw'
|
| 25 |
+
PREFIX = 'H2O/shared-v1.0'
|
| 26 |
+
BASE_DOC_HASHES = {
|
| 27 |
+
'CONTRACT.md': '8c0a0caa3d66a3984278dea36a5f18e925f2b878fb926f6b9ef41b76a4f37784',
|
| 28 |
+
'schema.json': '4b60ce367de7703ca07b7f016a844fc457da0e1040bbda1f0dd9486cc34bd5d2',
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def write_json(path, value):
|
| 33 |
+
path = Path(path)
|
| 34 |
+
path.parent.mkdir(parents=True, exist_ok=True)
|
| 35 |
+
tmp = path.with_name(path.name + '.tmp')
|
| 36 |
+
tmp.write_text(json.dumps(value, ensure_ascii=False, indent=2, allow_nan=False) + '\n')
|
| 37 |
+
os.replace(tmp, path)
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def tree(revision, folder, recursive=False):
|
| 41 |
+
if not re.fullmatch(r'[0-9a-f]{40}', revision):
|
| 42 |
+
raise ValueError('source revision must be a fixed commit SHA')
|
| 43 |
+
url = 'https://huggingface.co/api/datasets/' + REPO + '/tree/' + revision + '/' + urllib.parse.quote(folder, safe='/')
|
| 44 |
+
url += '?recursive=' + str(recursive).lower() + '&limit=1000'
|
| 45 |
+
result = {}
|
| 46 |
+
while url:
|
| 47 |
+
if urllib.parse.urlsplit(url).hostname != 'huggingface.co':
|
| 48 |
+
raise ValueError('untrusted pagination URL')
|
| 49 |
+
for attempt in range(5):
|
| 50 |
+
try:
|
| 51 |
+
response = urllib.request.urlopen(url, timeout=90)
|
| 52 |
+
break
|
| 53 |
+
except (urllib.error.URLError, TimeoutError) as exc:
|
| 54 |
+
if isinstance(exc, urllib.error.HTTPError) and exc.code not in (429,500,502,503,504):
|
| 55 |
+
raise
|
| 56 |
+
if attempt == 4:
|
| 57 |
+
raise
|
| 58 |
+
retry = exc.headers.get('Retry-After', '') if isinstance(exc, urllib.error.HTTPError) else ''
|
| 59 |
+
delay = min(60, int(retry)) if retry.isdigit() else min(30, 2**attempt)
|
| 60 |
+
print('HF_READ_RETRY', attempt+1, 'delay', delay, flush=True)
|
| 61 |
+
time.sleep(delay)
|
| 62 |
+
with response:
|
| 63 |
+
for row in json.load(response):
|
| 64 |
+
if row['path'] in result:
|
| 65 |
+
raise ValueError('duplicate HF inventory path')
|
| 66 |
+
result[row['path']] = row
|
| 67 |
+
link = response.headers.get('Link', '')
|
| 68 |
+
match = re.search(r'<([^>]+)>;\s*rel="next"', link)
|
| 69 |
+
url = match[1] if match else None
|
| 70 |
+
return result
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def stamp(path):
|
| 74 |
+
s = path.stat()
|
| 75 |
+
return s.st_dev, s.st_ino, s.st_size, s.st_mtime_ns
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def verify_source_file(path, entry):
|
| 79 |
+
before = stamp(path)
|
| 80 |
+
if path.is_symlink() or before[2] != entry['size']:
|
| 81 |
+
raise ValueError(f'source size/symlink mismatch: {path}')
|
| 82 |
+
sha = hashlib.sha256()
|
| 83 |
+
git = hashlib.sha1(f'blob {entry["size"]}\0'.encode())
|
| 84 |
+
with path.open('rb') as stream:
|
| 85 |
+
while chunk := stream.read(4 * 1024 * 1024):
|
| 86 |
+
sha.update(chunk)
|
| 87 |
+
if not entry.get('lfs'):
|
| 88 |
+
git.update(chunk)
|
| 89 |
+
expected = entry['lfs'].get('oid', entry['lfs'].get('sha256')) if entry.get('lfs') else entry['oid']
|
| 90 |
+
digest = sha.hexdigest() if entry.get('lfs') else git.hexdigest()
|
| 91 |
+
if digest != expected or stamp(path) != before:
|
| 92 |
+
raise ValueError(f'local source differs from fixed HF commit or changed during read: {path}')
|
| 93 |
+
return sha.hexdigest()
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
def select_sequences(source):
|
| 97 |
+
candidates = {}
|
| 98 |
+
for seq in sorted((source / 'data').iterdir()):
|
| 99 |
+
views = sorted(seq.iterdir())
|
| 100 |
+
if [v.name for v in views] != [f'cam{i}' for i in range(5)] or any(not v.is_dir() for v in views):
|
| 101 |
+
raise ValueError(f'expected five complete camera views: {seq}')
|
| 102 |
+
meta = json.loads((views[0] / 'metainfo.json').read_text())
|
| 103 |
+
features = {'subject:' + seq.name.split('_')[0], 'split:' + meta['split']}
|
| 104 |
+
features |= {'object:' + n.removeprefix('pose_') for n,c in meta['components'].items()
|
| 105 |
+
if n.startswith('pose_') and c.get('available')}
|
| 106 |
+
receipt = source / 'doc' / (seq.name + '.build.json')
|
| 107 |
+
if receipt.is_file():
|
| 108 |
+
annotations = json.loads(receipt.read_text())['views']
|
| 109 |
+
for view in annotations.values():
|
| 110 |
+
for n,c in view.get('annotation_validity', {}).items():
|
| 111 |
+
features.add('valid:' + n.split('_', 1)[0] + ':' +
|
| 112 |
+
('mixed' if c.get('valid_count', 0) and c.get('invalid_count', 0) else
|
| 113 |
+
'invalid' if c.get('invalid_count', 0) else 'valid'))
|
| 114 |
+
if seq.name == 'subject1_k2_6':
|
| 115 |
+
features.add('rgb:h264_fallback')
|
| 116 |
+
candidates[seq.name] = (features, meta['num_frames'])
|
| 117 |
+
if not candidates:
|
| 118 |
+
raise ValueError('empty dataset')
|
| 119 |
+
remaining = set().union(*(f for f,_ in candidates.values()))
|
| 120 |
+
chosen = []
|
| 121 |
+
while remaining:
|
| 122 |
+
name = max((n for n in candidates if n not in chosen),
|
| 123 |
+
key=lambda n: (len(candidates[n][0] & remaining), n))
|
| 124 |
+
chosen.append(name)
|
| 125 |
+
remaining -= candidates[name][0]
|
| 126 |
+
for name in (min(candidates, key=lambda n: candidates[n][1]), max(candidates, key=lambda n: candidates[n][1])):
|
| 127 |
+
if name not in chosen:
|
| 128 |
+
chosen.append(name)
|
| 129 |
+
return sorted(chosen), sorted(set().union(*(candidates[n][0] for n in chosen)))
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
def migrate_view(task):
|
| 133 |
+
import torch
|
| 134 |
+
torch.set_num_threads(1)
|
| 135 |
+
if torch.get_num_interop_threads() != 1:
|
| 136 |
+
torch.set_num_interop_threads(1)
|
| 137 |
+
source, target, schema_path, inventory = task
|
| 138 |
+
source, target = Path(source), Path(target)
|
| 139 |
+
started = time.monotonic()
|
| 140 |
+
original = json.loads((source / 'metainfo.json').read_text())
|
| 141 |
+
if original['schema_version'] != 'hand-warehouse/1.0' or original['release_id'] != 'shared-v1.0':
|
| 142 |
+
raise ValueError('source must be the unmigrated v1.0 release')
|
| 143 |
+
if original.get('dataset_id') != 'H2O' or original['camera_id'] != source.name or target.name != source.name:
|
| 144 |
+
raise ValueError('H2O camera metadata/path mismatch')
|
| 145 |
+
meta = json.loads(json.dumps(original))
|
| 146 |
+
reader, bundles, replaced, source_hashes = Reader(source), {}, set(), {}
|
| 147 |
+
actual = {p.relative_to(source).as_posix(): p for p in source.rglob('*') if p.is_file()}
|
| 148 |
+
if any(p.is_symlink() for p in source.rglob('*')):
|
| 149 |
+
raise ValueError('source symlinks are not permitted')
|
| 150 |
+
before = {ref: stamp(path) for ref,path in actual.items()}
|
| 151 |
+
verify_started = time.monotonic()
|
| 152 |
+
if set(actual) != set(inventory):
|
| 153 |
+
raise ValueError(f'local vs HF source file set mismatch: {source}')
|
| 154 |
+
print('VERIFY_VIEW', '/'.join(source.parts[-2:]), flush=True)
|
| 155 |
+
for ref, path in actual.items():
|
| 156 |
+
source_hashes[ref] = verify_source_file(path, inventory[ref])
|
| 157 |
+
verify_seconds = time.monotonic() - verify_started
|
| 158 |
+
pack_started = time.monotonic()
|
| 159 |
+
for name, c in meta['components'].items():
|
| 160 |
+
if not c.get('available') or not c['data_ref'].endswith('.pt'):
|
| 161 |
+
continue
|
| 162 |
+
ref, keys = layout(name, c)
|
| 163 |
+
data, valid = reader.field(c), reader.field(c, 'valid')
|
| 164 |
+
if valid.dtype != torch.bool:
|
| 165 |
+
raise ValueError('source validity must be bool')
|
| 166 |
+
replaced.update((c['data_ref'], c['valid_ref']))
|
| 167 |
+
node = bundles.setdefault(ref, {})
|
| 168 |
+
for key in keys[:-1]:
|
| 169 |
+
node = node.setdefault(key, {})
|
| 170 |
+
if keys[-1] in node:
|
| 171 |
+
raise ValueError('duplicate numeric bundle field')
|
| 172 |
+
node[keys[-1]] = {'data': data, 'valid': valid}
|
| 173 |
+
c.update(data_ref=ref, data_key=keys + ['data'], valid_ref=ref, valid_key=keys + ['valid'],
|
| 174 |
+
storage={'profile': PROFILE}, valid_storage={'profile': PROFILE})
|
| 175 |
+
if target.exists():
|
| 176 |
+
raise ValueError(f'target already exists: {target}')
|
| 177 |
+
staging = target.with_name('.tmp-' + target.name)
|
| 178 |
+
staging.mkdir(parents=True, exist_ok=False)
|
| 179 |
+
unchanged = {}
|
| 180 |
+
for ref, path in actual.items():
|
| 181 |
+
if ref in replaced or ref == 'metainfo.json':
|
| 182 |
+
continue
|
| 183 |
+
dest = staging / ref
|
| 184 |
+
dest.parent.mkdir(parents=True, exist_ok=True)
|
| 185 |
+
os.link(path, dest) # Pilot only: unchanged files share storage; never write these links.
|
| 186 |
+
if not os.path.samefile(path, dest) or stamp(path) != before[ref]:
|
| 187 |
+
raise ValueError(f'unchanged file mismatch: {ref}')
|
| 188 |
+
unchanged[ref] = source_hashes[ref]
|
| 189 |
+
for ref, bundle in bundles.items():
|
| 190 |
+
dest = staging / ref
|
| 191 |
+
dest.parent.mkdir(parents=True, exist_ok=True)
|
| 192 |
+
tmp = dest.with_name(dest.name + '.tmp')
|
| 193 |
+
torch.save(bundle, tmp)
|
| 194 |
+
os.replace(tmp, dest)
|
| 195 |
+
meta.update(schema_version='hand-warehouse/1.1', release_id='shared-v1.1')
|
| 196 |
+
write_json(staging / 'metainfo.json', meta)
|
| 197 |
+
validation = validate_view(staging, schema_path)
|
| 198 |
+
saved = Reader(staging)
|
| 199 |
+
for name, old in original['components'].items():
|
| 200 |
+
if old.get('available') and old['data_ref'].endswith('.pt'):
|
| 201 |
+
for kind in ('data', 'valid'):
|
| 202 |
+
exact(reader.field(old, kind), saved.field(meta['components'][name], kind))
|
| 203 |
+
elif old != meta['components'][name]:
|
| 204 |
+
raise ValueError('non-numerical component metadata changed')
|
| 205 |
+
exact_metadata(original, meta)
|
| 206 |
+
output_hashes = {p.relative_to(staging).as_posix(): sha256(p)
|
| 207 |
+
for p in staging.rglob('*') if p.is_file() and p.relative_to(staging).as_posix() not in unchanged}
|
| 208 |
+
if any(stamp(path) != before[ref] for ref,path in actual.items()):
|
| 209 |
+
raise ValueError('source changed during migration; retain private staging for investigation')
|
| 210 |
+
os.replace(staging, target)
|
| 211 |
+
return {'view': '/'.join(target.parts[-3:]), 'num_frames': meta['num_frames'],
|
| 212 |
+
'seconds': time.monotonic() - started, 'verify_seconds': verify_seconds,
|
| 213 |
+
'pack_seconds': time.monotonic() - pack_started,
|
| 214 |
+
'source_bytes': sum(s[2] for s in before.values()), 'source_sha256': source_hashes,
|
| 215 |
+
'unchanged_sha256': unchanged,
|
| 216 |
+
'unchanged_stamp': {ref:list(before[ref]) for ref in unchanged}, 'changed_sha256': output_hashes,
|
| 217 |
+
'removed_numeric_paths': sorted(replaced), 'new_bundle_paths': sorted(bundles),
|
| 218 |
+
'source_files': len(actual), 'target_files': len(unchanged) + len(output_hashes),
|
| 219 |
+
'numeric_bytes_exact': True, 'source_matches_fixed_hf': True, 'validation': validation}
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
def main(argv=None):
|
| 223 |
+
p = argparse.ArgumentParser(description=__doc__)
|
| 224 |
+
p.add_argument('--source', required=True, type=Path)
|
| 225 |
+
p.add_argument('--out', required=True, type=Path)
|
| 226 |
+
p.add_argument('--source-revision', required=True)
|
| 227 |
+
p.add_argument('--workers', type=int, default=4)
|
| 228 |
+
args = p.parse_args(argv)
|
| 229 |
+
source, out = args.source.resolve(), args.out.resolve()
|
| 230 |
+
if not 1 <= args.workers <= 8:
|
| 231 |
+
p.error('pilot supports 1–8 workers, one Torch thread per worker')
|
| 232 |
+
if out.exists() or out.is_relative_to(source) or source.is_relative_to(out):
|
| 233 |
+
p.error('pilot output must be a new directory outside the source release')
|
| 234 |
+
if source.stat().st_dev != out.parent.stat().st_dev:
|
| 235 |
+
p.error('pilot must be on the same filesystem; unchanged media are hardlinked, not copied')
|
| 236 |
+
for name, expected in BASE_DOC_HASHES.items():
|
| 237 |
+
if sha256(source / 'doc' / name) != expected:
|
| 238 |
+
raise ValueError('source contract/schema differ from the verified fixed HF version')
|
| 239 |
+
lock = (out.parent / 'h2o-v1.1-pilot.lock').open('a')
|
| 240 |
+
fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
| 241 |
+
chosen, coverage = select_sequences(source)
|
| 242 |
+
print('PILOT_SELECTION', json.dumps({'sequences':chosen, 'views':5*len(chosen), 'coverage':coverage}), flush=True)
|
| 243 |
+
started = time.monotonic()
|
| 244 |
+
baseline = tree(args.source_revision, 'H2O')
|
| 245 |
+
if 'H2O/shared-v1.1' in baseline:
|
| 246 |
+
raise ValueError('pinned source already has shared-v1.1; investigate before proceeding')
|
| 247 |
+
raw_oid = baseline['H2O/raw']['oid']
|
| 248 |
+
remote = tree(args.source_revision, PREFIX + '/script', recursive=True)
|
| 249 |
+
remote.update({k:v for k,v in tree(args.source_revision, PREFIX + '/doc').items()
|
| 250 |
+
if k.rsplit('/',1)[-1] in (*BASE_DOC_HASHES, 'RAW_TO_SHARED.md')})
|
| 251 |
+
baseline_hashes = {}
|
| 252 |
+
for key,entry in remote.items():
|
| 253 |
+
if entry['type'] == 'file':
|
| 254 |
+
ref = key.removeprefix(PREFIX + '/')
|
| 255 |
+
baseline_hashes[ref] = verify_source_file(resolve(source, ref), entry)
|
| 256 |
+
actual_scripts = {'script/' + f.relative_to(source / 'script').as_posix()
|
| 257 |
+
for f in (source / 'script').rglob('*') if f.is_file() and f.suffix != '.pyc'}
|
| 258 |
+
if actual_scripts != {ref for ref in baseline_hashes if ref.startswith('script/')}:
|
| 259 |
+
raise ValueError('local source scripts do not match fixed HF file set')
|
| 260 |
+
out.mkdir()
|
| 261 |
+
doc, scripts = out / 'doc', out / 'script'
|
| 262 |
+
doc.mkdir()
|
| 263 |
+
scripts.mkdir()
|
| 264 |
+
here = Path(__file__).resolve().parent
|
| 265 |
+
shutil.copytree(here, scripts / 'h2o_v1_1', ignore=shutil.ignore_patterns('__pycache__', '*.pyc'))
|
| 266 |
+
shutil.copytree(source / 'script', scripts / 'v1_0_snapshot/script', ignore=shutil.ignore_patterns('__pycache__', '*.pyc'))
|
| 267 |
+
(scripts / 'v1_0_snapshot/doc').mkdir()
|
| 268 |
+
for name in BASE_DOC_HASHES:
|
| 269 |
+
shutil.copyfile(source / 'doc' / name, scripts / 'v1_0_snapshot/doc' / name)
|
| 270 |
+
for ref,digest in baseline_hashes.items():
|
| 271 |
+
if ref.startswith('script/') and sha256(scripts / 'v1_0_snapshot' / ref) != digest:
|
| 272 |
+
raise ValueError('historical script changed while snapshotting')
|
| 273 |
+
for name in ('schema.json', 'MIGRATION.md'):
|
| 274 |
+
shutil.copyfile(here / 'spec' / name, doc / name)
|
| 275 |
+
contract = (here / 'spec/CONTRACT.md').read_text().replace('../hand-warehouse-1.0/CONTRACT.md', 'V1_0_SEMANTICS.md')
|
| 276 |
+
(doc / 'CONTRACT.md').write_text('> H2O v1.1 试点,未正式发布;历史语义基线随本目录提供。\n\n' + contract)
|
| 277 |
+
shutil.copyfile(source / 'doc/CONTRACT.md', doc / 'V1_0_SEMANTICS.md')
|
| 278 |
+
mapping = source / 'doc/RAW_TO_SHARED.md'
|
| 279 |
+
text = mapping.read_text() if mapping.exists() else '# H2O raw → shared\n\n原转换实现见 script/v1_0_snapshot/script。\n'
|
| 280 |
+
(doc / 'RAW_TO_SHARED.md').write_text(text + '\n\n## v1.1 纯存储迁移\n\n'
|
| 281 |
+
'原始 RGB、深度及逐像素 valid、帧索引、MANO、左右手、split 和物体身份保持不变。'
|
| 282 |
+
'不重新编码视频,不合成源缺失的 UV、分割或接触。\n\n'
|
| 283 |
+
'| v1.0 文件 | v1.1 文件与字典条目 |\n|---|---|\n'
|
| 284 |
+
'| camera/intrinsic.pt + valid | camera/camera.pt → intrinsic/{data,valid} |\n'
|
| 285 |
+
'| camera/extrinsic.pt + valid | camera/camera.pt → extrinsic/{data,valid} |\n'
|
| 286 |
+
'| mano/motion.pt + valid | mano/mano.pt → motion/{data,valid} |\n'
|
| 287 |
+
'| keypoints/xyz.pt + valid | keypoints/keypoints.pt → xyz/{data,valid} |\n'
|
| 288 |
+
'| object/<id>/pose.pt + valid | object/<id>/object.pt → pose/{data,valid} |\n'
|
| 289 |
+
'| object/<id>/keypoints/xyz.pt + valid | object/<id>/object.pt → keypoints/xyz/{data,valid} |\n\n'
|
| 290 |
+
'媒体/JSONL 的独立 valid 保留。没有新增缺失组件。迁移实现见 script/h2o_v1_1/pilot.py;'
|
| 291 |
+
'试点未修改源发布或 HF。原始构建记录与旧验收属于 v1.0,不冒充 v1.1 验收。\n')
|
| 292 |
+
history = doc / 'history-v1.0'
|
| 293 |
+
history.mkdir()
|
| 294 |
+
for seq in chosen:
|
| 295 |
+
shutil.copyfile(source / 'doc' / (seq + '.build.json'), history / (seq + '.build.json'))
|
| 296 |
+
journal = {'phase': 'preparing', 'created_utc': datetime.now(timezone.utc).isoformat(),
|
| 297 |
+
'source': str(source), 'out': str(out), 'source_revision': args.source_revision,
|
| 298 |
+
'raw_tree_oid': raw_oid, 'source_tree_oid': baseline[PREFIX]['oid'],
|
| 299 |
+
'baseline_doc_script_sha256': baseline_hashes, 'workers': args.workers, 'sequences': chosen, 'coverage': coverage,
|
| 300 |
+
'tool_sha256': {str(f.relative_to(here)): sha256(f) for f in here.rglob('*') if f.is_file() and f.suffix != '.pyc'},
|
| 301 |
+
'views': [], 'scope': 'pilot only; full migration, HF writes and human approval not performed'}
|
| 302 |
+
journal_path = out.parent / 'PILOT_JOURNAL.json'
|
| 303 |
+
write_json(journal_path, journal)
|
| 304 |
+
try:
|
| 305 |
+
tasks = []
|
| 306 |
+
for seq in chosen:
|
| 307 |
+
inventory = tree(args.source_revision, PREFIX + '/data/' + seq, recursive=True)
|
| 308 |
+
entries = {k: v for k, v in inventory.items() if v['type'] == 'file'}
|
| 309 |
+
for view in sorted((source / 'data' / seq).iterdir()):
|
| 310 |
+
prefix = PREFIX + '/data/' + seq + '/' + view.name + '/'
|
| 311 |
+
refs = {k.removeprefix(prefix): v for k, v in entries.items() if k.startswith(prefix)}
|
| 312 |
+
tasks.append((str(view), str(out / 'data' / seq / view.name), str(doc / 'schema.json'), refs))
|
| 313 |
+
journal['phase'] = 'migrating_pilot'
|
| 314 |
+
write_json(journal_path, journal)
|
| 315 |
+
for key in ('OMP_NUM_THREADS', 'MKL_NUM_THREADS', 'OPENBLAS_NUM_THREADS', 'NUMEXPR_NUM_THREADS'):
|
| 316 |
+
os.environ[key] = '1'
|
| 317 |
+
with ProcessPoolExecutor(max_workers=args.workers, mp_context=multiprocessing.get_context('spawn')) as pool:
|
| 318 |
+
futures = [pool.submit(migrate_view, task) for task in tasks]
|
| 319 |
+
for future in as_completed(futures):
|
| 320 |
+
result = future.result()
|
| 321 |
+
journal['views'].append(result)
|
| 322 |
+
write_json(journal_path, journal)
|
| 323 |
+
print('PILOT_VIEW', result['view'], 'seconds', round(result['seconds'], 2), flush=True)
|
| 324 |
+
journal['views'].sort(key=lambda v: v['view'])
|
| 325 |
+
journal['phase'] = 'numeric_pilot_passed_awaiting_html_and_human_review'
|
| 326 |
+
journal['wall_seconds'] = time.monotonic() - started
|
| 327 |
+
journal['source_files'] = sum(v['source_files'] for v in journal['views'])
|
| 328 |
+
journal['target_files'] = sum(v['target_files'] for v in journal['views'])
|
| 329 |
+
journal['saved_data_files'] = journal['source_files'] - journal['target_files']
|
| 330 |
+
journal['view_frames'] = sum(v['num_frames'] for v in journal['views'])
|
| 331 |
+
journal['source_bytes_checked'] = sum(v['source_bytes'] for v in journal['views'])
|
| 332 |
+
journal['verify_worker_seconds'] = sum(v['verify_seconds'] for v in journal['views'])
|
| 333 |
+
journal['pack_worker_seconds'] = sum(v['pack_seconds'] for v in journal['views'])
|
| 334 |
+
write_json(journal_path, journal)
|
| 335 |
+
write_json(doc / 'PILOT_MIGRATION_REPORT.json', journal)
|
| 336 |
+
print('PILOT_NUMERIC_DONE', json.dumps({k:journal[k] for k in ('wall_seconds','saved_data_files','view_frames','source_bytes_checked','phase')}), flush=True)
|
| 337 |
+
except Exception as exc:
|
| 338 |
+
journal.update(phase='failed', error=repr(exc))
|
| 339 |
+
write_json(journal_path, journal)
|
| 340 |
+
raise
|
| 341 |
+
|
| 342 |
+
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Render stored H2O RGB-D, native camera-space hands/objects, and OBJ assets for review."""
|
| 3 |
+
import argparse
|
| 4 |
+
import html
|
| 5 |
+
import json
|
| 6 |
+
from concurrent.futures import ProcessPoolExecutor
|
| 7 |
+
import multiprocessing
|
| 8 |
+
import os
|
| 9 |
+
import subprocess
|
| 10 |
+
import sys
|
| 11 |
+
import time
|
| 12 |
+
from pathlib import Path
|
| 13 |
+
|
| 14 |
+
import numpy as np
|
| 15 |
+
from PIL import Image, ImageDraw
|
| 16 |
+
import torch
|
| 17 |
+
|
| 18 |
+
if __package__:
|
| 19 |
+
from .warehouse import Reader, validate_view
|
| 20 |
+
else:
|
| 21 |
+
from warehouse import Reader, validate_view
|
| 22 |
+
|
| 23 |
+
# Historical helpers decode native media and draw assets; do not invoke the v1.0 validator.
|
| 24 |
+
helpers = Path(__file__).resolve().parents[1] / 'v1_0_snapshot/script'
|
| 25 |
+
if not helpers.is_dir():
|
| 26 |
+
helpers = Path(__file__).resolve().parents[1] / 'h2o_production/scripts'
|
| 27 |
+
sys.path.insert(0, str(helpers))
|
| 28 |
+
from render_hoi4d_validation import mesh_preview, picture
|
| 29 |
+
from warehouse_v1_0 import decode_args, unpack_depth
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def snapshot(video, fmt, shape, dtype, indices):
|
| 33 |
+
indices = sorted(indices)
|
| 34 |
+
if not indices or indices[0] < 0:
|
| 35 |
+
raise ValueError('nonempty nonnegative frame indices required')
|
| 36 |
+
expression = '+'.join(f'eq(n\\,{i})' for i in indices)
|
| 37 |
+
cmd = decode_args(video, fmt) + ['-vf', 'select=' + expression,
|
| 38 |
+
'-frames:v', str(len(indices)), 'pipe:1']
|
| 39 |
+
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True)
|
| 40 |
+
frame_bytes = int(np.prod(shape)) * np.dtype(dtype).itemsize
|
| 41 |
+
if len(result.stdout) != frame_bytes * len(indices):
|
| 42 |
+
raise ValueError(f'missing/truncated selected frames: {video}')
|
| 43 |
+
values = np.frombuffer(result.stdout, dtype=dtype).reshape(len(indices), *shape)
|
| 44 |
+
return dict(zip(indices, values, strict=True))
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def render(view, destination):
|
| 48 |
+
meta = json.loads((view / 'metainfo.json').read_text())
|
| 49 |
+
if meta['dataset_id'] != 'H2O':
|
| 50 |
+
raise ValueError('H2O view required')
|
| 51 |
+
n = meta['num_frames']
|
| 52 |
+
height, width = reversed(meta['camera']['image_size'])
|
| 53 |
+
parts = meta['components']
|
| 54 |
+
frames = [json.loads(line) for line in (view / 'camera/frames.jsonl').read_text().splitlines()]
|
| 55 |
+
assert len(frames) == n
|
| 56 |
+
selected = {0, n // 4, n // 2, 3 * n // 4, n - 1}
|
| 57 |
+
reader = Reader(view)
|
| 58 |
+
numeric = {}
|
| 59 |
+
for name, item in parts.items():
|
| 60 |
+
if item.get('data_ref', '').endswith('.pt') and item.get('available'):
|
| 61 |
+
values = reader.field(item).numpy()
|
| 62 |
+
valid = reader.field(item, 'valid').numpy()
|
| 63 |
+
if values is not None:
|
| 64 |
+
numeric[name] = (values, valid)
|
| 65 |
+
if valid is not None:
|
| 66 |
+
indices = np.flatnonzero(valid.reshape(n, -1).any(axis=1))
|
| 67 |
+
if len(indices):
|
| 68 |
+
selected.add(int(indices[0]))
|
| 69 |
+
invalid = np.flatnonzero(~valid.reshape(n, -1).all(axis=1))
|
| 70 |
+
if len(invalid):
|
| 71 |
+
selected.add(int(invalid[0]))
|
| 72 |
+
selected = set(sorted(selected)[:12]) | {n - 1}
|
| 73 |
+
rgb = snapshot(view / parts['rgb']['data_ref'], 'rgb24', (height, width, 3), np.uint8, selected)
|
| 74 |
+
depth = snapshot(view / parts['depth']['data_ref'], 'gray16le', (height, 2 * width), '<u2', selected) if parts.get('depth', {}).get('available') else {}
|
| 75 |
+
depth_valid = snapshot(view / parts['depth']['valid_ref'], 'gray', (height, width), np.uint8, selected) if depth else {}
|
| 76 |
+
intrinsic = numeric.get('intrinsic', (None, None))[0]
|
| 77 |
+
pages = []
|
| 78 |
+
for i in sorted(selected):
|
| 79 |
+
photo = Image.fromarray(rgb[i])
|
| 80 |
+
legend = []
|
| 81 |
+
if intrinsic is not None:
|
| 82 |
+
draw = ImageDraw.Draw(photo)
|
| 83 |
+
for name, (points, valid) in numeric.items():
|
| 84 |
+
if name != 'keypoints_xyz' and not name.startswith('points_'):
|
| 85 |
+
continue
|
| 86 |
+
color = '#00e6ff' if name == 'keypoints_xyz' else '#ff48a4'
|
| 87 |
+
for slot, row in enumerate(points[i] if points.ndim == 4 else [points[i]]):
|
| 88 |
+
mask = valid[i, slot] if points.ndim == 4 else valid[i]
|
| 89 |
+
for xyz, good in zip(row, mask, strict=True):
|
| 90 |
+
if good and np.isfinite(xyz).all() and xyz[2] > 0:
|
| 91 |
+
u, v = intrinsic[i, 0, 0] * xyz[0] / xyz[2] + intrinsic[i, 0, 2], intrinsic[i, 1, 1] * xyz[1] / xyz[2] + intrinsic[i, 1, 2]
|
| 92 |
+
if 0 <= u < width and 0 <= v < height:
|
| 93 |
+
draw.ellipse((u-4, v-4, u+4, v+4), fill=color)
|
| 94 |
+
legend.append(name + ' ' + color)
|
| 95 |
+
panels = ['<figure>' + picture(Image.fromarray(rgb[i])) + '<figcaption>原生 RGB(仅预览缩放)</figcaption></figure>', '<figure>' + picture(photo) + '<figcaption>RGB + 原生 3D 关键点投影(仅预览:' + html.escape(', '.join(legend) or '当前帧无可投影点') + ')</figcaption></figure>']
|
| 96 |
+
if i in depth:
|
| 97 |
+
z = unpack_depth(depth[i])
|
| 98 |
+
luminance = (np.clip(np.nan_to_num(z, nan=0), 0, 3) * 85).astype(np.uint8)
|
| 99 |
+
panels.append('<figure>' + picture(Image.fromarray(luminance)) + '<figcaption>深度 Z,黑=无效,白≥3 m;不改源深度</figcaption></figure>')
|
| 100 |
+
if i in depth_valid:
|
| 101 |
+
good = depth_valid[i]
|
| 102 |
+
if not np.isin(good, [0, 1]).all():
|
| 103 |
+
raise ValueError('depth validity must be 0/1')
|
| 104 |
+
panels.append('<figure>' + picture(Image.fromarray(good * 255)) + '<figcaption>原深度逐像素 valid:白=有效,黑=无效,不是深度值</figcaption></figure>')
|
| 105 |
+
details = {'frame': frames[i], 'rgb_valid': bool(reader.field(parts['rgb'], 'valid')[i])}
|
| 106 |
+
for name, (values, valid) in numeric.items():
|
| 107 |
+
details[name] = {'value': values[i].tolist(), 'valid': None if valid is None else valid[i].tolist()}
|
| 108 |
+
pages.append('<section><h2>帧 ' + str(i) + ' / ' + str(n) + '</h2><div class="panels">' + ''.join(panels) + '</div><details><summary>原帧号、全部数值标注及有效性</summary><pre>' + html.escape(json.dumps(details, ensure_ascii=False, indent=2)) + '</pre></details></section>')
|
| 109 |
+
assets = []
|
| 110 |
+
for name, item in parts.items():
|
| 111 |
+
if item.get('available') and item.get('data_ref', '').lower().endswith('.obj'):
|
| 112 |
+
assets.append('<figure><h3>' + html.escape(name) + '</h3>' + mesh_preview(view / item['data_ref']) + '<figcaption>源 OBJ 静态预览,不代表物体姿态投影</figcaption></figure>')
|
| 113 |
+
report = validate_view(view, view.parents[2] / 'doc/schema.json')
|
| 114 |
+
report['selected_frames'] = sorted(selected)
|
| 115 |
+
report['preview_media'] = ['rgb', 'depth', 'depth_valid']
|
| 116 |
+
report['decode_scope'] = 'only selected frames emitted; sequential decoding may traverse earlier frames, no full-video pixel comparison'
|
| 117 |
+
destination.mkdir(parents=True, exist_ok=True)
|
| 118 |
+
title = view.parent.name + '_' + view.name
|
| 119 |
+
style = 'body{font:16px sans-serif;max-width:1500px;margin:auto;padding:1rem;background:#f5f7fa;color:#18232f}section,details{background:white;padding:1rem;margin:1rem 0;border-radius:8px}.panels{display:flex;flex-wrap:wrap}img{max-width:100%}pre{white-space:pre-wrap;overflow:auto;font-size:12px}'
|
| 120 |
+
page = '<!doctype html><html lang="zh"><meta charset="utf-8"><title>' + html.escape(title) + '</title><style>' + style + '</style><h1>' + html.escape(title) + '</h1><p>直接读取 v1.1 bundle;预览只作人工核查。手/物体点来自源 3D 标注,仅为显示投影到 RGB;未生成新 UV、分割或接触标注。</p>' + ''.join(pages) + '<h2>源网格</h2><div class="panels">' + ''.join(assets) + '</div><details><summary>全部组件元数据</summary><pre>' + html.escape(json.dumps(meta, ensure_ascii=False, indent=2)) + '</pre></details><details><summary>持久化 QC</summary><pre>' + html.escape(json.dumps(report, ensure_ascii=False, indent=2)) + '</pre></details></html>'
|
| 121 |
+
(destination / (title + '.html')).write_text(page)
|
| 122 |
+
(destination / (title + '.report.json')).write_text(json.dumps(report, ensure_ascii=False, indent=2) + '\n')
|
| 123 |
+
return destination / (title + '.html')
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
def render_task(task):
|
| 128 |
+
torch.set_num_threads(1)
|
| 129 |
+
if torch.get_num_interop_threads() != 1:
|
| 130 |
+
torch.set_num_interop_threads(1)
|
| 131 |
+
view, dest = map(Path, task)
|
| 132 |
+
render(view, dest)
|
| 133 |
+
print('HTML_VIEW', view.parent.name, view.name, flush=True)
|
| 134 |
+
return json.loads((dest / (view.parent.name + '_' + view.name + '.report.json')).read_text())
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
def main():
|
| 138 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 139 |
+
parser.add_argument('root', type=Path)
|
| 140 |
+
parser.add_argument('--workers', type=int, default=4)
|
| 141 |
+
parser.add_argument('--sequences-file', type=Path)
|
| 142 |
+
args = parser.parse_args()
|
| 143 |
+
if not 1 <= args.workers <= 8:
|
| 144 |
+
parser.error('1–8 workers required')
|
| 145 |
+
root = args.root.resolve()
|
| 146 |
+
dest = root / 'doc/validation'
|
| 147 |
+
dest.mkdir(exist_ok=True)
|
| 148 |
+
if args.sequences_file:
|
| 149 |
+
sequences = json.loads(args.sequences_file.read_text())['sequences']
|
| 150 |
+
if len(sequences) != len(set(sequences)) or any(not isinstance(n,str) or n in ('', '.', '..') or '/' in n or '\\' in n for n in sequences):
|
| 151 |
+
raise ValueError('unsafe or duplicate selected sequence')
|
| 152 |
+
views = sorted(p.parent for seq in sequences for p in (root / 'data' / seq).glob('*/metainfo.json'))
|
| 153 |
+
if len(views) != len(sequences) * 5:
|
| 154 |
+
raise ValueError('selected sequences must include all five cameras')
|
| 155 |
+
else:
|
| 156 |
+
views = sorted(p.parent for p in (root / 'data').glob('*/*/metainfo.json'))
|
| 157 |
+
if not views:
|
| 158 |
+
raise ValueError('no views to render')
|
| 159 |
+
for key in ('OMP_NUM_THREADS', 'MKL_NUM_THREADS', 'OPENBLAS_NUM_THREADS', 'NUMEXPR_NUM_THREADS'):
|
| 160 |
+
os.environ[key] = '1'
|
| 161 |
+
os.environ['HAND_WAREHOUSE_FFMPEG_THREADS'] = '10'
|
| 162 |
+
start = time.monotonic()
|
| 163 |
+
with ProcessPoolExecutor(max_workers=args.workers, mp_context=multiprocessing.get_context('spawn')) as pool:
|
| 164 |
+
reports = list(pool.map(render_task, [(str(v), str(dest)) for v in views]))
|
| 165 |
+
label = '全量后抽样' if args.sequences_file else '试点'
|
| 166 |
+
summary = {'review_kind': label, 'views': len(views), 'sequences': len({v.parent for v in views}),
|
| 167 |
+
'wall_seconds': time.monotonic() - start, 'reports': reports,
|
| 168 |
+
'scope': 'all selected sequence cameras; sampled frames and all numeric fields read from new bundles; manual approval pending'}
|
| 169 |
+
(dest / 'V1_1_VALIDATION.json').write_text(json.dumps(summary, ensure_ascii=False, indent=2) + '\n')
|
| 170 |
+
links = sorted(p.name for p in dest.glob('*.html') if p.name != 'index.html')
|
| 171 |
+
(dest / 'index.html').write_text('<!doctype html><html lang="zh"><meta charset="utf-8"><title>H2O v1.1 review</title><h1>H2O v1.1 ' + label + '全部相机验收</h1><p>数值按字节一致;媒体不重新编码。RGB、深度/深度 valid、相机、MANO、手/物体点、位姿、网格和来源均可查看;源没有 UV、分割或接触,不补造。</p><p><a href="../CONTRACT.md">合同</a> · <a href="../RAW_TO_SHARED.md">字段映射</a> · <a href="../' + ('FULL_MIGRATION_SUMMARY.json' if args.sequences_file else 'PILOT_MIGRATION_REPORT.json') + '">迁移报告</a> · <a href="V1_1_VALIDATION.json">可视化报告</a></p><ul>' + ''.join('<li><a href="' + html.escape(p, quote=True) + '">' + html.escape(p) + '</a></li>' for p in links) + '</ul></html>')
|
| 172 |
+
print('PILOT_HTML_DONE', len(views), 'views', round(summary['wall_seconds'], 2), 'seconds', dest / 'index.html', flush=True)
|
| 173 |
+
|
| 174 |
+
|
| 175 |
+
if __name__ == '__main__':
|
| 176 |
+
main()
|
H2O/shared-v1.1/script/h2o_v1_1/spec/CONTRACT.md
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 手物数据仓库统一约定 v1.1:张量合并存储
|
| 2 |
+
|
| 3 |
+
格式版本:`hand-warehouse/1.1`。张量存储约定:`pt/tensor_bundle/v1`。
|
| 4 |
+
|
| 5 |
+
状态:合同草案,2026-10-09。本版规定新的文件布局与读取方式,配套 [schema.json](schema.json) 注册表已更新;尚未迁移现有数据,也未适配生产转换器、读取器或可执行校验器。不能仅修改现有 metainfo 的版本号就宣称符合本版。
|
| 6 |
+
|
| 7 |
+
本版以 [v1.0 合同](../hand-warehouse-1.0/CONTRACT.md) 为语义基础:任务范围、两层序列/相机组织、数据类型、单位、坐标系、时间对齐、左右手顺序、官方划分、view_type、来源、可用监督规则、媒体无损编码和验收要求均保留。下文仅替代数值张量组件的独立 Tensor 文件、对应 `*_valid.pt` 及文件引用规定;这些旧文件名仅用于识别对应逻辑字段。媒体和 JSONL 组件的有效性文件及引用保持 v1.0,不纳入合并。未明确改变的语义继续执行 v1.0。
|
| 8 |
+
|
| 9 |
+
本版按用户约定作为 v1.0 的小版本存储修订,后续所有数据集逐步迁移到 v1.1。数值字段与 valid 语义不变,但 `.pt` 物理结构和引用方式改变,旧读取器不能未经适配直接读取新字典。各数据集在原 `shared-v1.0` 目录内逐步升级,完整验收后将目录更名为 `shared-v1.1`,不长期保留两套发布树。最终 `metainfo.schema_version=hand-warehouse/1.1`、`release_id=shared-v1.1`;尚未迁移的数据集仍使用原目录和版本。升级与发布流程见 [MIGRATION.md](MIGRATION.md)。实施前须按配套 v1.1 注册表完成读写/校验工具;不得将 v1.0 的 schema.json 改个版本号作为已完成适配的证明。正式发布时须提供完整合同与匹配注册表,不依赖本地草案目录中的相对链接。
|
| 10 |
+
|
| 11 |
+
## 1. 合并边界
|
| 12 |
+
|
| 13 |
+
1. 数值张量与对应有效性必须在同一个 `.pt` 文件、同一个字段字典内保存:`{"data": Tensor, "valid": BoolTensor}`。这些数值张量组件不再生成独立的 `*_valid.pt`;媒体和 JSONL 的有效性文件不受此规则影响。
|
| 14 |
+
2. 按组件合并经常一起读取的小张量:相机内参、外参、畸变放在一个 `camera.pt`;MANO 参数与整手可见性放在一个 `mano.pt`;手关键点的二维、三维与可见性放在一个 `keypoints.pt`。
|
| 15 |
+
3. 每个物体的数值字段及全部部件数值字段合并为一个 `object.pt`。不同物体、不同相机、不同序列不合成一个全局大文件,以保留按需下载和读取能力。
|
| 16 |
+
4. RGB、深度、栅格 mask 继续使用原无损媒体格式,不把解码后的大数组或媒体字节塞进 `.pt`。它们的有效性文件保持原文件名、Tensor/媒体格式、形状和引用方式,不包装为字典。
|
| 17 |
+
5. `metainfo.json`、`camera/frames.jsonl`、实例映射、物体身份/运动学定义与网格资产保留原格式。此次不把 JSON、JSONL、OBJ、纹理全部打进一个字典。
|
| 18 |
+
|
| 19 |
+
合并只改变存储方式,不改变采样、帧数、张量内容或有效性判定。不为减少字段数而将多个组件的 valid 合成一个公共 valid。
|
| 20 |
+
|
| 21 |
+
## 2. 目录
|
| 22 |
+
|
| 23 |
+
```text
|
| 24 |
+
<dataset>/shared-v1.1/
|
| 25 |
+
doc/ # 完整合同、匹配 schema、字段映射、验收报告
|
| 26 |
+
script/ # 转换、读取和校验代码
|
| 27 |
+
data/<sequence_id>/<camera_id>/
|
| 28 |
+
metainfo.json
|
| 29 |
+
observation/
|
| 30 |
+
rgb.mkv
|
| 31 |
+
rgb_valid.pt # 原独立 bool Tensor,保持不变
|
| 32 |
+
depth.mkv
|
| 33 |
+
depth_valid.mkv # 逐像素有效性,保留压缩媒体格式
|
| 34 |
+
camera/
|
| 35 |
+
frames.jsonl
|
| 36 |
+
camera.pt # intrinsic、extrinsic、distortion
|
| 37 |
+
annotation/
|
| 38 |
+
mano/mano.pt # motion、visibility
|
| 39 |
+
keypoints/keypoints.pt # uv、xyz、visibility、whole_hand_visibility
|
| 40 |
+
object/<object_id>/
|
| 41 |
+
metainfo.json
|
| 42 |
+
articulation.json # 仅关节/部件结构实际存在时
|
| 43 |
+
object.pt # 位姿、可见性、几何点、关节、部件数值
|
| 44 |
+
assets/ # 原网格、材质、纹理及依赖
|
| 45 |
+
segment/
|
| 46 |
+
mask.mkv # 或 polygons.jsonl,按所选表示
|
| 47 |
+
instances.jsonl # 仅需要实例/区域编码映射时
|
| 48 |
+
mask_valid.pt # 原帧级 bool Tensor,保持不变
|
| 49 |
+
contact/
|
| 50 |
+
relations.jsonl
|
| 51 |
+
relations_valid.pt # 原帧级 bool Tensor,保持不变
|
| 52 |
+
<subject_id>__<object_id>/
|
| 53 |
+
contact.pt # vertex_region、vertex_distance
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
只创建实际提供的组件和字段。以上不是每个数据集必须填满的模板;缺失内参、MANO、深度等不能通过占位文件伪装为已提供。序列/相机的两层结构不变,物体与模态目录属于相机内部组件。
|
| 57 |
+
|
| 58 |
+
## 3. 字典结构与有效性
|
| 59 |
+
|
| 60 |
+
本次合并的数值组件 `.pt` 根对象为字符���键的 Python `dict`,内部仅允许嵌套字符串键字典和 CPU `torch.Tensor`,不保存自定义类、模型、NumPy 对象或任意可执行对象。元信息、schema、单位和来源放在 metainfo,不在每个张量条目中重复保存。读取使用 `torch.load(path, map_location="cpu", weights_only=True)`。第 4 节保留的独立有效性 `.pt` 根对象仍为 CPU bool Tensor,不适用字典结构要求。
|
| 61 |
+
|
| 62 |
+
例如,`camera/camera.pt` 的逻辑结构为:
|
| 63 |
+
|
| 64 |
+
```python
|
| 65 |
+
{
|
| 66 |
+
"intrinsic": {"data": K, "valid": K_valid},
|
| 67 |
+
"extrinsic": {"data": T_camera_from_world, "valid": extrinsic_valid},
|
| 68 |
+
"distortion": {"data": distortion, "valid": distortion_valid},
|
| 69 |
+
}
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
以上变量均为 Tensor。未提供的字段整个省略;例如无世界系外参时不保存 `extrinsic`,不填单位矩阵。没有单独畸变向量的模型不创建 `distortion`:Fisheye624 仍使用既定 `[T,15]` 内参参数布局。
|
| 73 |
+
|
| 74 |
+
数值字段统一为 `data` 与 `valid` 两个叶子。源属性原先显式声明全已知 `valid=true` 时,迁移可按该属性的有效性形状展开为全 true 的 bool Tensor;这是已有有效性声明的等价表示,不是根据数值或姿态推测有效性。有效性必须为 bool Tensor,不能用 Python `True` 代替字段内的 Tensor。静态数值字段同样配套 valid,形状采用其语义定义的标量或逐元素有效性;静态网格等外部资产仍可在 metainfo 中声明标量 valid。
|
| 75 |
+
|
| 76 |
+
valid 的形状不要求与 data 完全相同,但必须与该字段定义一致。例如 MANO 为 `[T,2,61]` / `[T,2]`,内参为 `[T,3,3]` / `[T]`,关键点为 `[T,2,K,3]` / `[T,2,K]`。按 schema 将 valid 扩展到相应数值维度,不允许依靠碰巧可广播推断语义。
|
| 77 |
+
|
| 78 |
+
浮点默认 float32,无效浮点位置仍为 NaN;bool 和整数沿用该组件的占位/保留值规则,不因没有 NaN 而视为有效。valid 表达可用监督,不只是“值有限”或“记录存在”;适用官方 QA 与已经确认的排除规则继续保留。不能用 `isfinite(data)` 重建 valid,不能因为迁移而把 false 改成 true。
|
| 79 |
+
|
| 80 |
+
不同字段的 valid 独立保存和解释。visibility 的 valid 不复用姿态 valid;内参 valid 不代替外参 valid。既有相机模型要求内参与单独畸变向量共用有效性时,在两个字段内保存相同 bool 值并校验一致,而不改变该模型的联合标定规则。
|
| 81 |
+
|
| 82 |
+
## 4. 固定分组与字段名
|
| 83 |
+
|
| 84 |
+
下表中的键路径用 `/` 展示字典层级;它不是文件系统路径。数值字段均在列出的键下继续存储 `data`、`valid`。
|
| 85 |
+
|
| 86 |
+
| 文件 | 数值字段键 | 内容 |
|
| 87 |
+
|---|---|---|
|
| 88 |
+
| `camera/camera.pt` | `intrinsic`、`extrinsic`、`distortion` | 逐帧标定;形状、参数顺序与相机模型定义不变 |
|
| 89 |
+
| `annotation/mano/mano.pt` | `motion`、`visibility` | MANO `[T,2,61]` 与源整手可见性;各有独立有效性 |
|
| 90 |
+
| `annotation/keypoints/keypoints.pt` | `uv`、`xyz`、`visibility`、`whole_hand_visibility` | 手关键点及源可见性;整手与逐点可见性不混用 |
|
| 91 |
+
| `annotation/object/<id>/object.pt` | `pose`、`visibility`、`dimensions`、`joint_state` | 该物体的数值标注 |
|
| 92 |
+
| 同上 | `keypoints/xyz`、`keypoints/template_xyz` | 相机系逐帧点或物体系静态模板点 |
|
| 93 |
+
| 同上 | `parts/<part_id>/pose`、`parts/<part_id>/dimensions`、`parts/<part_id>/keypoints/xyz`、`parts/<part_id>/keypoints/template_xyz` | 部件数值字段,部件身份仍由 articulation 登记 |
|
| 94 |
+
| 同上 | `meshes/<mesh_id>/vertex_part_ids` | `[V] int64` 顶点部件标签,valid 为 `[V]`,未知 -1 对应 false;每个 mesh 单独绑定拓扑 |
|
| 95 |
+
| `annotation/contact/<subject_id>__<object_id>/contact.pt` | `vertex_region`、`vertex_distance` | 已登记拓扑上的接触区域/距离与同形有效性 |
|
| 96 |
+
|
| 97 |
+
顶点部件标签使用注册类型 `object/vertex_part_ids/v1`。物体的 mesh_id、part_id 必须在 metainfo/运动学定义中可解析;不同拓扑不能误用同一顶点数组。未提供的可见性、关节值或模板点不生成空字段。
|
| 98 |
+
|
| 99 |
+
**媒体和 JSONL 的有效性保持原样,不参与字典合并:**
|
| 100 |
+
|
| 101 |
+
| 数据本体 | 有效性文件 | 存储形式 |
|
| 102 |
+
|---|---|---|
|
| 103 |
+
| `observation/rgb.mkv` | `observation/rgb_valid.pt` | 独立 CPU bool Tensor `[T]` |
|
| 104 |
+
| `annotation/segment/mask.mkv` 或 `polygons.jsonl` | 原 `valid_ref` 指定的文件,通常为 `annotation/segment/mask_valid.pt` | 独立 CPU bool Tensor `[T]`;沿用原路径 |
|
| 105 |
+
| `annotation/contact/relations.jsonl` | `annotation/contact/relations_valid.pt` | 独立 CPU bool Tensor `[T]` |
|
| 106 |
+
| `observation/depth.mkv` | `observation/depth_valid.mkv` | 原逐像素 bool 无损视频 `[T,H,W]` |
|
| 107 |
+
|
| 108 |
+
不新建仅包装上述 valid 的 observation.pt、segment.pt 或关系级 contact.pt。现有媒体/JSONL 的 `valid_ref`、`valid_axes` 及适用的 `valid_storage` 保持原定义;深度编码、NaN 位串还原与像素有效性规则不变。实体对的接触区域/距离是数值张量,仍���上表合并到各实体对的 contact.pt。
|
| 109 |
+
|
| 110 |
+
## 5. metainfo 的文件与字典键引用
|
| 111 |
+
|
| 112 |
+
文件定位与字典内部定位分开登记,不在文件名中拼接自定义分隔符:
|
| 113 |
+
|
| 114 |
+
| 字段 | 定义 |
|
| 115 |
+
|---|---|
|
| 116 |
+
| `data_ref` | 相对当前相机视图根目录的 POSIX 文件路径 |
|
| 117 |
+
| `data_key` | 非空字符串列表,按顺序访问 `.pt` 嵌套字典,最终必须得到 data Tensor |
|
| 118 |
+
| `valid_ref` | 有效性所在文件;合并的数值字段必须与 data_ref 相同,媒体/JSONL 保留独立有效性文件 |
|
| 119 |
+
| `valid_key` | 非空字符串列表,最终必须得到 bool Tensor |
|
| 120 |
+
| `storage.profile` / `valid_storage.profile` | 合并字典采用 `pt/tensor_bundle/v1`;媒体及其独立有效性保持原配置,不将独立 bool Tensor 声明为 bundle |
|
| 121 |
+
|
| 122 |
+
数值字段必须显式登记 data_key 与 valid_key。例如内参登记:
|
| 123 |
+
|
| 124 |
+
```json
|
| 125 |
+
{
|
| 126 |
+
"available": true,
|
| 127 |
+
"schema_id": "camera/pinhole/v1",
|
| 128 |
+
"data_ref": "camera/camera.pt",
|
| 129 |
+
"data_key": ["intrinsic", "data"],
|
| 130 |
+
"axes": ["T", "row", "column"],
|
| 131 |
+
"valid_ref": "camera/camera.pt",
|
| 132 |
+
"valid_key": ["intrinsic", "valid"],
|
| 133 |
+
"valid_axes": ["T"],
|
| 134 |
+
"storage": {"profile": "pt/tensor_bundle/v1"},
|
| 135 |
+
"valid_storage": {"profile": "pt/tensor_bundle/v1"}
|
| 136 |
+
}
|
| 137 |
+
```
|
| 138 |
+
|
| 139 |
+
这是引用结构片段,实际组件仍须补齐 provenance、source_locator 等必填内容。MANO 的 schema_id 仍可为 `mano/axis_angle61/v1`:它描述解码后的数值语义,不因为物理文件合并而改动。顶层 schema_version 与 storage.profile 标识新的存储方式。
|
| 140 |
+
|
| 141 |
+
媒体和 JSONL 的 data_ref 不设置 data_key;RGB 的 valid_ref 仍为 `observation/rgb_valid.pt`,不设置 valid_key。分割、关系和深度的有效性同样保持原引用方式,不新增任何字典键字段。只有引用合并字典时才使用 data_key/valid_key。
|
| 142 |
+
|
| 143 |
+
同样规则适用于 attributes 中的可见性等数值字段。相机模型已有的 `distortion_ref` 改为指向 `camera/camera.pt`,新增 `distortion_key=["distortion", "data"]`;对应有效性由同组件的 `distortion_valid_ref` 与 `distortion_valid_key=["distortion", "valid"]` 登记。带 `_key` 的引用必须指向匹配的 bundle 文件,不能指向目录或媒体。
|
| 144 |
+
|
| 145 |
+
读取器按文件路径缓存已加载字典,再按 key 取字段。同一 camera.pt 的三个字段不应触发三次反序列化。按组件下载时取所需 bundle 的整个文件;本约定不承诺 `.pt` 内单个键的远端局部下载。组件合并会增加最小下载粒度,这是减少文件数的明确取舍。
|
| 146 |
+
|
| 147 |
+
## 6. 迁移与验收
|
| 148 |
+
|
| 149 |
+
各数据集分别迁移:先适配工具并做代表性完整序列验证,再迁移全量并核对结果,最后按授权更新远端发布;一个数据集完成不代表其他数据集已完成。迁移状态和输入/输出固定版本逐数据集登记。
|
| 150 |
+
|
| 151 |
+
本地先在既有 `shared-v1.0` 内完成受控升级,校验完成后更名为 `shared-v1.1`。暂存、回滚、锁、旧文件清理、版本更新及 HF 路径切换遵循 [MIGRATION.md](MIGRATION.md);不复制完整媒体、不改 raw、不重新编码。多文件原地更新期间须保持维护状态,不能让读取任务使用半迁移视图。
|
| 152 |
+
|
| 153 |
+
每次迁移必须检查:
|
| 154 |
+
|
| 155 |
+
1. 所有组件、属性及其字典键可解析;无越界文件引用、缺失键或未登记字段;已合并的数值组件不得遗留旧独立 `*_valid.pt`。媒体/JSONL 的原独立有效性文件必须保留,不得误删或重打包。
|
| 156 |
+
2. 每个迁移前后的数值字段 dtype、shape、逐元素值、NaN 位置以及 bool valid 完全一致。数值张量还应按统一连续字节视图比较,确认没有更改 NaN 位串等内容;不能用近似容差代替单纯重打包的一致性。
|
| 157 |
+
3. T、帧映射、相机方向、手槽、split、来源和 valid_policy 不变。固定标定仍按既有 `[T,...]` 规则保存;本次不额外改成单份静态标定加广播。
|
| 158 |
+
4. 媒体与其他未修改文件按原可信摘要核对。新 `.pt` 的文件 SHA256 通常改变,必须重新生成发布清单;新文件指纹不等于转换语义正确性的证明。
|
| 159 |
+
5. 用新读取器运行代表性完整序列及所有相机,检查 RGB、相机与实际存在的标注是否正确关联;报告明确“重打包数值一致”与“人工视觉验收”的不同范围。
|
| 160 |
+
|
| 161 |
+
只有完成匹配注册表、读写工具及上述验收后才能生产/发布 v1.1。上传仍须单独得到授权;本文档更新本身不启动数据迁移或上传;被替代旧文件的清理属于后续迁移发布步骤,必须遵守MIGRATION.md 中先验收、安全切换和固定提交核验要求。
|
H2O/shared-v1.1/script/h2o_v1_1/spec/MIGRATION.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 数据集 v1.0 → v1.1 升级规范
|
| 2 |
+
|
| 3 |
+
日期:2026-10-09。目标格式:`hand-warehouse/1.1`。字段与字典布局见 [CONTRACT.md](CONTRACT.md)。
|
| 4 |
+
|
| 5 |
+
## 1. 升级单位与最终布局
|
| 6 |
+
|
| 7 |
+
以一个完整数据集为单位逐步升级。每个数据集在既有目录内完成数值文件重组、工具适配与验证,完成后将目录由 `shared-v1.0` 更名为 `shared-v1.1`。最终使用:
|
| 8 |
+
|
| 9 |
+
```text
|
| 10 |
+
<dataset>/
|
| 11 |
+
raw/ # 保持原样
|
| 12 |
+
shared-v1.1/
|
| 13 |
+
data/
|
| 14 |
+
doc/
|
| 15 |
+
script/
|
| 16 |
+
```
|
| 17 |
+
|
| 18 |
+
这是对“发布目录永久保持 shared-v1.0”安排的修订:不长期保留两套发布树,也不复制一整套媒体再制作新版本。尚未升级的数据集继续使用自己的 `shared-v1.0`;不同数据集处于不同版本是正常的。
|
| 19 |
+
|
| 20 |
+
完成后视图元数据统一为 `schema_version=hand-warehouse/1.1`、`release_id=shared-v1.1`。目录名与元数据版本均须正确,不能只更名而不改变内容。发布记录保留旧版本的固定提交以便追溯。
|
| 21 |
+
|
| 22 |
+
## 2. 变更范围
|
| 23 |
+
|
| 24 |
+
- 合并相机、MANO、关键点、物体、实体对接触等数值张量及各自 valid;具体分组遵循合同。
|
| 25 |
+
- 保持媒体及其独立有效性文件不变,包括 RGB、深度、mask 和相应 valid。JSONL、资产按合同保留;不重新编码媒体,不改 raw。
|
| 26 |
+
- 不改变张量 dtype、shape、数值、NaN 位串、valid、帧映射、T、单位、坐标系、左右手、划分及监督策略。
|
| 27 |
+
- 更新匹配的 schema、读取/转换/校验脚本、metainfo 引用、发布清单和正式文档。不得仅替换版本字符串冒充工具适配。
|
| 28 |
+
- 删除已经完整合并且验收通过的旧数值文件与对应独立 valid;不得按 `*_valid.pt` 通配删除,媒体/JSONL 有效性不在清理范围。
|
| 29 |
+
|
| 30 |
+
## 3. 启动与登记
|
| 31 |
+
|
| 32 |
+
启动前核对项目并行上限、实际进程、锁和空间。取得数据集迁移锁并暂停该目录的转换、发布和读取任务;多文件原地更新不是整体原子操作,不得让消费者读取半迁移视图。
|
| 33 |
+
|
| 34 |
+
在发布树外的 `tmp/` 为每个数据集登记:源 schema/release、源 HF 固定提交、源文件清单及摘要、目标版本、工具摘要、变更/删除的精确路径清单、checkpoint、阶段、错误和验收结果。原始数据长期保留。
|
| 35 |
+
|
| 36 |
+
准备可恢复的基线:保存即将被替换的小型元数据和脚本,以及旧数值文件的临时备份或已核验可恢复的远端固定版本。不复制未变化的大型媒体。空间预算包含临时新文件和回滚所需文件;空间不足时停止新增工作,不删 raw 腾空间。
|
| 37 |
+
|
| 38 |
+
## 4. 原地升级
|
| 39 |
+
|
| 40 |
+
1. 先选代表性完整序列及全部相机,在 `tmp/` 验证新写入器、读取器和引用;覆盖实际存在的组件与有效性组合。遵循项目人工验收要求后再全量。
|
| 41 |
+
2. 全量按完整视图处理。读取旧数值及 valid,写临时字典,重新读取并逐字段精确比较;不得用近似误差判断纯重打包的一致性。
|
| 42 |
+
3. 验证通过后在同一文件系统原子替换单个文件,再更新该视图 metainfo。只有新字段与引用完整可读、且回滚依据可用,才能移除该视图被替代的旧文件。
|
| 43 |
+
4. 每个视图保存完成 checkpoint;续跑必须核对输入和工具版本、产物摘要及当前引用,不能只依据文件存在而跳过。整个数据集完成前保持维护状态。
|
| 44 |
+
5. 完成全部视图后校验完整路径集合、无重复/缺失、所有键引用、全部数值一致性和未变文件摘要,并更新正式文档及脚本。生成直接读取新格式的随机完整序列报告,按项目流程人工确认。
|
| 45 |
+
|
| 46 |
+
失败时停止该数据集迁移,保留 checkpoint 和回滚材料,不伪装完成,不自动删除整棵目录或从 raw 重做转换。
|
| 47 |
+
|
| 48 |
+
## 5. 本地最终更名
|
| 49 |
+
|
| 50 |
+
全量验收通过后,在维护状态下统一设置最终 `release_id=shared-v1.1`,更新当前使用的配置、入口、清单和链接,然后将原目录重命名为 `shared-v1.1`。
|
| 51 |
+
|
| 52 |
+
重命名前核对源/目标绝对路径均位于该数据集根目录;目标目录必须不存在,不合并、不覆盖已有同名目录。同一文件系统内执行目录重命名,避免复制全部媒体。更名后再次解析相对引用并检查脚本默认路径,最后解除本地维护状态。
|
| 53 |
+
|
| 54 |
+
历史报告中说明当时版本的文字与固定摘要作为历史证据保留,不批量篡改;当前入口须明确报告所属版本,并链接本次迁移验收结果。
|
| 55 |
+
|
| 56 |
+
## 6. HF 发布与路径更换
|
| 57 |
+
|
| 58 |
+
本地目录重命名不等于 HF 路径已经更换。远端须在得到发布授权后,基于旧的固定提交执行受控更新;发布前再次核对源 HEAD 和相关文件内容,冲突时停止调查。
|
| 59 |
+
|
| 60 |
+
优先复用仓库已有内容,以平台实际支持且经过验证的服务端复制/提交操作,将未变化媒体映射到 `shared-v1.1`;仅新的字典、元数据、文档和脚本需要提供新内容。不承诺路径更换必然零网络传输或零耗时;先验证实际行为,不盲目重新上传全套媒体。
|
| 61 |
+
|
| 62 |
+
理想情况下,在一个提交中添加目标路径并删除旧路径,使默认分支完整切换。若文件数或 API 限制不允许,使用经过验证的临时分支准备与核验,完成后受控切换;若只能分批更新默认分支,必须明确维护状态,旧版本保留到目标完整核验通过,不提前删除唯一完整的旧树。短暂的核验用路径并存不代表长期发布两套版本。
|
| 63 |
+
|
| 64 |
+
最终必须在同一固定提交上验证:目标 `shared-v1.1` 的文件集合、大小与内容摘要全部匹配清单,所有引用有效;旧 `shared-v1.0` 路径已移除;raw 未变化。服务端更换路径仍须执行这些核验,不能用“文件名已改”替代。
|
| 65 |
+
|
| 66 |
+
完成后更新数据集登记与下载示例,记录最终提交,清理本次临时文件并通知一次,再安排下一个数据集。旧提交历史保留历史版本;本流程减少当前发布树的重复文件,不承诺清除 HF 历史存储。
|
| 67 |
+
|
| 68 |
+
本文仅规定后续实施流程,编写本文不等于已经启动迁移、修改数据或获得新的发布授权。
|
H2O/shared-v1.1/script/h2o_v1_1/spec/schema.json
ADDED
|
@@ -0,0 +1,1590 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema_version": "hand-warehouse/1.1",
|
| 3 |
+
"validity_revision": "usable-annotation-2026-09-20",
|
| 4 |
+
"annotation_validity": {
|
| 5 |
+
"meaning": "annotation usable for supervision, not merely record presence",
|
| 6 |
+
"formula": "source_annotation_present AND numerical_checks_pass AND applicable_official_QA_pass AND NOT explicitly_reviewed_local_exclusion",
|
| 7 |
+
"without_official_qa": "omit QA term; declare source rules; do not fabricate QA",
|
| 8 |
+
"policy_field": "components.<name>.valid_policy",
|
| 9 |
+
"visibility_is_independent": true,
|
| 10 |
+
"invalid_float_value": "NaN",
|
| 11 |
+
"hot3d": "broadcast per-camera frame manual QA conservatively to hand/object labels and pose-derived visibility; retain RGB and source calibration; keep native QA in raw and review report",
|
| 12 |
+
"hot3d_visibility": "native visibility_ratio[%] already ranges from 0 to 1; do not divide by 100"
|
| 13 |
+
},
|
| 14 |
+
"hand_slots": [
|
| 15 |
+
"left",
|
| 16 |
+
"right"
|
| 17 |
+
],
|
| 18 |
+
"view_metadata": {
|
| 19 |
+
"required_fields": [
|
| 20 |
+
"schema_version",
|
| 21 |
+
"dataset_id",
|
| 22 |
+
"release_id",
|
| 23 |
+
"sequence_id",
|
| 24 |
+
"camera_id",
|
| 25 |
+
"sample_type",
|
| 26 |
+
"num_frames",
|
| 27 |
+
"hand_slots",
|
| 28 |
+
"sampling",
|
| 29 |
+
"camera",
|
| 30 |
+
"components",
|
| 31 |
+
"split",
|
| 32 |
+
"view_type"
|
| 33 |
+
],
|
| 34 |
+
"view_type_values": [
|
| 35 |
+
"ego",
|
| 36 |
+
"exo",
|
| 37 |
+
"unknown"
|
| 38 |
+
],
|
| 39 |
+
"view_type_policy": "required per camera view; use ego or exo whenever the source data or capture setup establishes the viewpoint; use unknown only when no trustworthy source determines it; never omit or guess",
|
| 40 |
+
"schema_version": "hand-warehouse/1.1",
|
| 41 |
+
"release_id": "shared-v1.1"
|
| 42 |
+
},
|
| 43 |
+
"keypoints": {
|
| 44 |
+
"mano21/v1": {
|
| 45 |
+
"count": 21,
|
| 46 |
+
"names": [
|
| 47 |
+
"wrist",
|
| 48 |
+
"thumb_1",
|
| 49 |
+
"thumb_2",
|
| 50 |
+
"thumb_3",
|
| 51 |
+
"thumb_4",
|
| 52 |
+
"index_1",
|
| 53 |
+
"index_2",
|
| 54 |
+
"index_3",
|
| 55 |
+
"index_4",
|
| 56 |
+
"middle_1",
|
| 57 |
+
"middle_2",
|
| 58 |
+
"middle_3",
|
| 59 |
+
"middle_4",
|
| 60 |
+
"ring_1",
|
| 61 |
+
"ring_2",
|
| 62 |
+
"ring_3",
|
| 63 |
+
"ring_4",
|
| 64 |
+
"little_1",
|
| 65 |
+
"little_2",
|
| 66 |
+
"little_3",
|
| 67 |
+
"little_4"
|
| 68 |
+
],
|
| 69 |
+
"source_index_map": null,
|
| 70 |
+
"note": "adapter maps official MANO joint and fingertip convention"
|
| 71 |
+
},
|
| 72 |
+
"rhd21/v1": {
|
| 73 |
+
"count": 21,
|
| 74 |
+
"names": [
|
| 75 |
+
"wrist",
|
| 76 |
+
"thumb_1",
|
| 77 |
+
"thumb_2",
|
| 78 |
+
"thumb_3",
|
| 79 |
+
"thumb_4",
|
| 80 |
+
"index_1",
|
| 81 |
+
"index_2",
|
| 82 |
+
"index_3",
|
| 83 |
+
"index_4",
|
| 84 |
+
"middle_1",
|
| 85 |
+
"middle_2",
|
| 86 |
+
"middle_3",
|
| 87 |
+
"middle_4",
|
| 88 |
+
"ring_1",
|
| 89 |
+
"ring_2",
|
| 90 |
+
"ring_3",
|
| 91 |
+
"ring_4",
|
| 92 |
+
"little_1",
|
| 93 |
+
"little_2",
|
| 94 |
+
"little_3",
|
| 95 |
+
"little_4"
|
| 96 |
+
],
|
| 97 |
+
"source_index_map_per_hand": [
|
| 98 |
+
0,
|
| 99 |
+
4,
|
| 100 |
+
3,
|
| 101 |
+
2,
|
| 102 |
+
1,
|
| 103 |
+
8,
|
| 104 |
+
7,
|
| 105 |
+
6,
|
| 106 |
+
5,
|
| 107 |
+
12,
|
| 108 |
+
11,
|
| 109 |
+
10,
|
| 110 |
+
9,
|
| 111 |
+
16,
|
| 112 |
+
15,
|
| 113 |
+
14,
|
| 114 |
+
13,
|
| 115 |
+
20,
|
| 116 |
+
19,
|
| 117 |
+
18,
|
| 118 |
+
17
|
| 119 |
+
]
|
| 120 |
+
}
|
| 121 |
+
},
|
| 122 |
+
"camera": {
|
| 123 |
+
"opencv_fisheye4": {
|
| 124 |
+
"K": [
|
| 125 |
+
3,
|
| 126 |
+
3
|
| 127 |
+
],
|
| 128 |
+
"distortion": [
|
| 129 |
+
"k1",
|
| 130 |
+
"k2",
|
| 131 |
+
"k3",
|
| 132 |
+
"k4"
|
| 133 |
+
],
|
| 134 |
+
"projection": "theta=atan(r); theta_d=theta*(1+k1*theta^2+k2*theta^4+k3*theta^6+k4*theta^8); source ReInterHand"
|
| 135 |
+
},
|
| 136 |
+
"pinhole": {
|
| 137 |
+
"K": [
|
| 138 |
+
3,
|
| 139 |
+
3
|
| 140 |
+
]
|
| 141 |
+
},
|
| 142 |
+
"fisheye624": {
|
| 143 |
+
"parameters": [
|
| 144 |
+
"f",
|
| 145 |
+
"cx",
|
| 146 |
+
"cy",
|
| 147 |
+
"k0",
|
| 148 |
+
"k1",
|
| 149 |
+
"k2",
|
| 150 |
+
"k3",
|
| 151 |
+
"k4",
|
| 152 |
+
"k5",
|
| 153 |
+
"p0",
|
| 154 |
+
"p1",
|
| 155 |
+
"s0",
|
| 156 |
+
"s1",
|
| 157 |
+
"s2",
|
| 158 |
+
"s3"
|
| 159 |
+
]
|
| 160 |
+
},
|
| 161 |
+
"rational8": {
|
| 162 |
+
"K": [
|
| 163 |
+
3,
|
| 164 |
+
3
|
| 165 |
+
],
|
| 166 |
+
"distortion": [
|
| 167 |
+
"k1",
|
| 168 |
+
"k2",
|
| 169 |
+
"p1",
|
| 170 |
+
"p2",
|
| 171 |
+
"k3",
|
| 172 |
+
"k4",
|
| 173 |
+
"k5",
|
| 174 |
+
"k6"
|
| 175 |
+
]
|
| 176 |
+
}
|
| 177 |
+
},
|
| 178 |
+
"segmentation": {
|
| 179 |
+
"segment/uint16_labels/v1": {
|
| 180 |
+
"storage": "mask.mkv",
|
| 181 |
+
"dtype": "uint16",
|
| 182 |
+
"mapping": "instances.jsonl",
|
| 183 |
+
"valid_shape": [
|
| 184 |
+
"T"
|
| 185 |
+
],
|
| 186 |
+
"required_metadata": [
|
| 187 |
+
"segmentation_type",
|
| 188 |
+
"coverage",
|
| 189 |
+
"mapping_ref",
|
| 190 |
+
"storage"
|
| 191 |
+
],
|
| 192 |
+
"shape": [
|
| 193 |
+
"T",
|
| 194 |
+
"H",
|
| 195 |
+
"W"
|
| 196 |
+
],
|
| 197 |
+
"reserved_codes": {
|
| 198 |
+
"0": "unassigned",
|
| 199 |
+
"65535": "ignore"
|
| 200 |
+
},
|
| 201 |
+
"region_codes": [
|
| 202 |
+
1,
|
| 203 |
+
65534
|
| 204 |
+
],
|
| 205 |
+
"allowed_storage_profiles": [
|
| 206 |
+
"mkv/uint16_ffv1/v1"
|
| 207 |
+
]
|
| 208 |
+
},
|
| 209 |
+
"segment/instance_polygons/v1": {
|
| 210 |
+
"storage": "polygons.jsonl",
|
| 211 |
+
"mapping": "instances.jsonl",
|
| 212 |
+
"frame_keys": [
|
| 213 |
+
"frame_index",
|
| 214 |
+
"instances"
|
| 215 |
+
],
|
| 216 |
+
"instance_keys": [
|
| 217 |
+
"mask_value",
|
| 218 |
+
"polygons"
|
| 219 |
+
],
|
| 220 |
+
"coordinate_unit": "pixel",
|
| 221 |
+
"overlap_allowed": true,
|
| 222 |
+
"valid_shape": [
|
| 223 |
+
"T"
|
| 224 |
+
],
|
| 225 |
+
"required_metadata": [
|
| 226 |
+
"segmentation_type",
|
| 227 |
+
"coverage",
|
| 228 |
+
"mapping_ref"
|
| 229 |
+
],
|
| 230 |
+
"polygon_shape": [
|
| 231 |
+
"N",
|
| 232 |
+
2
|
| 233 |
+
],
|
| 234 |
+
"holes_supported": false
|
| 235 |
+
},
|
| 236 |
+
"segment/foreground_intensity/v1": {
|
| 237 |
+
"storage": "mask.mkv",
|
| 238 |
+
"dtype": "uint16",
|
| 239 |
+
"value_range": [
|
| 240 |
+
0,
|
| 241 |
+
255
|
| 242 |
+
],
|
| 243 |
+
"normalization_scale": 0.00392156862745098,
|
| 244 |
+
"axes": [
|
| 245 |
+
"T",
|
| 246 |
+
"height",
|
| 247 |
+
"width"
|
| 248 |
+
],
|
| 249 |
+
"meaning": "native hand foreground intensity; individual hand or union declared in metadata; not instance codes or calibrated probability",
|
| 250 |
+
"zero": "background",
|
| 251 |
+
"full_scale": "foreground",
|
| 252 |
+
"mapping": "foreground_category in component metadata",
|
| 253 |
+
"valid_shape": [
|
| 254 |
+
"T"
|
| 255 |
+
],
|
| 256 |
+
"required_metadata": [
|
| 257 |
+
"segmentation_type",
|
| 258 |
+
"coverage",
|
| 259 |
+
"value_range",
|
| 260 |
+
"normalization_scale",
|
| 261 |
+
"foreground_category",
|
| 262 |
+
"entity_id",
|
| 263 |
+
"storage"
|
| 264 |
+
],
|
| 265 |
+
"shape": [
|
| 266 |
+
"T",
|
| 267 |
+
"H",
|
| 268 |
+
"W"
|
| 269 |
+
],
|
| 270 |
+
"allowed_storage_profiles": [
|
| 271 |
+
"mkv/uint16_ffv1/v1"
|
| 272 |
+
]
|
| 273 |
+
}
|
| 274 |
+
},
|
| 275 |
+
"note": "Registry for hand-warehouse/1.1. Read CONTRACT.md and MIGRATION.md. This is a declarative registry, not a JSON Schema document or executable validator. Runtime readers/converters/validators still require adaptation.",
|
| 276 |
+
"components": {
|
| 277 |
+
"mano/axis_angle61/v1": {
|
| 278 |
+
"storage": "pt",
|
| 279 |
+
"dtype": "float32",
|
| 280 |
+
"shape": [
|
| 281 |
+
"T",
|
| 282 |
+
2,
|
| 283 |
+
61
|
| 284 |
+
],
|
| 285 |
+
"valid_shape": [
|
| 286 |
+
"T",
|
| 287 |
+
2
|
| 288 |
+
],
|
| 289 |
+
"unit": "m",
|
| 290 |
+
"angle_unit": "rad",
|
| 291 |
+
"coordinate_frame": "camera",
|
| 292 |
+
"layout": {
|
| 293 |
+
"pose_axis_angle": [
|
| 294 |
+
0,
|
| 295 |
+
48
|
| 296 |
+
],
|
| 297 |
+
"shape": [
|
| 298 |
+
48,
|
| 299 |
+
58
|
| 300 |
+
],
|
| 301 |
+
"translation": [
|
| 302 |
+
58,
|
| 303 |
+
61
|
| 304 |
+
]
|
| 305 |
+
},
|
| 306 |
+
"allowed_storage_profiles": [
|
| 307 |
+
"pt/tensor_bundle/v1"
|
| 308 |
+
],
|
| 309 |
+
"allowed_valid_storage_profiles": [
|
| 310 |
+
"pt/tensor_bundle/v1"
|
| 311 |
+
],
|
| 312 |
+
"valid_storage": "pt",
|
| 313 |
+
"tensor_container": "dict",
|
| 314 |
+
"valid_dtype": "bool",
|
| 315 |
+
"required_metadata": [
|
| 316 |
+
"data_ref",
|
| 317 |
+
"data_key",
|
| 318 |
+
"valid_ref",
|
| 319 |
+
"valid_key",
|
| 320 |
+
"storage",
|
| 321 |
+
"valid_storage"
|
| 322 |
+
]
|
| 323 |
+
},
|
| 324 |
+
"keypoints/uv/v1": {
|
| 325 |
+
"storage": "pt",
|
| 326 |
+
"dtype": "float32",
|
| 327 |
+
"shape": [
|
| 328 |
+
"T",
|
| 329 |
+
2,
|
| 330 |
+
21,
|
| 331 |
+
2
|
| 332 |
+
],
|
| 333 |
+
"valid_shape": [
|
| 334 |
+
"T",
|
| 335 |
+
2,
|
| 336 |
+
21
|
| 337 |
+
],
|
| 338 |
+
"unit": "pixel",
|
| 339 |
+
"required_metadata": [
|
| 340 |
+
"keypoint_schema",
|
| 341 |
+
"data_ref",
|
| 342 |
+
"data_key",
|
| 343 |
+
"valid_ref",
|
| 344 |
+
"valid_key",
|
| 345 |
+
"storage",
|
| 346 |
+
"valid_storage"
|
| 347 |
+
],
|
| 348 |
+
"allowed_storage_profiles": [
|
| 349 |
+
"pt/tensor_bundle/v1"
|
| 350 |
+
],
|
| 351 |
+
"allowed_valid_storage_profiles": [
|
| 352 |
+
"pt/tensor_bundle/v1"
|
| 353 |
+
],
|
| 354 |
+
"valid_storage": "pt",
|
| 355 |
+
"tensor_container": "dict",
|
| 356 |
+
"valid_dtype": "bool"
|
| 357 |
+
},
|
| 358 |
+
"keypoints/xyz/v1": {
|
| 359 |
+
"storage": "pt",
|
| 360 |
+
"dtype": "float32",
|
| 361 |
+
"shape": [
|
| 362 |
+
"T",
|
| 363 |
+
2,
|
| 364 |
+
21,
|
| 365 |
+
3
|
| 366 |
+
],
|
| 367 |
+
"valid_shape": [
|
| 368 |
+
"T",
|
| 369 |
+
2,
|
| 370 |
+
21
|
| 371 |
+
],
|
| 372 |
+
"unit": "m",
|
| 373 |
+
"required_metadata": [
|
| 374 |
+
"keypoint_schema",
|
| 375 |
+
"data_ref",
|
| 376 |
+
"data_key",
|
| 377 |
+
"valid_ref",
|
| 378 |
+
"valid_key",
|
| 379 |
+
"storage",
|
| 380 |
+
"valid_storage"
|
| 381 |
+
],
|
| 382 |
+
"allowed_storage_profiles": [
|
| 383 |
+
"pt/tensor_bundle/v1"
|
| 384 |
+
],
|
| 385 |
+
"allowed_valid_storage_profiles": [
|
| 386 |
+
"pt/tensor_bundle/v1"
|
| 387 |
+
],
|
| 388 |
+
"valid_storage": "pt",
|
| 389 |
+
"tensor_container": "dict",
|
| 390 |
+
"valid_dtype": "bool"
|
| 391 |
+
},
|
| 392 |
+
"depth/z_float32/v1": {
|
| 393 |
+
"storage": "mkv",
|
| 394 |
+
"dtype": "float32",
|
| 395 |
+
"shape": [
|
| 396 |
+
"T",
|
| 397 |
+
"H",
|
| 398 |
+
"W"
|
| 399 |
+
],
|
| 400 |
+
"valid_shape": [
|
| 401 |
+
"T",
|
| 402 |
+
"H",
|
| 403 |
+
"W"
|
| 404 |
+
],
|
| 405 |
+
"unit": "m",
|
| 406 |
+
"depth_type": "z",
|
| 407 |
+
"pixel_grid": "current_rgb",
|
| 408 |
+
"coordinate_frame": "current_rgb_camera",
|
| 409 |
+
"valid_storage": "mkv",
|
| 410 |
+
"allowed_storage_profiles": [
|
| 411 |
+
"mkv/depth_float32_bits/v1"
|
| 412 |
+
],
|
| 413 |
+
"allowed_valid_storage_profiles": [
|
| 414 |
+
"mkv/bool_ffv1/v1"
|
| 415 |
+
],
|
| 416 |
+
"required_metadata": [
|
| 417 |
+
"storage",
|
| 418 |
+
"valid_storage",
|
| 419 |
+
"depth_origin"
|
| 420 |
+
],
|
| 421 |
+
"depth_origin_values": [
|
| 422 |
+
"measured",
|
| 423 |
+
"rendered",
|
| 424 |
+
"unknown"
|
| 425 |
+
]
|
| 426 |
+
},
|
| 427 |
+
"transform/se3/v1": {
|
| 428 |
+
"storage": "pt",
|
| 429 |
+
"dtype": "float32",
|
| 430 |
+
"shape": [
|
| 431 |
+
"T",
|
| 432 |
+
4,
|
| 433 |
+
4
|
| 434 |
+
],
|
| 435 |
+
"valid_shape": [
|
| 436 |
+
"T"
|
| 437 |
+
],
|
| 438 |
+
"unit": "m",
|
| 439 |
+
"required_metadata": [
|
| 440 |
+
"convention",
|
| 441 |
+
"data_ref",
|
| 442 |
+
"data_key",
|
| 443 |
+
"valid_ref",
|
| 444 |
+
"valid_key",
|
| 445 |
+
"storage",
|
| 446 |
+
"valid_storage"
|
| 447 |
+
],
|
| 448 |
+
"allowed_storage_profiles": [
|
| 449 |
+
"pt/tensor_bundle/v1"
|
| 450 |
+
],
|
| 451 |
+
"allowed_valid_storage_profiles": [
|
| 452 |
+
"pt/tensor_bundle/v1"
|
| 453 |
+
],
|
| 454 |
+
"valid_storage": "pt",
|
| 455 |
+
"tensor_container": "dict",
|
| 456 |
+
"valid_dtype": "bool"
|
| 457 |
+
},
|
| 458 |
+
"object/rigid/v1": {
|
| 459 |
+
"storage": "pt",
|
| 460 |
+
"dtype": "float32",
|
| 461 |
+
"shape": [
|
| 462 |
+
"T",
|
| 463 |
+
4,
|
| 464 |
+
4
|
| 465 |
+
],
|
| 466 |
+
"valid_shape": [
|
| 467 |
+
"T"
|
| 468 |
+
],
|
| 469 |
+
"unit": "m",
|
| 470 |
+
"required_metadata": [
|
| 471 |
+
"convention",
|
| 472 |
+
"data_ref",
|
| 473 |
+
"data_key",
|
| 474 |
+
"valid_ref",
|
| 475 |
+
"valid_key",
|
| 476 |
+
"storage",
|
| 477 |
+
"valid_storage"
|
| 478 |
+
],
|
| 479 |
+
"allowed_storage_profiles": [
|
| 480 |
+
"pt/tensor_bundle/v1"
|
| 481 |
+
],
|
| 482 |
+
"allowed_valid_storage_profiles": [
|
| 483 |
+
"pt/tensor_bundle/v1"
|
| 484 |
+
],
|
| 485 |
+
"valid_storage": "pt",
|
| 486 |
+
"tensor_container": "dict",
|
| 487 |
+
"valid_dtype": "bool"
|
| 488 |
+
},
|
| 489 |
+
"camera/pinhole/v1": {
|
| 490 |
+
"storage": "pt",
|
| 491 |
+
"dtype": "float32",
|
| 492 |
+
"shape": [
|
| 493 |
+
"T",
|
| 494 |
+
3,
|
| 495 |
+
3
|
| 496 |
+
],
|
| 497 |
+
"valid_shape": [
|
| 498 |
+
"T"
|
| 499 |
+
],
|
| 500 |
+
"allowed_storage_profiles": [
|
| 501 |
+
"pt/tensor_bundle/v1"
|
| 502 |
+
],
|
| 503 |
+
"allowed_valid_storage_profiles": [
|
| 504 |
+
"pt/tensor_bundle/v1"
|
| 505 |
+
],
|
| 506 |
+
"valid_storage": "pt",
|
| 507 |
+
"tensor_container": "dict",
|
| 508 |
+
"valid_dtype": "bool",
|
| 509 |
+
"required_metadata": [
|
| 510 |
+
"data_ref",
|
| 511 |
+
"data_key",
|
| 512 |
+
"valid_ref",
|
| 513 |
+
"valid_key",
|
| 514 |
+
"storage",
|
| 515 |
+
"valid_storage"
|
| 516 |
+
]
|
| 517 |
+
},
|
| 518 |
+
"camera/rational8/v1": {
|
| 519 |
+
"storage": "pt",
|
| 520 |
+
"dtype": "float32",
|
| 521 |
+
"shape": [
|
| 522 |
+
"T",
|
| 523 |
+
3,
|
| 524 |
+
3
|
| 525 |
+
],
|
| 526 |
+
"valid_shape": [
|
| 527 |
+
"T"
|
| 528 |
+
],
|
| 529 |
+
"allowed_storage_profiles": [
|
| 530 |
+
"pt/tensor_bundle/v1"
|
| 531 |
+
],
|
| 532 |
+
"allowed_valid_storage_profiles": [
|
| 533 |
+
"pt/tensor_bundle/v1"
|
| 534 |
+
],
|
| 535 |
+
"valid_storage": "pt",
|
| 536 |
+
"tensor_container": "dict",
|
| 537 |
+
"valid_dtype": "bool",
|
| 538 |
+
"required_metadata": [
|
| 539 |
+
"data_ref",
|
| 540 |
+
"data_key",
|
| 541 |
+
"valid_ref",
|
| 542 |
+
"valid_key",
|
| 543 |
+
"storage",
|
| 544 |
+
"valid_storage",
|
| 545 |
+
"distortion_ref",
|
| 546 |
+
"distortion_key",
|
| 547 |
+
"distortion_valid_ref",
|
| 548 |
+
"distortion_valid_key"
|
| 549 |
+
]
|
| 550 |
+
},
|
| 551 |
+
"camera/opencv_fisheye4/v1": {
|
| 552 |
+
"storage": "pt",
|
| 553 |
+
"dtype": "float32",
|
| 554 |
+
"shape": [
|
| 555 |
+
"T",
|
| 556 |
+
3,
|
| 557 |
+
3
|
| 558 |
+
],
|
| 559 |
+
"valid_shape": [
|
| 560 |
+
"T"
|
| 561 |
+
],
|
| 562 |
+
"allowed_storage_profiles": [
|
| 563 |
+
"pt/tensor_bundle/v1"
|
| 564 |
+
],
|
| 565 |
+
"allowed_valid_storage_profiles": [
|
| 566 |
+
"pt/tensor_bundle/v1"
|
| 567 |
+
],
|
| 568 |
+
"valid_storage": "pt",
|
| 569 |
+
"tensor_container": "dict",
|
| 570 |
+
"valid_dtype": "bool",
|
| 571 |
+
"required_metadata": [
|
| 572 |
+
"data_ref",
|
| 573 |
+
"data_key",
|
| 574 |
+
"valid_ref",
|
| 575 |
+
"valid_key",
|
| 576 |
+
"storage",
|
| 577 |
+
"valid_storage",
|
| 578 |
+
"distortion_ref",
|
| 579 |
+
"distortion_key",
|
| 580 |
+
"distortion_valid_ref",
|
| 581 |
+
"distortion_valid_key"
|
| 582 |
+
]
|
| 583 |
+
},
|
| 584 |
+
"camera/fisheye624/v1": {
|
| 585 |
+
"storage": "pt",
|
| 586 |
+
"dtype": "float32",
|
| 587 |
+
"shape": [
|
| 588 |
+
"T",
|
| 589 |
+
15
|
| 590 |
+
],
|
| 591 |
+
"valid_shape": [
|
| 592 |
+
"T"
|
| 593 |
+
],
|
| 594 |
+
"allowed_storage_profiles": [
|
| 595 |
+
"pt/tensor_bundle/v1"
|
| 596 |
+
],
|
| 597 |
+
"allowed_valid_storage_profiles": [
|
| 598 |
+
"pt/tensor_bundle/v1"
|
| 599 |
+
],
|
| 600 |
+
"valid_storage": "pt",
|
| 601 |
+
"tensor_container": "dict",
|
| 602 |
+
"valid_dtype": "bool",
|
| 603 |
+
"required_metadata": [
|
| 604 |
+
"data_ref",
|
| 605 |
+
"data_key",
|
| 606 |
+
"valid_ref",
|
| 607 |
+
"valid_key",
|
| 608 |
+
"storage",
|
| 609 |
+
"valid_storage"
|
| 610 |
+
]
|
| 611 |
+
},
|
| 612 |
+
"camera/distortion8/v1": {
|
| 613 |
+
"storage": "pt",
|
| 614 |
+
"dtype": "float32",
|
| 615 |
+
"shape": [
|
| 616 |
+
"T",
|
| 617 |
+
8
|
| 618 |
+
],
|
| 619 |
+
"valid_shape": [
|
| 620 |
+
"T"
|
| 621 |
+
],
|
| 622 |
+
"allowed_storage_profiles": [
|
| 623 |
+
"pt/tensor_bundle/v1"
|
| 624 |
+
],
|
| 625 |
+
"allowed_valid_storage_profiles": [
|
| 626 |
+
"pt/tensor_bundle/v1"
|
| 627 |
+
],
|
| 628 |
+
"valid_storage": "pt",
|
| 629 |
+
"tensor_container": "dict",
|
| 630 |
+
"valid_dtype": "bool",
|
| 631 |
+
"required_metadata": [
|
| 632 |
+
"data_ref",
|
| 633 |
+
"data_key",
|
| 634 |
+
"valid_ref",
|
| 635 |
+
"valid_key",
|
| 636 |
+
"storage",
|
| 637 |
+
"valid_storage"
|
| 638 |
+
]
|
| 639 |
+
},
|
| 640 |
+
"camera/fisheye4_distortion/v1": {
|
| 641 |
+
"storage": "pt",
|
| 642 |
+
"dtype": "float32",
|
| 643 |
+
"shape": [
|
| 644 |
+
"T",
|
| 645 |
+
4
|
| 646 |
+
],
|
| 647 |
+
"valid_shape": [
|
| 648 |
+
"T"
|
| 649 |
+
],
|
| 650 |
+
"allowed_storage_profiles": [
|
| 651 |
+
"pt/tensor_bundle/v1"
|
| 652 |
+
],
|
| 653 |
+
"allowed_valid_storage_profiles": [
|
| 654 |
+
"pt/tensor_bundle/v1"
|
| 655 |
+
],
|
| 656 |
+
"valid_storage": "pt",
|
| 657 |
+
"tensor_container": "dict",
|
| 658 |
+
"valid_dtype": "bool",
|
| 659 |
+
"required_metadata": [
|
| 660 |
+
"data_ref",
|
| 661 |
+
"data_key",
|
| 662 |
+
"valid_ref",
|
| 663 |
+
"valid_key",
|
| 664 |
+
"storage",
|
| 665 |
+
"valid_storage"
|
| 666 |
+
]
|
| 667 |
+
},
|
| 668 |
+
"object/joint_state/v1": {
|
| 669 |
+
"storage": "pt",
|
| 670 |
+
"dtype": "float32",
|
| 671 |
+
"shape": [
|
| 672 |
+
"T",
|
| 673 |
+
"J"
|
| 674 |
+
],
|
| 675 |
+
"valid_shape": [
|
| 676 |
+
"T",
|
| 677 |
+
"J"
|
| 678 |
+
],
|
| 679 |
+
"required_metadata": [
|
| 680 |
+
"joint_order",
|
| 681 |
+
"data_ref",
|
| 682 |
+
"data_key",
|
| 683 |
+
"valid_ref",
|
| 684 |
+
"valid_key",
|
| 685 |
+
"storage",
|
| 686 |
+
"valid_storage"
|
| 687 |
+
],
|
| 688 |
+
"unit_rule": "revolute radians; prismatic metres; mixed types declared per joint",
|
| 689 |
+
"allowed_storage_profiles": [
|
| 690 |
+
"pt/tensor_bundle/v1"
|
| 691 |
+
],
|
| 692 |
+
"allowed_valid_storage_profiles": [
|
| 693 |
+
"pt/tensor_bundle/v1"
|
| 694 |
+
],
|
| 695 |
+
"valid_storage": "pt",
|
| 696 |
+
"tensor_container": "dict",
|
| 697 |
+
"valid_dtype": "bool"
|
| 698 |
+
},
|
| 699 |
+
"object_keypoints/camera/v1": {
|
| 700 |
+
"storage": "pt",
|
| 701 |
+
"dtype": "float32",
|
| 702 |
+
"shape": [
|
| 703 |
+
"T",
|
| 704 |
+
"K",
|
| 705 |
+
3
|
| 706 |
+
],
|
| 707 |
+
"valid_shape": [
|
| 708 |
+
"T",
|
| 709 |
+
"K"
|
| 710 |
+
],
|
| 711 |
+
"unit": "m",
|
| 712 |
+
"coordinate_frame": "camera",
|
| 713 |
+
"required_metadata": [
|
| 714 |
+
"keypoint_schema",
|
| 715 |
+
"data_ref",
|
| 716 |
+
"data_key",
|
| 717 |
+
"valid_ref",
|
| 718 |
+
"valid_key",
|
| 719 |
+
"storage",
|
| 720 |
+
"valid_storage"
|
| 721 |
+
],
|
| 722 |
+
"allowed_storage_profiles": [
|
| 723 |
+
"pt/tensor_bundle/v1"
|
| 724 |
+
],
|
| 725 |
+
"allowed_valid_storage_profiles": [
|
| 726 |
+
"pt/tensor_bundle/v1"
|
| 727 |
+
],
|
| 728 |
+
"valid_storage": "pt",
|
| 729 |
+
"tensor_container": "dict",
|
| 730 |
+
"valid_dtype": "bool"
|
| 731 |
+
},
|
| 732 |
+
"object/dimensions/v1": {
|
| 733 |
+
"storage": "pt",
|
| 734 |
+
"dtype": "float32",
|
| 735 |
+
"shape": [
|
| 736 |
+
"T",
|
| 737 |
+
3
|
| 738 |
+
],
|
| 739 |
+
"valid_shape": [
|
| 740 |
+
"T"
|
| 741 |
+
],
|
| 742 |
+
"unit": "m",
|
| 743 |
+
"required_metadata": [
|
| 744 |
+
"dimensions_semantics",
|
| 745 |
+
"data_ref",
|
| 746 |
+
"data_key",
|
| 747 |
+
"valid_ref",
|
| 748 |
+
"valid_key",
|
| 749 |
+
"storage",
|
| 750 |
+
"valid_storage"
|
| 751 |
+
],
|
| 752 |
+
"axis_order": [
|
| 753 |
+
"length",
|
| 754 |
+
"width",
|
| 755 |
+
"height"
|
| 756 |
+
],
|
| 757 |
+
"scale_rule": "do not apply to mesh without source-supported size/scale relation",
|
| 758 |
+
"allowed_storage_profiles": [
|
| 759 |
+
"pt/tensor_bundle/v1"
|
| 760 |
+
],
|
| 761 |
+
"allowed_valid_storage_profiles": [
|
| 762 |
+
"pt/tensor_bundle/v1"
|
| 763 |
+
],
|
| 764 |
+
"valid_storage": "pt",
|
| 765 |
+
"tensor_container": "dict",
|
| 766 |
+
"valid_dtype": "bool"
|
| 767 |
+
},
|
| 768 |
+
"object_keypoints/template/v1": {
|
| 769 |
+
"storage": "pt",
|
| 770 |
+
"dtype": "float32",
|
| 771 |
+
"shape": [
|
| 772 |
+
"K",
|
| 773 |
+
3
|
| 774 |
+
],
|
| 775 |
+
"valid_shape": [
|
| 776 |
+
"K"
|
| 777 |
+
],
|
| 778 |
+
"unit": "m",
|
| 779 |
+
"coordinate_frame": "object",
|
| 780 |
+
"static": true,
|
| 781 |
+
"required_metadata": [
|
| 782 |
+
"keypoint_schema",
|
| 783 |
+
"data_ref",
|
| 784 |
+
"data_key",
|
| 785 |
+
"valid_ref",
|
| 786 |
+
"valid_key",
|
| 787 |
+
"storage",
|
| 788 |
+
"valid_storage"
|
| 789 |
+
],
|
| 790 |
+
"allowed_storage_profiles": [
|
| 791 |
+
"pt/tensor_bundle/v1"
|
| 792 |
+
],
|
| 793 |
+
"allowed_valid_storage_profiles": [
|
| 794 |
+
"pt/tensor_bundle/v1"
|
| 795 |
+
],
|
| 796 |
+
"valid_storage": "pt",
|
| 797 |
+
"tensor_container": "dict",
|
| 798 |
+
"valid_dtype": "bool"
|
| 799 |
+
},
|
| 800 |
+
"mesh/obj/v1": {
|
| 801 |
+
"storage": "obj",
|
| 802 |
+
"unit": "m",
|
| 803 |
+
"static": true,
|
| 804 |
+
"valid_shape": [],
|
| 805 |
+
"dependencies": "MTL and textures retained under owning object"
|
| 806 |
+
},
|
| 807 |
+
"rgb/uint8/v1": {
|
| 808 |
+
"storage": "mkv",
|
| 809 |
+
"dtype": "uint8",
|
| 810 |
+
"shape": [
|
| 811 |
+
"T",
|
| 812 |
+
"H",
|
| 813 |
+
"W",
|
| 814 |
+
3
|
| 815 |
+
],
|
| 816 |
+
"valid_shape": [
|
| 817 |
+
"T"
|
| 818 |
+
],
|
| 819 |
+
"color_order": "RGB",
|
| 820 |
+
"allowed_storage_profiles": [
|
| 821 |
+
"mkv/mjpeg_copy/v1",
|
| 822 |
+
"mkv/source_copy/v1",
|
| 823 |
+
"mkv/h264_rgb_lossless/v1",
|
| 824 |
+
"mkv/ffv1_rgb/v1"
|
| 825 |
+
],
|
| 826 |
+
"required_metadata": [
|
| 827 |
+
"storage"
|
| 828 |
+
]
|
| 829 |
+
},
|
| 830 |
+
"contact/relations/v1": {
|
| 831 |
+
"storage": "jsonl",
|
| 832 |
+
"valid_shape": [
|
| 833 |
+
"T"
|
| 834 |
+
],
|
| 835 |
+
"frame_keys": [
|
| 836 |
+
"frame_index",
|
| 837 |
+
"relations"
|
| 838 |
+
],
|
| 839 |
+
"absence_semantics": "no record is not a negative contact annotation"
|
| 840 |
+
},
|
| 841 |
+
"contact/vertex_region/v1": {
|
| 842 |
+
"storage": "pt",
|
| 843 |
+
"dtype": "bool",
|
| 844 |
+
"shape": [
|
| 845 |
+
"T",
|
| 846 |
+
"V"
|
| 847 |
+
],
|
| 848 |
+
"valid_shape": [
|
| 849 |
+
"T",
|
| 850 |
+
"V"
|
| 851 |
+
],
|
| 852 |
+
"required_metadata": [
|
| 853 |
+
"source_geometry_ref",
|
| 854 |
+
"target_geometry_ref",
|
| 855 |
+
"topology_id",
|
| 856 |
+
"data_ref",
|
| 857 |
+
"data_key",
|
| 858 |
+
"valid_ref",
|
| 859 |
+
"valid_key",
|
| 860 |
+
"storage",
|
| 861 |
+
"valid_storage"
|
| 862 |
+
],
|
| 863 |
+
"pilot_status": "defined_not_empirically_validated",
|
| 864 |
+
"allowed_storage_profiles": [
|
| 865 |
+
"pt/tensor_bundle/v1"
|
| 866 |
+
],
|
| 867 |
+
"allowed_valid_storage_profiles": [
|
| 868 |
+
"pt/tensor_bundle/v1"
|
| 869 |
+
],
|
| 870 |
+
"valid_storage": "pt",
|
| 871 |
+
"tensor_container": "dict",
|
| 872 |
+
"valid_dtype": "bool"
|
| 873 |
+
},
|
| 874 |
+
"contact/vertex_distance/v1": {
|
| 875 |
+
"storage": "pt",
|
| 876 |
+
"dtype": "float32",
|
| 877 |
+
"shape": [
|
| 878 |
+
"T",
|
| 879 |
+
"V"
|
| 880 |
+
],
|
| 881 |
+
"valid_shape": [
|
| 882 |
+
"T",
|
| 883 |
+
"V"
|
| 884 |
+
],
|
| 885 |
+
"unit": "m",
|
| 886 |
+
"required_metadata": [
|
| 887 |
+
"source_geometry_ref",
|
| 888 |
+
"target_geometry_ref",
|
| 889 |
+
"topology_id",
|
| 890 |
+
"distance_definition",
|
| 891 |
+
"data_ref",
|
| 892 |
+
"data_key",
|
| 893 |
+
"valid_ref",
|
| 894 |
+
"valid_key",
|
| 895 |
+
"storage",
|
| 896 |
+
"valid_storage"
|
| 897 |
+
],
|
| 898 |
+
"pilot_status": "defined_not_empirically_validated",
|
| 899 |
+
"allowed_storage_profiles": [
|
| 900 |
+
"pt/tensor_bundle/v1"
|
| 901 |
+
],
|
| 902 |
+
"allowed_valid_storage_profiles": [
|
| 903 |
+
"pt/tensor_bundle/v1"
|
| 904 |
+
],
|
| 905 |
+
"valid_storage": "pt",
|
| 906 |
+
"tensor_container": "dict",
|
| 907 |
+
"valid_dtype": "bool"
|
| 908 |
+
},
|
| 909 |
+
"object/articulated/v1": {
|
| 910 |
+
"storage": "json",
|
| 911 |
+
"required_keys": [
|
| 912 |
+
"parts",
|
| 913 |
+
"joints"
|
| 914 |
+
],
|
| 915 |
+
"part_keys": [
|
| 916 |
+
"part_id",
|
| 917 |
+
"parent_id",
|
| 918 |
+
"has_model",
|
| 919 |
+
"mesh_ref"
|
| 920 |
+
],
|
| 921 |
+
"hierarchy_semantics": "declare mechanical articulation or semantic containment; containment alone does not imply joints",
|
| 922 |
+
"acyclic": true
|
| 923 |
+
},
|
| 924 |
+
"segment/uint16_labels/v1": {
|
| 925 |
+
"storage": "mkv",
|
| 926 |
+
"dtype": "uint16",
|
| 927 |
+
"mapping": "instances.jsonl",
|
| 928 |
+
"valid_shape": [
|
| 929 |
+
"T"
|
| 930 |
+
],
|
| 931 |
+
"required_metadata": [
|
| 932 |
+
"segmentation_type",
|
| 933 |
+
"coverage",
|
| 934 |
+
"mapping_ref",
|
| 935 |
+
"storage"
|
| 936 |
+
],
|
| 937 |
+
"shape": [
|
| 938 |
+
"T",
|
| 939 |
+
"H",
|
| 940 |
+
"W"
|
| 941 |
+
],
|
| 942 |
+
"reserved_codes": {
|
| 943 |
+
"0": "unassigned",
|
| 944 |
+
"65535": "ignore"
|
| 945 |
+
},
|
| 946 |
+
"region_codes": [
|
| 947 |
+
1,
|
| 948 |
+
65534
|
| 949 |
+
],
|
| 950 |
+
"allowed_storage_profiles": [
|
| 951 |
+
"mkv/uint16_ffv1/v1"
|
| 952 |
+
]
|
| 953 |
+
},
|
| 954 |
+
"segment/instance_polygons/v1": {
|
| 955 |
+
"storage": "jsonl",
|
| 956 |
+
"mapping": "instances.jsonl",
|
| 957 |
+
"frame_keys": [
|
| 958 |
+
"frame_index",
|
| 959 |
+
"instances"
|
| 960 |
+
],
|
| 961 |
+
"instance_keys": [
|
| 962 |
+
"mask_value",
|
| 963 |
+
"polygons"
|
| 964 |
+
],
|
| 965 |
+
"coordinate_unit": "pixel",
|
| 966 |
+
"overlap_allowed": true,
|
| 967 |
+
"valid_shape": [
|
| 968 |
+
"T"
|
| 969 |
+
],
|
| 970 |
+
"required_metadata": [
|
| 971 |
+
"segmentation_type",
|
| 972 |
+
"coverage",
|
| 973 |
+
"mapping_ref"
|
| 974 |
+
],
|
| 975 |
+
"polygon_shape": [
|
| 976 |
+
"N",
|
| 977 |
+
2
|
| 978 |
+
],
|
| 979 |
+
"holes_supported": false
|
| 980 |
+
},
|
| 981 |
+
"segment/foreground_intensity/v1": {
|
| 982 |
+
"storage": "mkv",
|
| 983 |
+
"dtype": "uint16",
|
| 984 |
+
"value_range": [
|
| 985 |
+
0,
|
| 986 |
+
255
|
| 987 |
+
],
|
| 988 |
+
"normalization_scale": 0.00392156862745098,
|
| 989 |
+
"axes": [
|
| 990 |
+
"T",
|
| 991 |
+
"height",
|
| 992 |
+
"width"
|
| 993 |
+
],
|
| 994 |
+
"meaning": "native hand foreground intensity; individual hand or union declared in metadata; not instance codes or calibrated probability",
|
| 995 |
+
"zero": "background",
|
| 996 |
+
"full_scale": "foreground",
|
| 997 |
+
"mapping": "foreground_category in component metadata",
|
| 998 |
+
"valid_shape": [
|
| 999 |
+
"T"
|
| 1000 |
+
],
|
| 1001 |
+
"required_metadata": [
|
| 1002 |
+
"segmentation_type",
|
| 1003 |
+
"coverage",
|
| 1004 |
+
"value_range",
|
| 1005 |
+
"normalization_scale",
|
| 1006 |
+
"foreground_category",
|
| 1007 |
+
"entity_id",
|
| 1008 |
+
"storage"
|
| 1009 |
+
],
|
| 1010 |
+
"shape": [
|
| 1011 |
+
"T",
|
| 1012 |
+
"H",
|
| 1013 |
+
"W"
|
| 1014 |
+
],
|
| 1015 |
+
"allowed_storage_profiles": [
|
| 1016 |
+
"mkv/uint16_ffv1/v1"
|
| 1017 |
+
]
|
| 1018 |
+
},
|
| 1019 |
+
"object/vertex_part_ids/v1": {
|
| 1020 |
+
"storage": "pt",
|
| 1021 |
+
"tensor_container": "dict",
|
| 1022 |
+
"dtype": "int64",
|
| 1023 |
+
"shape": [
|
| 1024 |
+
"V"
|
| 1025 |
+
],
|
| 1026 |
+
"valid_shape": [
|
| 1027 |
+
"V"
|
| 1028 |
+
],
|
| 1029 |
+
"valid_dtype": "bool",
|
| 1030 |
+
"static": true,
|
| 1031 |
+
"unknown_value": -1,
|
| 1032 |
+
"valid_rule": "data != -1; every valid integer resolves in part_id_mapping",
|
| 1033 |
+
"required_metadata": [
|
| 1034 |
+
"mesh_ref",
|
| 1035 |
+
"topology_id",
|
| 1036 |
+
"part_id_mapping",
|
| 1037 |
+
"data_ref",
|
| 1038 |
+
"data_key",
|
| 1039 |
+
"valid_ref",
|
| 1040 |
+
"valid_key",
|
| 1041 |
+
"storage",
|
| 1042 |
+
"valid_storage"
|
| 1043 |
+
],
|
| 1044 |
+
"allowed_storage_profiles": [
|
| 1045 |
+
"pt/tensor_bundle/v1"
|
| 1046 |
+
],
|
| 1047 |
+
"allowed_valid_storage_profiles": [
|
| 1048 |
+
"pt/tensor_bundle/v1"
|
| 1049 |
+
],
|
| 1050 |
+
"valid_storage": "pt"
|
| 1051 |
+
}
|
| 1052 |
+
},
|
| 1053 |
+
"storage_revision": "lossless-video-2026-09-18",
|
| 1054 |
+
"sampling": {
|
| 1055 |
+
"image": {
|
| 1056 |
+
"single": {
|
| 1057 |
+
"T": 1
|
| 1058 |
+
},
|
| 1059 |
+
"independent": {
|
| 1060 |
+
"T": ">=2",
|
| 1061 |
+
"required_frame_fields": [
|
| 1062 |
+
"sample_id",
|
| 1063 |
+
"source_locator"
|
| 1064 |
+
],
|
| 1065 |
+
"temporal_relationship": false
|
| 1066 |
+
},
|
| 1067 |
+
"source_fps": null
|
| 1068 |
+
},
|
| 1069 |
+
"video": {
|
| 1070 |
+
"sampling_types": [
|
| 1071 |
+
"dense",
|
| 1072 |
+
"sparse"
|
| 1073 |
+
]
|
| 1074 |
+
}
|
| 1075 |
+
},
|
| 1076 |
+
"storage_profiles": {
|
| 1077 |
+
"mkv/mjpeg_copy/v1": {
|
| 1078 |
+
"container": "matroska",
|
| 1079 |
+
"codec": "mjpeg",
|
| 1080 |
+
"method": "stream_copy_from_source_jpeg",
|
| 1081 |
+
"logical_dtype": "uint8",
|
| 1082 |
+
"decoded_pixel_format": "rgb24",
|
| 1083 |
+
"validation": [
|
| 1084 |
+
"source_jpeg_packet_sha256_exact",
|
| 1085 |
+
"all_packet_count_order_and_dimensions_exact",
|
| 1086 |
+
"deterministic_decoded_rgb_sample_exact",
|
| 1087 |
+
"pilot_and_final_selected_whole_sequences_decoded_rgb_exact"
|
| 1088 |
+
],
|
| 1089 |
+
"validation_policy": {
|
| 1090 |
+
"id": "jpeg-packets-all-rgb-sample16/v1",
|
| 1091 |
+
"sample_count_per_view": 16,
|
| 1092 |
+
"short_views": "all_frames_if_T_less_than_16",
|
| 1093 |
+
"fixed_indices": "0,T-1,T//4,T//2,3*T//4, deduplicated",
|
| 1094 |
+
"remaining_indices": "sample without replacement to min(T,16) using Python random.Random(seed)",
|
| 1095 |
+
"seed": "first 8 bytes of SHA256(sequence_id/camera_id/20260920), big-endian integer",
|
| 1096 |
+
"report": "policy, exact selected frame indices, seed, separate packet and pixel coverage",
|
| 1097 |
+
"legacy_all_frame_pixel_proofs": "still accepted; preserve historical evidence"
|
| 1098 |
+
}
|
| 1099 |
+
},
|
| 1100 |
+
"mkv/source_copy/v1": {
|
| 1101 |
+
"container": "matroska",
|
| 1102 |
+
"codec": "source_codec_declared_in_metadata",
|
| 1103 |
+
"method": "stream_copy_only",
|
| 1104 |
+
"logical_dtype": "uint8",
|
| 1105 |
+
"decoded_pixel_format": "rgb24",
|
| 1106 |
+
"validation": [
|
| 1107 |
+
"no_reencoding",
|
| 1108 |
+
"all_decoded_rgb_frames_exact",
|
| 1109 |
+
"presentation_frame_order_exact"
|
| 1110 |
+
]
|
| 1111 |
+
},
|
| 1112 |
+
"mkv/h264_rgb_lossless/v1": {
|
| 1113 |
+
"container": "matroska",
|
| 1114 |
+
"codec": "h264",
|
| 1115 |
+
"encoder": "libx264rgb",
|
| 1116 |
+
"crf": 0,
|
| 1117 |
+
"decoded_pixel_format": "rgb24",
|
| 1118 |
+
"logical_dtype": "uint8",
|
| 1119 |
+
"gop": "declared_in_encoder_parameters",
|
| 1120 |
+
"validation": [
|
| 1121 |
+
"all_decoded_rgb_frames_exact"
|
| 1122 |
+
],
|
| 1123 |
+
"forbidden": [
|
| 1124 |
+
"lossy_rate_control",
|
| 1125 |
+
"rgb_to_yuv420_subsampling"
|
| 1126 |
+
]
|
| 1127 |
+
},
|
| 1128 |
+
"mkv/ffv1_rgb/v1": {
|
| 1129 |
+
"container": "matroska",
|
| 1130 |
+
"codec": "ffv1",
|
| 1131 |
+
"decoded_pixel_format": "rgb24",
|
| 1132 |
+
"logical_dtype": "uint8",
|
| 1133 |
+
"validation": [
|
| 1134 |
+
"all_decoded_rgb_frames_exact"
|
| 1135 |
+
]
|
| 1136 |
+
},
|
| 1137 |
+
"mkv/depth_float32_bits/v1": {
|
| 1138 |
+
"container": "matroska",
|
| 1139 |
+
"codec": "ffv1",
|
| 1140 |
+
"pixel_format": "gray16le",
|
| 1141 |
+
"logical_dtype": "float32",
|
| 1142 |
+
"logical_shape": [
|
| 1143 |
+
"T",
|
| 1144 |
+
"H",
|
| 1145 |
+
"W"
|
| 1146 |
+
],
|
| 1147 |
+
"encoded_shape": [
|
| 1148 |
+
"T",
|
| 1149 |
+
"H",
|
| 1150 |
+
"2*W"
|
| 1151 |
+
],
|
| 1152 |
+
"packing": "IEEE754 little-endian float32 bits; low uint16 in first W columns, high uint16 in last W columns",
|
| 1153 |
+
"decode": "reinterpret_float32(uint32(low) | (uint32(high) << 16))",
|
| 1154 |
+
"validation": [
|
| 1155 |
+
"all_float32_bits_exact_including_nan"
|
| 1156 |
+
]
|
| 1157 |
+
},
|
| 1158 |
+
"mkv/bool_ffv1/v1": {
|
| 1159 |
+
"container": "matroska",
|
| 1160 |
+
"codec": "ffv1",
|
| 1161 |
+
"pixel_format": "gray",
|
| 1162 |
+
"logical_dtype": "bool",
|
| 1163 |
+
"stored_values": [
|
| 1164 |
+
0,
|
| 1165 |
+
1
|
| 1166 |
+
],
|
| 1167 |
+
"validation": [
|
| 1168 |
+
"all_bool_values_exact"
|
| 1169 |
+
]
|
| 1170 |
+
},
|
| 1171 |
+
"mkv/uint16_ffv1/v1": {
|
| 1172 |
+
"container": "matroska",
|
| 1173 |
+
"codec": "ffv1",
|
| 1174 |
+
"pixel_formats": [
|
| 1175 |
+
"gray",
|
| 1176 |
+
"gray16le"
|
| 1177 |
+
],
|
| 1178 |
+
"logical_dtype": "uint16",
|
| 1179 |
+
"gray_condition": "all values <=255; decode by exact uint8-to-uint16 promotion",
|
| 1180 |
+
"validation": [
|
| 1181 |
+
"all_integer_values_exact"
|
| 1182 |
+
]
|
| 1183 |
+
},
|
| 1184 |
+
"pt/tensor_bundle/v1": {
|
| 1185 |
+
"container": "pytorch_pt",
|
| 1186 |
+
"root_type": "dict",
|
| 1187 |
+
"dictionary_key_type": "nonempty_string",
|
| 1188 |
+
"allowed_value_types": [
|
| 1189 |
+
"dict",
|
| 1190 |
+
"CPU torch.Tensor"
|
| 1191 |
+
],
|
| 1192 |
+
"tensor_entry": {
|
| 1193 |
+
"required_keys": [
|
| 1194 |
+
"data",
|
| 1195 |
+
"valid"
|
| 1196 |
+
],
|
| 1197 |
+
"additional_keys": false,
|
| 1198 |
+
"data_type": "CPU torch.Tensor",
|
| 1199 |
+
"valid_type": "CPU torch.Tensor",
|
| 1200 |
+
"valid_dtype": "bool"
|
| 1201 |
+
},
|
| 1202 |
+
"metadata_location": "metainfo.json; do not duplicate strings, paths or custom objects inside bundles",
|
| 1203 |
+
"missing_entry": "omit entire entry; never fabricate absent modalities",
|
| 1204 |
+
"load": {
|
| 1205 |
+
"map_location": "cpu",
|
| 1206 |
+
"weights_only": true
|
| 1207 |
+
},
|
| 1208 |
+
"valid_shape_rule": "Use the specific component or attribute valid_shape; do not infer broadcasting or share validity across independent fields.",
|
| 1209 |
+
"validation": [
|
| 1210 |
+
"registered layout and key resolution",
|
| 1211 |
+
"CPU tensors only",
|
| 1212 |
+
"schema dtype and shape",
|
| 1213 |
+
"independent bool validity",
|
| 1214 |
+
"frame alignment unchanged",
|
| 1215 |
+
"invalid floating positions NaN",
|
| 1216 |
+
"pure migration exact data bytes and validity equality"
|
| 1217 |
+
],
|
| 1218 |
+
"not_applicable_to": [
|
| 1219 |
+
"media payloads",
|
| 1220 |
+
"media standalone validity tensors",
|
| 1221 |
+
"JSONL standalone validity tensors"
|
| 1222 |
+
]
|
| 1223 |
+
}
|
| 1224 |
+
},
|
| 1225 |
+
"video_metadata": {
|
| 1226 |
+
"required": [
|
| 1227 |
+
"profile",
|
| 1228 |
+
"codec",
|
| 1229 |
+
"pixel_format",
|
| 1230 |
+
"encoded_size",
|
| 1231 |
+
"decoder",
|
| 1232 |
+
"encoder_parameters",
|
| 1233 |
+
"source_lossy"
|
| 1234 |
+
],
|
| 1235 |
+
"source_lossy_values": [
|
| 1236 |
+
true,
|
| 1237 |
+
false,
|
| 1238 |
+
"unknown"
|
| 1239 |
+
],
|
| 1240 |
+
"timebase_role": "index_only",
|
| 1241 |
+
"lossless_reference": "source compressed packets or fixed-decoder source pixels; depth uses normalized standard float32 bits",
|
| 1242 |
+
"selection": "choose smaller complete candidate only after exact roundtrip validation"
|
| 1243 |
+
},
|
| 1244 |
+
"tensor_storage_revision": "tensor-bundle-2026-10-09",
|
| 1245 |
+
"release_layout": {
|
| 1246 |
+
"directory": "shared-v1.1",
|
| 1247 |
+
"release_id": "shared-v1.1",
|
| 1248 |
+
"migration": "Upgrade each dataset in place under shared-v1.0 during maintenance, validate completely, then rename to shared-v1.1; do not retain duplicate published trees. See MIGRATION.md."
|
| 1249 |
+
},
|
| 1250 |
+
"tensor_attributes": {
|
| 1251 |
+
"visibility": {
|
| 1252 |
+
"storage_profile": "pt/tensor_bundle/v1",
|
| 1253 |
+
"allowed_dtypes": [
|
| 1254 |
+
"bool",
|
| 1255 |
+
"float32"
|
| 1256 |
+
],
|
| 1257 |
+
"visibility_types": [
|
| 1258 |
+
"boolean",
|
| 1259 |
+
"ratio"
|
| 1260 |
+
],
|
| 1261 |
+
"ratio_range": [
|
| 1262 |
+
0,
|
| 1263 |
+
1
|
| 1264 |
+
],
|
| 1265 |
+
"scopes": {
|
| 1266 |
+
"whole_hand": {
|
| 1267 |
+
"shape": [
|
| 1268 |
+
"T",
|
| 1269 |
+
2
|
| 1270 |
+
],
|
| 1271 |
+
"valid_shape": [
|
| 1272 |
+
"T",
|
| 1273 |
+
2
|
| 1274 |
+
]
|
| 1275 |
+
},
|
| 1276 |
+
"hand_keypoint": {
|
| 1277 |
+
"shape": [
|
| 1278 |
+
"T",
|
| 1279 |
+
2,
|
| 1280 |
+
"K"
|
| 1281 |
+
],
|
| 1282 |
+
"valid_shape": [
|
| 1283 |
+
"T",
|
| 1284 |
+
2,
|
| 1285 |
+
"K"
|
| 1286 |
+
]
|
| 1287 |
+
},
|
| 1288 |
+
"object": {
|
| 1289 |
+
"shape": [
|
| 1290 |
+
"T"
|
| 1291 |
+
],
|
| 1292 |
+
"valid_shape": [
|
| 1293 |
+
"T"
|
| 1294 |
+
]
|
| 1295 |
+
}
|
| 1296 |
+
},
|
| 1297 |
+
"required_metadata": [
|
| 1298 |
+
"data_ref",
|
| 1299 |
+
"data_key",
|
| 1300 |
+
"axes",
|
| 1301 |
+
"dtype",
|
| 1302 |
+
"visibility_type",
|
| 1303 |
+
"meaning",
|
| 1304 |
+
"valid_ref",
|
| 1305 |
+
"valid_key",
|
| 1306 |
+
"valid_axes",
|
| 1307 |
+
"storage",
|
| 1308 |
+
"valid_storage",
|
| 1309 |
+
"provenance",
|
| 1310 |
+
"source_locator"
|
| 1311 |
+
],
|
| 1312 |
+
"valid_dtype": "bool",
|
| 1313 |
+
"unknown": "valid=false; ratio data NaN; boolean data is not interpretable without valid",
|
| 1314 |
+
"all_known": "explicit all-true bool tensor; do not infer from pose validity",
|
| 1315 |
+
"note": "No source visibility means omit. Expand explicitly declared all-known scalar validity during migration without changing semantics."
|
| 1316 |
+
}
|
| 1317 |
+
},
|
| 1318 |
+
"tensor_bundles": {
|
| 1319 |
+
"camera": {
|
| 1320 |
+
"path": "camera/camera.pt",
|
| 1321 |
+
"entries": {
|
| 1322 |
+
"intrinsic": {
|
| 1323 |
+
"schema_ids": [
|
| 1324 |
+
"camera/pinhole/v1",
|
| 1325 |
+
"camera/rational8/v1",
|
| 1326 |
+
"camera/opencv_fisheye4/v1",
|
| 1327 |
+
"camera/fisheye624/v1"
|
| 1328 |
+
]
|
| 1329 |
+
},
|
| 1330 |
+
"extrinsic": {
|
| 1331 |
+
"schema_ids": [
|
| 1332 |
+
"transform/se3/v1"
|
| 1333 |
+
]
|
| 1334 |
+
},
|
| 1335 |
+
"distortion": {
|
| 1336 |
+
"schema_ids": [
|
| 1337 |
+
"camera/distortion8/v1",
|
| 1338 |
+
"camera/fisheye4_distortion/v1"
|
| 1339 |
+
]
|
| 1340 |
+
}
|
| 1341 |
+
}
|
| 1342 |
+
},
|
| 1343 |
+
"mano": {
|
| 1344 |
+
"path": "annotation/mano/mano.pt",
|
| 1345 |
+
"entries": {
|
| 1346 |
+
"motion": {
|
| 1347 |
+
"schema_ids": [
|
| 1348 |
+
"mano/axis_angle61/v1"
|
| 1349 |
+
]
|
| 1350 |
+
},
|
| 1351 |
+
"visibility": {
|
| 1352 |
+
"attribute_id": "visibility",
|
| 1353 |
+
"scope": "whole_hand"
|
| 1354 |
+
}
|
| 1355 |
+
}
|
| 1356 |
+
},
|
| 1357 |
+
"keypoints": {
|
| 1358 |
+
"path": "annotation/keypoints/keypoints.pt",
|
| 1359 |
+
"entries": {
|
| 1360 |
+
"uv": {
|
| 1361 |
+
"schema_ids": [
|
| 1362 |
+
"keypoints/uv/v1"
|
| 1363 |
+
]
|
| 1364 |
+
},
|
| 1365 |
+
"xyz": {
|
| 1366 |
+
"schema_ids": [
|
| 1367 |
+
"keypoints/xyz/v1"
|
| 1368 |
+
]
|
| 1369 |
+
},
|
| 1370 |
+
"visibility": {
|
| 1371 |
+
"attribute_id": "visibility",
|
| 1372 |
+
"scope": "hand_keypoint"
|
| 1373 |
+
},
|
| 1374 |
+
"whole_hand_visibility": {
|
| 1375 |
+
"attribute_id": "visibility",
|
| 1376 |
+
"scope": "whole_hand"
|
| 1377 |
+
}
|
| 1378 |
+
}
|
| 1379 |
+
},
|
| 1380 |
+
"object": {
|
| 1381 |
+
"path": "annotation/object/<object_id>/object.pt",
|
| 1382 |
+
"entries": {
|
| 1383 |
+
"pose": {
|
| 1384 |
+
"schema_ids": [
|
| 1385 |
+
"object/rigid/v1"
|
| 1386 |
+
]
|
| 1387 |
+
},
|
| 1388 |
+
"visibility": {
|
| 1389 |
+
"attribute_id": "visibility",
|
| 1390 |
+
"scope": "object"
|
| 1391 |
+
},
|
| 1392 |
+
"dimensions": {
|
| 1393 |
+
"schema_ids": [
|
| 1394 |
+
"object/dimensions/v1"
|
| 1395 |
+
]
|
| 1396 |
+
},
|
| 1397 |
+
"joint_state": {
|
| 1398 |
+
"schema_ids": [
|
| 1399 |
+
"object/joint_state/v1"
|
| 1400 |
+
]
|
| 1401 |
+
},
|
| 1402 |
+
"keypoints/xyz": {
|
| 1403 |
+
"schema_ids": [
|
| 1404 |
+
"object_keypoints/camera/v1"
|
| 1405 |
+
]
|
| 1406 |
+
},
|
| 1407 |
+
"keypoints/template_xyz": {
|
| 1408 |
+
"schema_ids": [
|
| 1409 |
+
"object_keypoints/template/v1"
|
| 1410 |
+
]
|
| 1411 |
+
},
|
| 1412 |
+
"parts/<part_id>/pose": {
|
| 1413 |
+
"schema_ids": [
|
| 1414 |
+
"transform/se3/v1"
|
| 1415 |
+
],
|
| 1416 |
+
"convention": "T_camera_from_part"
|
| 1417 |
+
},
|
| 1418 |
+
"parts/<part_id>/dimensions": {
|
| 1419 |
+
"schema_ids": [
|
| 1420 |
+
"object/dimensions/v1"
|
| 1421 |
+
]
|
| 1422 |
+
},
|
| 1423 |
+
"parts/<part_id>/keypoints/xyz": {
|
| 1424 |
+
"schema_ids": [
|
| 1425 |
+
"object_keypoints/camera/v1"
|
| 1426 |
+
]
|
| 1427 |
+
},
|
| 1428 |
+
"parts/<part_id>/keypoints/template_xyz": {
|
| 1429 |
+
"schema_ids": [
|
| 1430 |
+
"object_keypoints/template/v1"
|
| 1431 |
+
],
|
| 1432 |
+
"coordinate_frame": "part"
|
| 1433 |
+
},
|
| 1434 |
+
"meshes/<mesh_id>/vertex_part_ids": {
|
| 1435 |
+
"schema_ids": [
|
| 1436 |
+
"object/vertex_part_ids/v1"
|
| 1437 |
+
]
|
| 1438 |
+
}
|
| 1439 |
+
}
|
| 1440 |
+
},
|
| 1441 |
+
"contact_pair": {
|
| 1442 |
+
"path": "annotation/contact/<subject_id>__<object_id>/contact.pt",
|
| 1443 |
+
"entries": {
|
| 1444 |
+
"vertex_region": {
|
| 1445 |
+
"schema_ids": [
|
| 1446 |
+
"contact/vertex_region/v1"
|
| 1447 |
+
]
|
| 1448 |
+
},
|
| 1449 |
+
"vertex_distance": {
|
| 1450 |
+
"schema_ids": [
|
| 1451 |
+
"contact/vertex_distance/v1"
|
| 1452 |
+
]
|
| 1453 |
+
}
|
| 1454 |
+
}
|
| 1455 |
+
}
|
| 1456 |
+
},
|
| 1457 |
+
"bundle_layout_rules": {
|
| 1458 |
+
"entry_path_syntax": "Slash-separated dictionary keys in this registry only; serialize references as string arrays. Angle-bracket placeholders resolve to registered IDs, not literal keys.",
|
| 1459 |
+
"entry_leaves": [
|
| 1460 |
+
"data",
|
| 1461 |
+
"valid"
|
| 1462 |
+
],
|
| 1463 |
+
"additional_entries": false,
|
| 1464 |
+
"all_entries_optional": true,
|
| 1465 |
+
"omit_empty_bundles": true,
|
| 1466 |
+
"identifiers": "object/part/mesh and contact entity IDs must resolve in metadata; reject empty, dot, dot-dot or slash-containing IDs",
|
| 1467 |
+
"per_view": true,
|
| 1468 |
+
"no_cross_object_or_camera_merge": true,
|
| 1469 |
+
"numeric_field_valid_ref_equals_data_ref": true,
|
| 1470 |
+
"attributes_must_be_registered": true
|
| 1471 |
+
},
|
| 1472 |
+
"reference_rules": {
|
| 1473 |
+
"file_paths": {
|
| 1474 |
+
"base": "current camera view root",
|
| 1475 |
+
"format": "relative POSIX",
|
| 1476 |
+
"reject": [
|
| 1477 |
+
"absolute paths",
|
| 1478 |
+
"parent traversal",
|
| 1479 |
+
"external URLs",
|
| 1480 |
+
"unresolved placeholders"
|
| 1481 |
+
]
|
| 1482 |
+
},
|
| 1483 |
+
"dictionary_keys": {
|
| 1484 |
+
"type": "array",
|
| 1485 |
+
"item_type": "nonempty_string",
|
| 1486 |
+
"min_items": 1,
|
| 1487 |
+
"traversal": "literal nested dictionary lookup; never eval; no automatic flattening",
|
| 1488 |
+
"data_terminal": "data",
|
| 1489 |
+
"valid_terminal": "valid",
|
| 1490 |
+
"target_type": "CPU torch.Tensor"
|
| 1491 |
+
},
|
| 1492 |
+
"bundle_component": {
|
| 1493 |
+
"required": [
|
| 1494 |
+
"data_ref",
|
| 1495 |
+
"data_key",
|
| 1496 |
+
"valid_ref",
|
| 1497 |
+
"valid_key",
|
| 1498 |
+
"storage",
|
| 1499 |
+
"valid_storage"
|
| 1500 |
+
],
|
| 1501 |
+
"same_file": true,
|
| 1502 |
+
"same_entry_prefix": true,
|
| 1503 |
+
"storage_profile": "pt/tensor_bundle/v1",
|
| 1504 |
+
"valid_storage_profile": "pt/tensor_bundle/v1"
|
| 1505 |
+
},
|
| 1506 |
+
"media_jsonl": {
|
| 1507 |
+
"forbidden": [
|
| 1508 |
+
"data_key",
|
| 1509 |
+
"valid_key"
|
| 1510 |
+
],
|
| 1511 |
+
"preserve_original_valid_ref": true,
|
| 1512 |
+
"standalone_valid_pt_root": "CPU bool torch.Tensor; not dict",
|
| 1513 |
+
"do_not_label_standalone_valid_as_bundle": true
|
| 1514 |
+
},
|
| 1515 |
+
"camera_distortion": {
|
| 1516 |
+
"models": {
|
| 1517 |
+
"rational8": "camera/distortion8/v1",
|
| 1518 |
+
"opencv_fisheye4": "camera/fisheye4_distortion/v1"
|
| 1519 |
+
},
|
| 1520 |
+
"required": [
|
| 1521 |
+
"distortion_ref",
|
| 1522 |
+
"distortion_key",
|
| 1523 |
+
"distortion_valid_ref",
|
| 1524 |
+
"distortion_valid_key"
|
| 1525 |
+
],
|
| 1526 |
+
"distortion_ref": "camera/camera.pt",
|
| 1527 |
+
"distortion_key": [
|
| 1528 |
+
"distortion",
|
| 1529 |
+
"data"
|
| 1530 |
+
],
|
| 1531 |
+
"distortion_valid_ref": "camera/camera.pt",
|
| 1532 |
+
"distortion_valid_key": [
|
| 1533 |
+
"distortion",
|
| 1534 |
+
"valid"
|
| 1535 |
+
],
|
| 1536 |
+
"valid_equals_intrinsic_valid": true,
|
| 1537 |
+
"models_without_separate_distortion": [
|
| 1538 |
+
"pinhole",
|
| 1539 |
+
"fisheye624"
|
| 1540 |
+
]
|
| 1541 |
+
},
|
| 1542 |
+
"reader_cache": "Cache bundle by resolved file path; loading different fields must not repeatedly deserialize the file."
|
| 1543 |
+
},
|
| 1544 |
+
"standalone_validity": {
|
| 1545 |
+
"rgb": {
|
| 1546 |
+
"data_ref": "observation/rgb.mkv",
|
| 1547 |
+
"valid_ref": "observation/rgb_valid.pt",
|
| 1548 |
+
"dtype": "bool",
|
| 1549 |
+
"shape": [
|
| 1550 |
+
"T"
|
| 1551 |
+
],
|
| 1552 |
+
"container": "pt",
|
| 1553 |
+
"root_type": "CPU Tensor"
|
| 1554 |
+
},
|
| 1555 |
+
"segment": {
|
| 1556 |
+
"data_refs": [
|
| 1557 |
+
"annotation/segment/mask.mkv",
|
| 1558 |
+
"annotation/segment/polygons.jsonl"
|
| 1559 |
+
],
|
| 1560 |
+
"valid_ref": "preserve source release reference; normally annotation/segment/mask_valid.pt",
|
| 1561 |
+
"dtype": "bool",
|
| 1562 |
+
"shape": [
|
| 1563 |
+
"T"
|
| 1564 |
+
],
|
| 1565 |
+
"container": "pt",
|
| 1566 |
+
"root_type": "CPU Tensor"
|
| 1567 |
+
},
|
| 1568 |
+
"relations": {
|
| 1569 |
+
"data_ref": "annotation/contact/relations.jsonl",
|
| 1570 |
+
"valid_ref": "annotation/contact/relations_valid.pt",
|
| 1571 |
+
"dtype": "bool",
|
| 1572 |
+
"shape": [
|
| 1573 |
+
"T"
|
| 1574 |
+
],
|
| 1575 |
+
"container": "pt",
|
| 1576 |
+
"root_type": "CPU Tensor"
|
| 1577 |
+
},
|
| 1578 |
+
"depth": {
|
| 1579 |
+
"data_ref": "observation/depth.mkv",
|
| 1580 |
+
"valid_ref": "observation/depth_valid.mkv",
|
| 1581 |
+
"dtype": "bool",
|
| 1582 |
+
"shape": [
|
| 1583 |
+
"T",
|
| 1584 |
+
"H",
|
| 1585 |
+
"W"
|
| 1586 |
+
],
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""H2O v1.1 bundle reading and registry validation; no media re-encoding."""
|
| 2 |
+
import hashlib
|
| 3 |
+
import json
|
| 4 |
+
from pathlib import Path, PurePosixPath
|
| 5 |
+
|
| 6 |
+
import torch
|
| 7 |
+
|
| 8 |
+
PROFILE = 'pt/tensor_bundle/v1'
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def sha256(path):
|
| 12 |
+
with Path(path).open('rb') as stream:
|
| 13 |
+
return hashlib.file_digest(stream, 'sha256').hexdigest()
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def resolve(root, ref):
|
| 17 |
+
if not isinstance(ref, str) or not ref or '\\' in ref:
|
| 18 |
+
raise ValueError(f'invalid file reference: {ref!r}')
|
| 19 |
+
path = PurePosixPath(ref)
|
| 20 |
+
if path.is_absolute() or '..' in path.parts or ':' in ref:
|
| 21 |
+
raise ValueError(f'escaping file reference: {ref}')
|
| 22 |
+
root = Path(root).resolve()
|
| 23 |
+
result = root / path
|
| 24 |
+
if not result.resolve().is_relative_to(root) or not result.is_file() or result.is_symlink():
|
| 25 |
+
raise ValueError(f'missing/escaping file reference: {ref}')
|
| 26 |
+
return result
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def layout(name, component):
|
| 30 |
+
"""Fail closed on fields outside the audited H2O v1.0 release."""
|
| 31 |
+
fixed = {
|
| 32 |
+
'intrinsic': ('camera/pinhole/v1', 'camera/camera.pt', ['intrinsic']),
|
| 33 |
+
'extrinsic': ('transform/se3/v1', 'camera/camera.pt', ['extrinsic']),
|
| 34 |
+
'mano': ('mano/axis_angle61/v1', 'annotation/mano/mano.pt', ['motion']),
|
| 35 |
+
'keypoints_xyz': ('keypoints/xyz/v1', 'annotation/keypoints/keypoints.pt', ['xyz']),
|
| 36 |
+
}
|
| 37 |
+
expected = fixed.get(name)
|
| 38 |
+
for prefix, schema_id, keys in [('pose_', 'object/rigid/v1', ['pose']),
|
| 39 |
+
('points_', 'object_keypoints/camera/v1', ['keypoints', 'xyz'])]:
|
| 40 |
+
if name.startswith(prefix):
|
| 41 |
+
oid = name.removeprefix(prefix)
|
| 42 |
+
if oid not in {'book', 'espresso', 'lotion', 'spray', 'milk', 'cocoa', 'chips', 'cappuccino'}:
|
| 43 |
+
raise ValueError(f'unknown H2O object identity: {oid}')
|
| 44 |
+
expected = (schema_id, f'annotation/object/{oid}/object.pt', keys)
|
| 45 |
+
if expected is None or component['schema_id'] != expected[0]:
|
| 46 |
+
raise ValueError(f'unsupported H2O numeric component: {name}')
|
| 47 |
+
if component.get('attributes'):
|
| 48 |
+
raise ValueError(f'{name}: new numerical attributes need explicit migration support')
|
| 49 |
+
return expected[1:]
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
class Reader:
|
| 53 |
+
def __init__(self, view):
|
| 54 |
+
self.view = Path(view)
|
| 55 |
+
self.cache = {}
|
| 56 |
+
|
| 57 |
+
def field(self, component, kind='data'):
|
| 58 |
+
path = resolve(self.view, component[kind + '_ref'])
|
| 59 |
+
if path not in self.cache:
|
| 60 |
+
self.cache[path] = torch.load(path, map_location='cpu', weights_only=True)
|
| 61 |
+
value = self.cache[path]
|
| 62 |
+
keys = component.get(kind + '_key')
|
| 63 |
+
if keys is not None:
|
| 64 |
+
if not isinstance(keys, list) or not keys or any(not isinstance(k, str) or not k for k in keys):
|
| 65 |
+
raise ValueError('dictionary keys must be a nonempty list of nonempty strings')
|
| 66 |
+
for key in keys:
|
| 67 |
+
if type(value) is not dict or key not in value:
|
| 68 |
+
raise ValueError(f'missing dictionary key: {keys}')
|
| 69 |
+
value = value[key]
|
| 70 |
+
if not isinstance(value, torch.Tensor) or value.device.type != 'cpu':
|
| 71 |
+
raise ValueError('reference must resolve to a CPU Tensor')
|
| 72 |
+
return value
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def exact(left, right):
|
| 76 |
+
if left.dtype != right.dtype or left.shape != right.shape:
|
| 77 |
+
raise ValueError('tensor dtype/shape changed')
|
| 78 |
+
a = left.detach().contiguous().reshape(-1).view(torch.uint8)
|
| 79 |
+
b = right.detach().contiguous().reshape(-1).view(torch.uint8)
|
| 80 |
+
if not torch.equal(a, b):
|
| 81 |
+
raise ValueError('tensor bytes changed (including NaN payload or signed zero)')
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
def exact_metadata(old, new):
|
| 86 |
+
allowed = {'data_ref', 'valid_ref', 'data_key', 'valid_key', 'storage', 'valid_storage'}
|
| 87 |
+
expected = json.loads(json.dumps(new))
|
| 88 |
+
expected.update(schema_version=old['schema_version'], release_id=old['release_id'])
|
| 89 |
+
for name, component in old['components'].items():
|
| 90 |
+
target = new['components'][name]
|
| 91 |
+
if component.get('available') and component['data_ref'].endswith('.pt'):
|
| 92 |
+
if ({k:v for k,v in component.items() if k not in allowed} !=
|
| 93 |
+
{k:v for k,v in target.items() if k not in allowed}):
|
| 94 |
+
raise ValueError(f'{name}: numerical semantics metadata changed')
|
| 95 |
+
elif component != target:
|
| 96 |
+
raise ValueError(f'{name}: nonnumerical component metadata changed')
|
| 97 |
+
expected['components'][name] = component
|
| 98 |
+
if expected != old:
|
| 99 |
+
raise ValueError('view semantics metadata changed')
|
| 100 |
+
|
| 101 |
+
def check_shape(value, shape, n):
|
| 102 |
+
if value.ndim != len(shape) or any(
|
| 103 |
+
(wanted == 'T' and actual != n) or (isinstance(wanted, int) and actual != wanted)
|
| 104 |
+
for actual, wanted in zip(value.shape, shape, strict=True)
|
| 105 |
+
):
|
| 106 |
+
raise ValueError(f'tensor shape {tuple(value.shape)} differs from schema {shape}')
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
def validate_view(view, schema_path):
|
| 110 |
+
view = Path(view)
|
| 111 |
+
meta = json.loads((view / 'metainfo.json').read_text())
|
| 112 |
+
schema = json.loads(Path(schema_path).read_text())
|
| 113 |
+
if schema['schema_version'] != 'hand-warehouse/1.1' or meta['schema_version'] != schema['schema_version']:
|
| 114 |
+
raise ValueError('v1.1 schema required')
|
| 115 |
+
if any(k not in meta for k in schema['view_metadata']['required_fields']):
|
| 116 |
+
raise ValueError('required view metadata missing')
|
| 117 |
+
if (meta['dataset_id'] != 'H2O' or meta['release_id'] != 'shared-v1.1'
|
| 118 |
+
or meta['camera_id'] not in [f'cam{i}' for i in range(5)]
|
| 119 |
+
or meta['view_type'] != ('ego' if meta['camera_id'] == 'cam4' else 'exo')):
|
| 120 |
+
raise ValueError('H2O release/camera/view_type mismatch')
|
| 121 |
+
if meta['hand_slots'] != ['left', 'right'] or type(meta['num_frames']) is not int or meta['num_frames'] <= 0:
|
| 122 |
+
raise ValueError('hand slots/timeline mismatch')
|
| 123 |
+
n = meta['num_frames']
|
| 124 |
+
rows = [json.loads(line) for line in resolve(view, meta['sampling']['frames_ref']).read_text().splitlines()]
|
| 125 |
+
if len(rows) != n or [r['frame_index'] for r in rows] != list(range(n)):
|
| 126 |
+
raise ValueError('frame mapping incomplete or reordered')
|
| 127 |
+
reader, entries, report = Reader(view), {}, {}
|
| 128 |
+
for name, c in meta['components'].items():
|
| 129 |
+
if not c.get('available'):
|
| 130 |
+
if not c.get('reason'):
|
| 131 |
+
raise ValueError(f'{name}: unavailable component needs a reason')
|
| 132 |
+
continue
|
| 133 |
+
definition = schema['components'][c['schema_id']]
|
| 134 |
+
if c.get('attributes'):
|
| 135 |
+
raise ValueError(f'{name}: unaudited attributes are not supported')
|
| 136 |
+
for required in ['axes', 'provenance', 'source_locator', *definition.get('required_metadata', [])]:
|
| 137 |
+
if required not in c:
|
| 138 |
+
raise ValueError(f'{name}: missing {required}')
|
| 139 |
+
resolve(view, c['data_ref'])
|
| 140 |
+
if c.get('valid_ref'):
|
| 141 |
+
resolve(view, c['valid_ref'])
|
| 142 |
+
for profile_field, allowed in [('storage', 'allowed_storage_profiles'), ('valid_storage', 'allowed_valid_storage_profiles')]:
|
| 143 |
+
if allowed in definition and c.get(profile_field, {}).get('profile') not in definition[allowed]:
|
| 144 |
+
raise ValueError(f'{name}: unregistered {profile_field} profile')
|
| 145 |
+
if definition['storage'] == 'pt':
|
| 146 |
+
ref, key = layout(name, c)
|
| 147 |
+
if (c['data_ref'] != ref or c['valid_ref'] != ref or c['data_key'] != key + ['data']
|
| 148 |
+
or c['valid_key'] != key + ['valid']):
|
| 149 |
+
raise ValueError(f'{name}: noncanonical bundle reference')
|
| 150 |
+
entries.setdefault(ref, set()).add(tuple(key))
|
| 151 |
+
data, valid = reader.field(c), reader.field(c, 'valid')
|
| 152 |
+
check_shape(data, definition['shape'], n)
|
| 153 |
+
check_shape(valid, definition['valid_shape'], n)
|
| 154 |
+
if 'K' in definition['shape'] and data.shape[definition['shape'].index('K')] != 21:
|
| 155 |
+
raise ValueError(f'{name}: H2O keypoint count must remain 21')
|
| 156 |
+
if len(c['axes']) != data.ndim or c.get('valid_axes') != c['axes'][:valid.ndim]:
|
| 157 |
+
raise ValueError(f'{name}: axis declaration mismatch')
|
| 158 |
+
if c['data_ref'].startswith('annotation/') and not c.get('valid_policy', {}).get('source_rule'):
|
| 159 |
+
raise ValueError(f'{name}: source validity policy missing')
|
| 160 |
+
if data.dtype != getattr(torch, definition['dtype']) or valid.dtype != torch.bool:
|
| 161 |
+
raise ValueError(f'{name}: incorrect tensor dtype')
|
| 162 |
+
if data.shape[:valid.ndim] != valid.shape or not torch.isfinite(data[valid]).all() or not torch.isnan(data[~valid]).all():
|
| 163 |
+
raise ValueError(f'{name}: invalid finite/NaN/valid semantics')
|
| 164 |
+
if name.startswith(('pose_', 'points_')):
|
| 165 |
+
oid = name.split('_', 1)[1]
|
| 166 |
+
identity = json.loads(resolve(view, f'annotation/object/{oid}/metainfo.json').read_text())
|
| 167 |
+
if identity['object_id'] != oid:
|
| 168 |
+
raise ValueError('unresolved object identity')
|
| 169 |
+
report[name] = {'shape': list(data.shape), 'dtype': str(data.dtype),
|
| 170 |
+
'valid_true': int(valid.sum()), 'valid_total': valid.numel()}
|
| 171 |
+
else:
|
| 172 |
+
if 'data_key' in c or 'valid_key' in c:
|
| 173 |
+
raise ValueError(f'{name}: media/JSONL must not use bundle keys')
|
| 174 |
+
if c.get('valid_ref', '').endswith('.pt'):
|
| 175 |
+
valid = reader.field(c, 'valid')
|
| 176 |
+
if valid.dtype != torch.bool or tuple(valid.shape) != (n,):
|
| 177 |
+
raise ValueError(f'{name}: standalone validity must remain bool [T]')
|
| 178 |
+
for ref, registered in entries.items():
|
| 179 |
+
bundle = reader.cache[resolve(view, ref)]
|
| 180 |
+
def visit(node, prefix=()):
|
| 181 |
+
if type(node) is not dict or not node:
|
| 182 |
+
raise ValueError('bundle must contain nonempty string-key dictionaries')
|
| 183 |
+
if set(node) == {'data', 'valid'}:
|
| 184 |
+
if prefix not in registered or any(not isinstance(v, torch.Tensor) or v.device.type != 'cpu' for v in node.values()):
|
| 185 |
+
raise ValueError('unregistered bundle field or non-CPU tensor')
|
| 186 |
+
return {prefix}
|
| 187 |
+
found = set()
|
| 188 |
+
for key, value in node.items():
|
| 189 |
+
if not isinstance(key, str) or not key:
|
| 190 |
+
raise ValueError('invalid bundle key')
|
| 191 |
+
found |= visit(value, prefix + (key,))
|
| 192 |
+
return found
|
| 193 |
+
if visit(bundle) != registered:
|
| 194 |
+
raise ValueError('registered bundle entries missing')
|
| 195 |
+
referenced_pt = {c[k] for c in meta['components'].values() if c.get('available')
|
| 196 |
+
for k in ('data_ref', 'valid_ref') if c.get(k, '').endswith('.pt')}
|
| 197 |
+
if {p.relative_to(view).as_posix() for p in view.rglob('*.pt')} != referenced_pt:
|
| 198 |
+
raise ValueError('orphan PT file or obsolete standalone numeric validity')
|
| 199 |
+
return {'num_frames': n, 'numeric_components': report, 'bundle_files': len(entries),
|
| 200 |
+
'scope': 'v1.1 registry, keys, shapes, validity and timeline; not a media pixel comparison'}
|
| 201 |
+
|
H2O/shared-v1.1/script/provenance/operations/publish_h2o_v1_1.py
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Publish only H2O via a verified private PR; never squash repository history."""
|
| 3 |
+
import argparse
|
| 4 |
+
from contextlib import contextmanager
|
| 5 |
+
from datetime import datetime, timezone
|
| 6 |
+
import fcntl
|
| 7 |
+
import hashlib
|
| 8 |
+
import json
|
| 9 |
+
import os
|
| 10 |
+
from pathlib import Path, PurePosixPath
|
| 11 |
+
import time
|
| 12 |
+
|
| 13 |
+
from huggingface_hub import HfApi, CommitOperationAdd, CommitOperationCopy, CommitOperationDelete, hf_hub_download
|
| 14 |
+
|
| 15 |
+
REPO = 'ParityLab/Hand-Datasets-Raw'
|
| 16 |
+
OLD, NEW = 'H2O/shared-v1.0', 'H2O/shared-v1.1'
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def sha(path):
|
| 20 |
+
with Path(path).open('rb') as f:
|
| 21 |
+
return hashlib.file_digest(f, 'sha256').hexdigest()
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def write_json(path, value):
|
| 25 |
+
tmp = path.with_suffix(path.suffix + '.tmp')
|
| 26 |
+
tmp.write_text(json.dumps(value, ensure_ascii=False, indent=2, allow_nan=False) + '\n')
|
| 27 |
+
with tmp.open('rb') as f: os.fsync(f.fileno())
|
| 28 |
+
os.replace(tmp, path)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def safe(root, ref):
|
| 32 |
+
p = PurePosixPath(ref)
|
| 33 |
+
if not ref or p.is_absolute() or '..' in p.parts or '\\' in ref or ':' in ref:
|
| 34 |
+
raise ValueError('unsafe release reference')
|
| 35 |
+
path = root / ref
|
| 36 |
+
if not path.is_file() or path.is_symlink() or not path.resolve().is_relative_to(root.resolve()):
|
| 37 |
+
raise ValueError('missing/escaping release file')
|
| 38 |
+
return path
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def strip_h2o_attributes(data):
|
| 42 |
+
prefixes = (b'H2O/shared-v1.0/', b'"H2O/shared-v1.0/', b'H2O/shared-v1.1/', b'"H2O/shared-v1.1/')
|
| 43 |
+
return b''.join(line for line in data.splitlines(keepends=True) if not line.startswith(prefixes))
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
def remote_files(api, revision, prefix):
|
| 47 |
+
return {r.path.removeprefix(prefix + '/'): r for r in
|
| 48 |
+
api.list_repo_tree(REPO, path_in_repo=prefix, recursive=True, revision=revision, repo_type='dataset')
|
| 49 |
+
if getattr(r, 'size', None) is not None}
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def matches(row, expected):
|
| 53 |
+
if row.size != expected['size']: return False
|
| 54 |
+
if row.lfs: return row.lfs.sha256 == expected['sha256']
|
| 55 |
+
return row.blob_id == expected.get('git_sha1')
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def trees(api, revision, prefix=None):
|
| 59 |
+
return {r.path: getattr(r, 'tree_id', None) or getattr(r, 'blob_id', None)
|
| 60 |
+
for r in api.list_repo_tree(REPO, path_in_repo=prefix, revision=revision, repo_type='dataset')}
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def outside_h2o(values):
|
| 64 |
+
return {k:v for k,v in values.items() if k not in ('H2O', '.gitattributes')}
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def source_rows(api, work, revision):
|
| 68 |
+
plan = json.loads((work / 'PLAN.json').read_text())
|
| 69 |
+
hashes = dict(plan['root_source_sha256'])
|
| 70 |
+
rows = {}
|
| 71 |
+
for seq in plan['sequences']:
|
| 72 |
+
inventory = json.loads((work / 'inventory' / (seq + '.json')).read_text())['files']
|
| 73 |
+
rows.update(inventory)
|
| 74 |
+
for cam in range(5):
|
| 75 |
+
record = json.loads((work / 'checkpoints' / seq / f'cam{cam}.json').read_text())
|
| 76 |
+
hashes.update({record['view'] + '/' + k:v for k,v in record['source_sha256'].items()})
|
| 77 |
+
for folder in ('doc', 'script'):
|
| 78 |
+
for ref,row in remote_files(api, revision, OLD + '/' + folder).items():
|
| 79 |
+
rows[folder + '/' + ref] = {'size':row.size,'oid':row.blob_id,
|
| 80 |
+
'lfs':{'oid':row.lfs.sha256} if row.lfs else None}
|
| 81 |
+
by_content = {}
|
| 82 |
+
for ref,row in sorted(rows.items()):
|
| 83 |
+
by_content.setdefault((hashes[ref], row['size']), (ref,row))
|
| 84 |
+
return by_content
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
def build_plan(root, work, api, manifest):
|
| 88 |
+
sources = source_rows(api, work, manifest['source_revision'])
|
| 89 |
+
files = {}
|
| 90 |
+
for ref,entry in sorted(manifest['files'].items()):
|
| 91 |
+
path = safe(root, ref)
|
| 92 |
+
if path.stat().st_size != entry['size']: raise ValueError(f'local size changed: {ref}')
|
| 93 |
+
source = sources.get((entry['sha256'],entry['size']))
|
| 94 |
+
item = dict(entry)
|
| 95 |
+
if source:
|
| 96 |
+
src,row = source
|
| 97 |
+
if row.get('lfs'):
|
| 98 |
+
item.update(kind='copy', source=OLD + '/' + src)
|
| 99 |
+
else:
|
| 100 |
+
item.update(kind='add', git_sha1=row['oid'])
|
| 101 |
+
else:
|
| 102 |
+
if path.suffix == '.mkv': raise ValueError('refuse to upload/re-encode an unmatched media file')
|
| 103 |
+
h = hashlib.sha1(f'blob {entry["size"]}\0'.encode())
|
| 104 |
+
with path.open('rb') as f:
|
| 105 |
+
while chunk := f.read(4*1024*1024): h.update(chunk)
|
| 106 |
+
item.update(kind='add', git_sha1=h.hexdigest())
|
| 107 |
+
files[ref] = item
|
| 108 |
+
return {'source_revision':manifest['source_revision'], 'raw_tree_oid':manifest['raw_tree_oid'],
|
| 109 |
+
'manifest_sha256':sha(work/'PUBLISH_MANIFEST.json'), 'files':files,
|
| 110 |
+
'copy_files':sum(e['kind']=='copy' for e in files.values()),
|
| 111 |
+
'local_upload_bytes':sum(e['size'] for e in files.values() if e['kind']=='add')}
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
def operations(root, plan, refs):
|
| 115 |
+
result = []
|
| 116 |
+
for ref in refs:
|
| 117 |
+
e = plan['files'][ref]
|
| 118 |
+
if e['kind']=='copy':
|
| 119 |
+
result.append(CommitOperationCopy(e['source'],NEW+'/'+ref,src_revision=plan['source_revision']))
|
| 120 |
+
else:
|
| 121 |
+
path = safe(root,ref)
|
| 122 |
+
if sha(path)!=e['sha256']: raise ValueError(f'local content changed: {ref}')
|
| 123 |
+
result.append(CommitOperationAdd(NEW+'/'+ref,path))
|
| 124 |
+
return result
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
def batches(refs, files):
|
| 128 |
+
batch, size = [],0
|
| 129 |
+
for ref in refs:
|
| 130 |
+
n = files[ref]['size'] if files[ref]['kind']=='add' else 0
|
| 131 |
+
if batch and (len(batch)>=100 or size+n>48*1024**2):
|
| 132 |
+
yield batch;batch=[];size=0
|
| 133 |
+
batch.append(ref);size+=n
|
| 134 |
+
if batch: yield batch
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
def verify_release(api, revision, plan):
|
| 138 |
+
actual = remote_files(api,revision,NEW)
|
| 139 |
+
if set(actual)!=set(plan['files']): raise ValueError('remote release file set mismatch')
|
| 140 |
+
for ref,e in plan['files'].items():
|
| 141 |
+
if not matches(actual[ref],e): raise ValueError(f'remote size/content mismatch: {ref}')
|
| 142 |
+
h2o=trees(api,revision,'H2O')
|
| 143 |
+
if OLD in h2o or h2o.get('H2O/raw')!=plan['raw_tree_oid']:
|
| 144 |
+
raise ValueError('old tree still present or raw tree changed')
|
| 145 |
+
return h2o[NEW]
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
def main():
|
| 149 |
+
p=argparse.ArgumentParser(description=__doc__)
|
| 150 |
+
p.add_argument('--root',type=Path,required=True)
|
| 151 |
+
p.add_argument('--work',type=Path,required=True)
|
| 152 |
+
args=p.parse_args();root=args.root.resolve();work=args.work.resolve()
|
| 153 |
+
if root.name!='shared-v1.1' or root.parent.name!='H2O' or not work.is_relative_to(root.parent/'tmp'):
|
| 154 |
+
p.error('H2O final root and dedicated existing work required')
|
| 155 |
+
manifest=json.loads((work/'PUBLISH_MANIFEST.json').read_text())
|
| 156 |
+
state=json.loads((work/'RUN.json').read_text())
|
| 157 |
+
if state['phase']!='local_finalized_not_uploaded' or state['completed_views']!=920:
|
| 158 |
+
p.error('completed local release and post-full approval required')
|
| 159 |
+
actual={q.relative_to(root).as_posix() for q in root.rglob('*') if q.is_file() and q.suffix!='.pyc' and '__pycache__' not in q.parts}
|
| 160 |
+
if actual!=set(manifest['files']): raise ValueError('local release file set drift')
|
| 161 |
+
api=HfApi();api.auth_check(REPO,repo_type='dataset',write=True)
|
| 162 |
+
log_path=work/'HF_PUBLICATION.json'
|
| 163 |
+
lock=(work/'HF_PUBLICATION.lock').open('a')
|
| 164 |
+
fcntl.flock(lock,fcntl.LOCK_EX|fcntl.LOCK_NB)
|
| 165 |
+
plan_path=work/'HF_PUBLICATION_PLAN.json'
|
| 166 |
+
if plan_path.exists():
|
| 167 |
+
plan=json.loads(plan_path.read_text())
|
| 168 |
+
if plan['manifest_sha256']!=sha(work/'PUBLISH_MANIFEST.json'): raise ValueError('publication manifest changed')
|
| 169 |
+
else:
|
| 170 |
+
plan=build_plan(root,work,api,manifest);write_json(plan_path,plan)
|
| 171 |
+
print('PUBLISH_PLAN',len(plan['files']),'files',plan['copy_files'],'server copies',plan['local_upload_bytes'],'upload bytes',flush=True)
|
| 172 |
+
run=json.loads(log_path.read_text()) if log_path.exists() else {'phase':'preparing','created_utc':datetime.now(timezone.utc).isoformat()}
|
| 173 |
+
try:
|
| 174 |
+
head=api.repo_info(REPO,repo_type='dataset').sha
|
| 175 |
+
live=trees(api,head,'H2O');fixed=trees(api,plan['source_revision'],'H2O')
|
| 176 |
+
if NEW in live:
|
| 177 |
+
final=verify_release(api,head,plan)
|
| 178 |
+
run.update(phase='published_verified',final_commit=head,target_tree_oid=final)
|
| 179 |
+
write_json(log_path,run);print('PUBLISHED_VERIFIED',head,flush=True);return
|
| 180 |
+
if live.get(OLD)!=fixed.get(OLD) or live.get('H2O/raw')!=plan['raw_tree_oid']:
|
| 181 |
+
raise ValueError('H2O source/raw changed; do not overwrite')
|
| 182 |
+
if 'pr' not in run:
|
| 183 |
+
attrs=Path(hf_hub_download(REPO,'.gitattributes',repo_type='dataset',revision=head)).read_bytes()
|
| 184 |
+
trimmed=work/'H2O_CLEAN_GITATTRIBUTES';trimmed.write_bytes(strip_h2o_attributes(attrs))
|
| 185 |
+
proof=['data/subject1_k2_6/cam0/observation/rgb.mkv','data/subject1_h1_0/cam0/observation/depth.mkv']
|
| 186 |
+
run.update(base_commit=head,base_root=trees(api,head),phase='creating_private_pr',proof_files=proof)
|
| 187 |
+
write_json(log_path,run)
|
| 188 |
+
commit=api.create_commit(REPO,repo_type='dataset',revision='main',parent_commit=head,create_pr=True,
|
| 189 |
+
operations=[CommitOperationDelete(OLD,is_folder=True),CommitOperationAdd('.gitattributes',trimmed)]+operations(root,plan,proof),
|
| 190 |
+
commit_message='Prepare H2O shared-v1.1 migration (private PR)',num_threads=4)
|
| 191 |
+
run.update(pr=int(commit.pr_url.rstrip('/').split('/')[-1]),revision=commit.pr_revision,head=commit.oid,phase='staging')
|
| 192 |
+
write_json(log_path,run)
|
| 193 |
+
print('PRIVATE_PR',run['pr'],run['revision'],flush=True)
|
| 194 |
+
branch_head=api.repo_info(REPO,repo_type='dataset',revision=run['revision']).sha
|
| 195 |
+
existing=remote_files(api,branch_head,NEW)
|
| 196 |
+
for ref,row in existing.items():
|
| 197 |
+
if ref not in plan['files'] or not matches(row,plan['files'][ref]): raise ValueError('private branch content drift')
|
| 198 |
+
missing=[ref for ref in plan['files'] if ref not in existing]
|
| 199 |
+
done=len(existing)
|
| 200 |
+
for batch in batches(missing,plan['files']):
|
| 201 |
+
commit=api.create_commit(REPO,repo_type='dataset',revision=run['revision'],parent_commit=branch_head,
|
| 202 |
+
operations=operations(root,plan,batch),commit_message=f'Stage H2O shared-v1.1 {done+len(batch)}/{len(plan["files"])}',num_threads=4)
|
| 203 |
+
branch_head=commit.oid;done+=len(batch)
|
| 204 |
+
run.update(head=branch_head,staged_files=done,phase='staging');write_json(log_path,run)
|
| 205 |
+
print('STAGED',done,'/',len(plan['files']),branch_head,flush=True)
|
| 206 |
+
tree_id=verify_release(api,branch_head,plan)
|
| 207 |
+
if outside_h2o(trees(api,branch_head))!=outside_h2o(run['base_root']): raise ValueError('private PR changes other datasets')
|
| 208 |
+
before=api.repo_info(REPO,repo_type='dataset').sha
|
| 209 |
+
current=trees(api,before,'H2O')
|
| 210 |
+
if current.get(OLD)!=fixed.get(OLD) or current.get('H2O/raw')!=plan['raw_tree_oid'] or NEW in current:
|
| 211 |
+
raise ValueError('H2O changed during staging; merge halted')
|
| 212 |
+
attrs_live=Path(hf_hub_download(REPO,'.gitattributes',repo_type='dataset',revision=before)).read_bytes()
|
| 213 |
+
attrs_branch=Path(hf_hub_download(REPO,'.gitattributes',repo_type='dataset',revision=branch_head)).read_bytes()
|
| 214 |
+
if strip_h2o_attributes(attrs_live)!=strip_h2o_attributes(attrs_branch):
|
| 215 |
+
raise ValueError('non-H2O LFS tracking changed; merge halted for review')
|
| 216 |
+
before_root=trees(api,before)
|
| 217 |
+
run.update(phase='verified_before_merge',verified_branch_commit=branch_head,premerge_head=before,target_tree_oid=tree_id)
|
| 218 |
+
write_json(log_path,run)
|
| 219 |
+
discussion=api.get_discussion_details(REPO,run['pr'],repo_type='dataset')
|
| 220 |
+
if discussion.status=='draft': api.change_discussion_status(REPO,run['pr'],'open',repo_type='dataset')
|
| 221 |
+
api.merge_pull_request(REPO,run['pr'],repo_type='dataset',comment='All H2O release paths, sizes and content digests verified. Raw unchanged. No repository history squash.')
|
| 222 |
+
final=api.repo_info(REPO,repo_type='dataset').sha
|
| 223 |
+
final_tree=verify_release(api,final,plan)
|
| 224 |
+
if outside_h2o(trees(api,final))!=outside_h2o(before_root): raise ValueError('other dataset roots changed across merge; investigate')
|
| 225 |
+
run.update(phase='published_verified',final_commit=final,target_tree_oid=final_tree,files=len(plan['files']),raw_unchanged=True)
|
| 226 |
+
write_json(log_path,run);print('PUBLISHED_VERIFIED',final,flush=True)
|
| 227 |
+
except Exception as exc:
|
| 228 |
+
run.update(failed_phase=run.get('phase'),phase='failed',error=str(exc))
|
| 229 |
+
write_json(log_path,run)
|
| 230 |
+
print('PUBLISH_FAILED_NO_HISTORY_SQUASH',repr(exc),flush=True)
|
| 231 |
+
raise
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
if __name__=='__main__':main()
|
H2O/shared-v1.1/script/v1_0_snapshot/doc/CONTRACT.md
ADDED
|
@@ -0,0 +1,457 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 手物数据仓库统一约定 v1.0
|
| 2 |
+
|
| 3 |
+
格式版本:`hand-warehouse/1.0`。存储约定:`lossless-video-2026-09-18`。
|
| 4 |
+
|
| 5 |
+
范围限于手物交互重建。按本任务纳入的源模态转换,不要求每个数据集填满所有组件。缺失模态、尚未下载、语义未核实分别报告,不能互相替代。
|
| 6 |
+
|
| 7 |
+
本文定义各字段的含义与使用规则,机器可读注册表见 [schema.json](schema.json)。两者互相补充;如有冲突,应先核实并统一定义。
|
| 8 |
+
|
| 9 |
+
## 1. 目录
|
| 10 |
+
|
| 11 |
+
```text
|
| 12 |
+
hand-datasets/
|
| 13 |
+
<dataset_name>/
|
| 14 |
+
raw/
|
| 15 |
+
doc/ # 官方说明、来源与校验记录
|
| 16 |
+
script/ # 官方下载脚本、必要包装脚本
|
| 17 |
+
data/ # 保留原始包,不原地解压或改写
|
| 18 |
+
<dataset_version>/
|
| 19 |
+
doc/ # 发布说明、schema、来源清单
|
| 20 |
+
script/ # 转换、校验脚本及运行配置
|
| 21 |
+
data/
|
| 22 |
+
<sequence_id>/
|
| 23 |
+
<camera_id>/
|
| 24 |
+
metainfo.json
|
| 25 |
+
observation/
|
| 26 |
+
rgb.mkv
|
| 27 |
+
rgb_valid.pt
|
| 28 |
+
depth.mkv # float32 深度的可逆视频编码
|
| 29 |
+
depth_valid.mkv # 逐像素 bool 的无损视频编码
|
| 30 |
+
camera/
|
| 31 |
+
frames.jsonl
|
| 32 |
+
intrinsic.pt
|
| 33 |
+
intrinsic_valid.pt
|
| 34 |
+
extrinsic.pt
|
| 35 |
+
extrinsic_valid.pt
|
| 36 |
+
annotation/
|
| 37 |
+
mano/
|
| 38 |
+
motion.pt
|
| 39 |
+
motion_valid.pt
|
| 40 |
+
visibility.pt
|
| 41 |
+
keypoints/
|
| 42 |
+
uv.pt
|
| 43 |
+
uv_valid.pt
|
| 44 |
+
xyz.pt
|
| 45 |
+
xyz_valid.pt
|
| 46 |
+
visibility.pt # 源数据有时提供
|
| 47 |
+
object/
|
| 48 |
+
<object_id>/
|
| 49 |
+
assets/ # 该物体的网格、材质、纹理及部件资产
|
| 50 |
+
<mesh_id>.obj
|
| 51 |
+
pose.pt
|
| 52 |
+
pose_valid.pt
|
| 53 |
+
visibility.pt
|
| 54 |
+
metainfo.json # 物体身份、类别、mesh、尺寸与部件引用
|
| 55 |
+
articulation.json
|
| 56 |
+
keypoints/
|
| 57 |
+
vertex_part_ids.pt
|
| 58 |
+
joint_state.pt
|
| 59 |
+
joint_state_valid.pt
|
| 60 |
+
parts/<part_id>/pose.pt
|
| 61 |
+
parts/<part_id>/pose_valid.pt
|
| 62 |
+
segment/
|
| 63 |
+
mask.mkv
|
| 64 |
+
mask_valid.pt
|
| 65 |
+
instances.jsonl
|
| 66 |
+
contact/
|
| 67 |
+
relations.jsonl
|
| 68 |
+
<subject_id>__<object_id>/ # 对应实体间的距离/接触区域
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
目录展示可能存在的组件,不要求填满。具体文件、字段和缺省规则分别见后续对应小节。原始包的解压发生在临时工作区,raw 内原始包保持不变。
|
| 72 |
+
|
| 73 |
+
## 2. 相机视图的 metainfo.json
|
| 74 |
+
|
| 75 |
+
### 2.1 顶层字段与发布信息
|
| 76 |
+
|
| 77 |
+
每个相机视图必须有 `metainfo.json`。以下字段除另行说明外均为必填:
|
| 78 |
+
|
| 79 |
+
| 字段 | 填写内容 |
|
| 80 |
+
|---|---|
|
| 81 |
+
| schema_version | 结构版本,本版为 `hand-warehouse/1.0` |
|
| 82 |
+
| dataset_id | 数据集的逻辑标识 |
|
| 83 |
+
| release_id | 本次数据发布版本,对应目录中的 dataset_version |
|
| 84 |
+
| sequence_id | 所属序列或独立图片样本的标识 |
|
| 85 |
+
| camera_id | 当前相机视图标识 |
|
| 86 |
+
| sample_type | `image` 或 `video`,规则见 2.2 |
|
| 87 |
+
| num_frames | 当前视图帧数 T,所有随帧组件按同一时间轴组织 |
|
| 88 |
+
| hand_slots | 固定为 `["left", "right"]`;解剖学左右的使用规则见 5.1 |
|
| 89 |
+
| sampling | 采样类型、源 FPS、帧索引引用及选择策略,见 2.2 |
|
| 90 |
+
| camera | 当前相机模型与图像尺寸,见 2.3 |
|
| 91 |
+
| components | 实际提供的组件及其文件、schema、有效性和来源,见 2.5 |
|
| 92 |
+
| split | `train/val/test/unknown`,划分协议见 2.4 |
|
| 93 |
+
| view_type | 可选,`ego/exo/unknown` |
|
| 94 |
+
|
| 95 |
+
`dataset_version` 是数据发布版本;`schema_version` 是结构版本,两者独立。原始包校验摘要、官方来源和转换配置应记录在发布清单中。解压发生在临时工作区,原始包保持不变。
|
| 96 |
+
|
| 97 |
+
### 2.2 图片、视频与 sampling
|
| 98 |
+
|
| 99 |
+
`sample_type=image`:允许单图 T=1、`sampling.type=single`,也允许将独立图片批量装入一个视频容器,T>1 时 `sampling.type=independent`、`source_fps=null`。分片大小按数据集选择;FreiHAND 默认每片最多 4096 张,训练与评估分开,尾片不补帧。该数量不是其他数据集的强制要求;同批分辨率、相机模型类型及划分协议一致。每行 frames 必须有稳定且唯一的 `sample_id`、原始文件定位;内参、手形状等仍逐帧保留,不能因打包而共享错误的标定或身份。`sequence_id` 在这里仅是批次标识,不代表真实序列;不得按相邻帧推断跟踪、同步或接触延续。源 camera_id、image_variant、split 等随样本变化时放在 frames 的对应字段中。真实采集时间未知则 timestamp_ns=null。合成背景变体不视为真实多相机。
|
| 100 |
+
|
| 101 |
+
`sample_type=video`:`sampling.type=dense/sparse`;`source_fps` 是真实采集 FPS,未知为 null。非连续取样必须保留源帧号和已知源时间,不可用采样后索引除以 FPS 冒充源时间。可另记采样策略与步长。
|
| 102 |
+
|
| 103 |
+
shared 可以仅存所选 RGB 帧对应的数据。OakInk2 图像/动捕不同采样率时用 annotation_matches 明确映射;不要求将未采样动捕点硬塞进 T。多视角身份和源同步关系要保留;选择了哪些帧/相机及原因写在 sampling 中。
|
| 104 |
+
|
| 105 |
+
`sampling.frames_ref` 指向 `camera/frames.jsonl`。帧号、逐帧时间、同步与标注匹配记录的结构见 4.1;MKV 封装时间的约定见 3.1。
|
| 106 |
+
|
| 107 |
+
### 2.3 camera 模型声明
|
| 108 |
+
|
| 109 |
+
`camera` 至少包含 `model`、`schema_id`、`image_size:[W,H]`。模型未知使用 `unknown` 和 `null`,不猜成针孔。实际内参、畸变及外参数组放在 `camera/`,各模型的固定结构见第 4 节。
|
| 110 |
+
|
| 111 |
+
### 2.4 split 与划分协议
|
| 112 |
+
|
| 113 |
+
保留上游划分,不将同一采集序列的相邻帧随意拆到不同集合。
|
| 114 |
+
|
| 115 |
+
有官方划分时必填 split_scheme 和 split_source_locator,split_scheme 区分如 Dex-YCB s0/s1、ARCTIC P1/P2 等选定协议;不知道时 split=unknown 并给理由,不凭空分配。每发布可选择一种协议;存在逐帧差异时 frames 中的 split 覆盖视图默认值,并登记其来源。
|
| 116 |
+
|
| 117 |
+
### 2.5 components 组件登记
|
| 118 |
+
|
| 119 |
+
组件表的键是本发布内唯一名称,例如 `rgb`、`depth`、`mano`、`keypoints_uv`。每个已提供组件声明以下信息;模态特有参数在第 3–5 节对应小节中定义。
|
| 120 |
+
|
| 121 |
+
| 字段 | 约定 |
|
| 122 |
+
|---|---|
|
| 123 |
+
| available | 本发布是否提供该组件;缺省也表示未提供 |
|
| 124 |
+
| schema_id | 已登记的具体存储与语义类型,不得临时创造未登记名称 |
|
| 125 |
+
| data_ref | 数据文件路径,相对当前相机视图根目录,使用 POSIX 路径 |
|
| 126 |
+
| axes | 数组各维度的含义 |
|
| 127 |
+
| valid_ref / valid_axes | 有效性文件及其维度;语义由所属组件规定 |
|
| 128 |
+
| storage / valid_storage | 视频数据/视频有效性的存储配置;包含已登记 profile、实际 codec、pixel_format、encoded_size,见 3.1;非视频组件按原数组规则 |
|
| 129 |
+
| provenance | source / format_conversion / derived,以及转换或生成方法 |
|
| 130 |
+
| source_locator | 原文件、压缩包成员和记录/帧的定位信息 |
|
| 131 |
+
|
| 132 |
+
不存在的组件允许缺省或写作 `{ "available": false, "reason": "..." }`,不用引用不存在的文件。静态网格可声明标量有效性;具体见 5.4。观测的 valid 见第 3 节,标注的 valid 与 visibility 区分见 5.1。
|
| 133 |
+
|
| 134 |
+
`provenance.kind` 使用 source/format_conversion/derived,`method` 说明转换或生成方法;发布清单补充脚本版本、参数、输入摘要。`source_locator` 定位到原始文件/压缩包成员和记录、帧号;允许引用有完整溯源清单的前一发布,但链条最终应能回到 raw。不得仅写一个无法定位记录的数据集名字。
|
| 135 |
+
|
| 136 |
+
`.pt` 仅保存 CPU Tensor,不保存 Python 自定义对象;浮点默认 float32,有效性为 bool,浮点无效位置填 NaN。所有随帧数组保留首维 T,单帧也不 squeeze;静态资产按其 schema 单独声明。单位、坐标及固定形状见各组件小节。
|
| 137 |
+
|
| 138 |
+
机器注册表 `schema.json` 中,`components` 固定解码后的数据类型、形状、单位和语义;`storage_profiles` 固定视频内的编码/还原方式。不得临时创造未登记的 schema_id 或 storage.profile。同一语义允许选择其登记的不同无损存储 profile。
|
| 139 |
+
|
| 140 |
+
## 3. observation 观测数据
|
| 141 |
+
|
| 142 |
+
### 3.1 rgb.mkv 与 rgb_valid.pt
|
| 143 |
+
|
| 144 |
+
RGB、深度和栅格 mask 在 shared 中统一使用 MKV 视频容器,不展开为逐帧图片或图像 tar。MANO、关键点、位姿等数值标注仍用数组;分割的重叠多边形仍用 JSONL,不为了视频化而有损栅格化。单图可为一帧视频,独立图批量封装规则见 2.2。
|
| 145 |
+
|
| 146 |
+
**无损指共享层不增加信息损失。** 源 JPEG/H.264 等本身可能已是有损编码,原样保留并不恢复已丢失信息;不得重新以有损 JPEG、H.264、H.265、AV1 参数编码。源视频/图片的色彩、位深、分辨率和几何关系不得被静默改变。RGB schema `rgb/uint8/v1` 的统一读取结果是 `[T,H,W,3] uint8`、RGB 通道,有效性仍为 `rgb_valid.pt [T] bool`。超出该 schema 的高位深或 HDR 源必须报告并扩展定义,不能降到 8 位冒充无损。
|
| 147 |
+
|
| 148 |
+
#### 3.1.1 允许的 RGB 存储 profile
|
| 149 |
+
|
| 150 |
+
| storage.profile | 编码方式 | 适用规则 |
|
| 151 |
+
|---|---|---|
|
| 152 |
+
| mkv/mjpeg_copy/v1 | 源 JPEG 压缩帧直接封装成 MJPEG/MKV | 不解码重编码;保持每张 JPEG 码流字节;普通 8 位 JPEG 且 MKV/解码器支持时使用 |
|
| 153 |
+
| mkv/source_copy/v1 | 已有视频的 RGB 对应码流直接封装为 MKV | 仅源编码能被 MKV 和选定解码器支持时使用,不伪造帧;需维持正确的呈现顺序与依赖帧 |
|
| 154 |
+
| mkv/h264_rgb_lossless/v1 | libx264rgb 的真正无损模式 | 必须 RGB 路径、CRF=0,并通过全帧 RGB 字节比较;不能替换成默认 libx264 YUV420 路径 |
|
| 155 |
+
| mkv/ffv1_rgb/v1 | FFV1 的 RGB 可逆编码路径 | 作为通用候选;解码回 RGB 后必须逐字节相同,不做色度降采样 |
|
| 156 |
+
|
| 157 |
+
优先尝试源码流直接封装;不能封装或需要选择稀疏帧时,比较 FFV1 与无损 RGB H.264。对完整待发布片段,只在通过无损验收的候选中选择文件较小者,不假设某个编码器总最小;编码时间和随机读取代价记入构建记录。中间候选不作为 shared 多份常驻。H.264 跨帧压缩允许较长 GOP,必须记录 GOP/关键帧间隔,随机取帧需从前一关键帧正确解码,不能把 seek 返回的近似帧当目标帧。
|
| 158 |
+
|
| 159 |
+
普通源视频可以保留它已有的有损码流,但不允许新增有损重编码。源是 VRS 等记录容器时,先查明图像流实际编码:已有兼容 JPEG/视频包可直接提取封装,否则解码后使用真正无损编码;不把整个 VRS 改后缀当 MKV。PNG 不要求直接塞进 MKV,可选上表两种无损重编码方式。
|
| 160 |
+
|
| 161 |
+
#### 3.1.2 视频配置与校验
|
| 162 |
+
|
| 163 |
+
每个视频组件在 metainfo 中登记 `storage`,至少包含:
|
| 164 |
+
|
| 165 |
+
| 字段 | 内容 |
|
| 166 |
+
|---|---|
|
| 167 |
+
| profile | 上述登记的存储 profile;语义仍由组件 schema_id 指定 |
|
| 168 |
+
| codec | 文件中实际 codec,例如 mjpeg、h264、ffv1;source_copy 必须写实际 codec |
|
| 169 |
+
| pixel_format | 实际编码像素格式;不得仅凭编码器参数猜测 |
|
| 170 |
+
| encoded_size | 视频物理像素尺寸 `[width,height]`;深度可能不同于逻辑尺寸,见 3.2 |
|
| 171 |
+
| decoder | 解码器名称、版本,以及颜色矩阵/范围/旋转处理等实际像素解释配置;未知的源色彩声明 unknown,不擅自称为 sRGB |
|
| 172 |
+
| encoder_parameters | 重编码时的编码器、版本、无损模式和 GOP 等参数;直接封装时记录 stream_copy |
|
| 173 |
+
| source_lossy | 源是否已有损:true / false / unknown;不是共享层再有损编码的许可 |
|
| 174 |
+
|
| 175 |
+
无损重新编码的 RGB 必须使用同一固定解码配置,比较**全部帧**的统一 RGB 字节、数量及顺序。MJPEG-copy 不重新编码,生产校验采用 `jpeg-packets-all-rgb-sample16/v1`:从 MKV 逐包取回,对全部源 JPEG 的 SHA256、数量、顺序和图像尺寸进行精确核对;每视图另用同一固定解码配置比较最多 16 帧的源与目标 RGB 字节(含首尾与四分位位置,其余由固定种子抽取)。记录策略、实际索引、种子与结果;不足 16 帧时全查。试点与最终完整序列随机抽查,对选中视图的全部帧复核解码 RGB。历史已做全帧像素检查的证明继续保留。
|
| 176 |
+
|
| 177 |
+
逐包一致与像素抽查的范围必须分别声明,不能将抽查写成全量像素检查。不能用 PSNR 高、视觉相似、编码器参数称为 lossless 等替代精确检查。同时保留源编码的色彩标记和必要元数据;原图有 EXIF/色彩/方向等元数据时保留 raw 和必要来源信息;不能静默自动旋转图像而不更新像素对应与标定。以上加速策略仅适用于原 JPEG 码流直接封装,不适用于深度、标签或重新编码的 RGB。
|
| 178 |
+
|
| 179 |
+
所有共享视频的呈现帧顺序与统一 frame_index 一一对应,每个栅格组件恰好 T 帧。MKV 的 `storage_fps` 只服务封装,声明 `timebase_role=index_only`;source_copy 可以保留源 PTS 以避免改坏码流,但真实时间与标注对齐仍以 frames 为准。未知真实时间保留 null。缺失某帧组件时保留索引位置并使用该组件的无效占位/valid 标识,不删帧;不能以重复相邻图像冒充已知观测。
|
| 180 |
+
|
| 181 |
+
### 3.2 depth.mkv 与 depth_valid.mkv
|
| 182 |
+
|
| 183 |
+
深度语义仍是 `depth/z_float32/v1`:统一读取结果 `[T,H,W] float32`,米制相机 Z 分量,`depth_type=z`。有效深度有限且大于 0,无效位置为 NaN。`depth_origin=measured/rendered/unknown` 必填,来源不明时 unknown。默认与 RGB 共用像素网格及相机参考系,不处理未注册 RGB-D。射线距离必须依据源定义转换成 z,不能只改声明。
|
| 184 |
+
|
| 185 |
+
#### 3.2.1 float32 的可逆视频编码
|
| 186 |
+
|
| 187 |
+
采用 `mkv/depth_float32_bits/v1`:**不是把深度量化成 uint16**,而是将规范化后每个 IEEE-754 float32 的完整 32 位拆成两个 uint16,使用 FFV1 gray16le 保存。视频物理尺寸为 `[2W,H]`:每行前 W 列存原 float32 位串的低 16 位,后 W 列存高 16 位。读取时先合并为 uint32 位串,再按 float32 重新解释,不能数值 cast 成 float32。
|
| 188 |
+
|
| 189 |
+
```text
|
| 190 |
+
u = reinterpret_uint32(depth_float32)
|
| 191 |
+
encoded[:, :, :W] = uint16(u & 65535)
|
| 192 |
+
encoded[:, :, W:] = uint16(u >> 16)
|
| 193 |
+
u_restored = uint32(low) | (uint32(high) << 16)
|
| 194 |
+
depth_float32 = reinterpret_float32(u_restored)
|
| 195 |
+
```
|
| 196 |
+
|
| 197 |
+
统一采用 little-endian 原始字节接口。`camera.image_size` 始终是逻辑 RGB 尺寸 `[W,H]`,不能改成编���视频的 2W;`storage.encoded_size=[2W,H]`。包括 NaN 在内的 float32 位串必须全帧完全恢复,不允许改成 float16、整数毫米、归一化灰度或 RGB 伪彩色。这里的无损验收基准是完成既定米制/坐标转换后的标准 float32 数组,不声称消除 float64→float32 等原约定转换本身的舍入。
|
| 198 |
+
|
| 199 |
+
#### 3.2.2 逐像素有效性
|
| 200 |
+
|
| 201 |
+
`depth_valid.mkv` 使用 `mkv/bool_ffv1/v1`,FFV1 gray8(FFmpeg pixel_format=`gray`),物理尺寸 `[W,H]`。像素只能为 0 或 1,统一解码为 `[T,H,W] bool`,逐像素含义不变。这样不再把庞大的 bool 数组保存为未压缩 `.pt`;标注的帧级/手级 valid 仍保留原有小数组。
|
| 202 |
+
|
| 203 |
+
登记示例(W、H 以下取 640、480;decoder/encoder_parameters 的实际版本由转换器填写):
|
| 204 |
+
|
| 205 |
+
```json
|
| 206 |
+
{
|
| 207 |
+
"available": true,
|
| 208 |
+
"schema_id": "depth/z_float32/v1",
|
| 209 |
+
"data_ref": "observation/depth.mkv",
|
| 210 |
+
"axes": ["T", "height", "width"],
|
| 211 |
+
"valid_ref": "observation/depth_valid.mkv",
|
| 212 |
+
"valid_axes": ["T", "height", "width"],
|
| 213 |
+
"unit": "m",
|
| 214 |
+
"depth_type": "z",
|
| 215 |
+
"depth_origin": "measured",
|
| 216 |
+
"invalid_value": "NaN",
|
| 217 |
+
"storage": {
|
| 218 |
+
"profile": "mkv/depth_float32_bits/v1",
|
| 219 |
+
"codec": "ffv1",
|
| 220 |
+
"pixel_format": "gray16le",
|
| 221 |
+
"encoded_size": [1280, 480],
|
| 222 |
+
"source_lossy": false,
|
| 223 |
+
"decoder": {"name": "ffmpeg", "version": "填写实际版本"},
|
| 224 |
+
"encoder_parameters": {"name": "ffv1", "level": 3, "version": "填写实际版本"}
|
| 225 |
+
},
|
| 226 |
+
"valid_storage": {
|
| 227 |
+
"profile": "mkv/bool_ffv1/v1",
|
| 228 |
+
"codec": "ffv1",
|
| 229 |
+
"pixel_format": "gray",
|
| 230 |
+
"encoded_size": [640, 480],
|
| 231 |
+
"source_lossy": false,
|
| 232 |
+
"decoder": {"name": "ffmpeg", "version": "填写实际版本"},
|
| 233 |
+
"encoder_parameters": {"name": "ffv1", "version": "填写实际版本"}
|
| 234 |
+
},
|
| 235 |
+
"provenance": {"kind": "format_conversion", "method": "源深度转米制 z float32;逐位打包为 FFV1"},
|
| 236 |
+
"source_locator": {"file": "raw/data/depth.zip", "member": "depth/0001.png"}
|
| 237 |
+
}
|
| 238 |
+
```
|
| 239 |
+
|
| 240 |
+
深度和有效性视频都必须逐帧解码验收:float32 位串相同、bool 相同、T 相同,并检查 valid=true 的正有限值和 valid=false 的 NaN。读取器必须按 profile 还原,不能把 depth.mkv 的编码像素直接当深度值。
|
| 241 |
+
|
| 242 |
+
## 4. camera 相机、帧索引与标定
|
| 243 |
+
|
| 244 |
+
### 4.1 frames.jsonl:索引、时间与对应关系
|
| 245 |
+
|
| 246 |
+
`camera/frames.jsonl` 每行对应统一帧号 `frame_index=0..T-1`,是所有组件的唯一行索引。至少包含 `frame_index`、`timestamp_ns`、`clock_domain`、`source_locator`;原始帧号/文件名保存在 `source_frame_id`,不能被新帧号替代。每行还可有 `annotation_matches`,按组件键保存 `source_frame_id`、`source_timestamp_ns`、`clock_domain`、`match_method` 和 `delta_ns`;方法为 exact/index_map/nearest/interpolated,索引映射无时间依据时 delta_ns=null。nearest 必须记录允许误差;interpolated 必须记录两端源标识和权重。delta_ns 仅在同一时间域中计算为源标注时间减图像时间。多相机共享 `sequence_id`;已知同步关系必须用 `sync_id` 或明确的源帧/时间映射表达,不能仅凭相同数组索引认定同步。
|
| 247 |
+
|
| 248 |
+
每个视图必须提供此文件。源时间使用整数纳秒及 `clock_domain`,未知写 JSON `null`;不同时间域不能直接比较。逐帧 split 可以覆盖 metainfo 的视图默认划分,并保留来源,见 2.4。
|
| 249 |
+
|
| 250 |
+
### 4.2 坐标系与标定通则
|
| 251 |
+
|
| 252 |
+
| 项目 | 统一约定 |
|
| 253 |
+
|---|---|
|
| 254 |
+
| 相机坐标 | 右手系,X 向右、Y 向下、Z 向前,长度单位米 |
|
| 255 |
+
| 齐次变换 | 列向量,`p_target = T_target_from_source @ p_source` |
|
| 256 |
+
| 图像坐标 | `(u,v)`;左上像素中心为 `(0,0)`,u 向右、v 向下,单位 pixel |
|
| 257 |
+
| 固定标定 | 本版展开为 T 份,同一 schema 不混用静态与动态形状 |
|
| 258 |
+
| 分辨率或模型变化 | 分开存储为视图/片段,不在同一组件中混装 |
|
| 259 |
+
| 未知标定 | 相机内外参允许缺省,不填单位阵冒充已知标定 |
|
| 260 |
+
|
| 261 |
+
### 4.3 intrinsic.pt 与畸变参数
|
| 262 |
+
|
| 263 |
+
| model / schema_id | intrinsic.pt 的固定结构 |
|
| 264 |
+
|---|---|
|
| 265 |
+
| pinhole / camera/pinhole/v1 | `[T,3,3]`,标准 K,最后一行为 `[0,0,1]`;限无畸变或已校正图像 |
|
| 266 |
+
| fisheye624 / camera/fisheye624/v1 | `[T,15]`,`[f,cx,cy,k0,k1,k2,k3,k4,k5,p0,p1,s0,s1,s2,s3]`,采用 Project Aria Fisheye624 投影定义 |
|
| 267 |
+
| opencv_fisheye4 / camera/opencv_fisheye4/v1 | `intrinsic.pt [T,3,3]` 保存 K;同组件 `distortion_ref` 指向 `[T,4]`,顺序 `[k1,k2,k3,k4]`,使用 OpenCV fisheye 等距角度多项式;已由 ReInterHand 实际原始相机参数验证 |
|
| 268 |
+
| rational8 / camera/rational8/v1 | `intrinsic.pt [T,3,3]` 保存 K;同组件必需 `distortion_ref` 指向 `[T,8]`,顺序 `[k1,k2,p1,p2,k3,k4,k5,k6]` |
|
| 269 |
+
| unknown / null | 不提供可用 intrinsic,不声称可以投影 |
|
| 270 |
+
|
| 271 |
+
有畸变的其他模型必须注册新 schema,固定参数名、顺序和投影公式;不能塞进针孔 K 后遗失畸变项。`metainfo.camera.schema_id` 必须与 intrinsic 组件一致。同一模型的别名不可隐式改变参数布局。
|
| 272 |
+
|
| 273 |
+
`opencv_fisheye4`:对前方点令 `x=X/Z, y=Y/Z, r=sqrt(x²+y²), theta=atan(r)`,`theta_d=theta*(1+k1*theta²+k2*theta⁴+k3*theta⁶+k4*theta⁸)`;`u=fx*x*theta_d/r+cx, v=fy*y*theta_d/r+cy`。光轴 r=0 时使用连续极限 `theta_d/r=1`。四系数不能按普通径向畸变解释,也不能补零冒充 Fisheye624。
|
| 274 |
+
|
| 275 |
+
rational8 对归一化坐标 x=X/Z、y=Y/Z,令 r²=x²+y²,径向项为 `(1+k1*r²+k2*r⁴+k3*r⁶)/(1+k4*r²+k5*r⁴+k6*r⁶)`;再加 p1/p2 切向项并经 K 得到像素。`distortion_ref` 与 intrinsic 共用 `[T]` valid,保存到 camera/distortion.pt。不得把这种畸变三维坐标当作真实相机系 xyz 保存。
|
| 276 |
+
|
| 277 |
+
内参有效性为 `intrinsic_valid.pt [T] bool`;有畸变时使用对应 `distortion_ref`。同一模型的参数名和顺序固定。
|
| 278 |
+
|
| 279 |
+
### 4.4 extrinsic.pt 与 extrinsic_valid.pt
|
| 280 |
+
|
| 281 |
+
`extrinsic.pt` 为 `[T,4,4]`,schema `transform/se3/v1`,方向固定 `T_camera_from_world`,有效性 `[T]`。世界坐标含义及源坐标转换记录在 provenance 中;只有相机坐标标注不要求虚构世界坐标。旋转块须正交且 determinant≈1。
|
| 282 |
+
|
| 283 |
+
## 5. annotation 标注数据
|
| 284 |
+
|
| 285 |
+
### 5.1 标注通则:手槽、valid 与 visibility
|
| 286 |
+
|
| 287 |
+
手槽固定为 0=left、1=right,指解剖学左右,不按画面位置或可见性重排。本阶段只处理左右手两槽,不处理更多手。实体引用使用 `hand_left`、`hand_right`;手槽不证明跨采集片段的个人身份。
|
| 288 |
+
|
| 289 |
+
#### 5.1.1 valid:标注是否可用于监督
|
| 290 |
+
|
| 291 |
+
标注的 `valid=true` 表示:有对应实际标注、通过本 schema 数值检查,且通过来源明确提供并适用于该组件的有效性/QA 条件。`valid=false` 可由缺标注、无法建立帧对应、源无效占位或官方 QA 不通过导致;不等于画面没有手或手不可见。各组件独立判断,MANO 按 `[T,2]` 标记左右手,关键点按 `[T,2,K]` 标记。
|
| 292 |
+
|
| 293 |
+
**2026-09-20 将标注 valid 从“仅表示存在”修订为“可用于监督”,字段形状不变。** 公式为 `source_annotation_present AND numerical_checks_pass AND applicable_official_QA_pass`。没有官方 QA 时省略最后一项,不伪造 QA;不能把未知当成已通过已存在的 QA。适配器在组件 `valid_policy` 中记录具体规则、来源、聚合/广播作用域。缺失官方必需 QA 的记录须明确处理为未知或暂停验收,不能静默通过。无效浮点项仍填 NaN,原始数据保留在 raw;被排除原值可用于 doc 中明确标识的诊断渲染,不能冒充 shared 有效监督。
|
| 294 |
+
|
| 295 |
+
本地筛选须依据明确的规则,并在 `valid_policy.local_excluded_frame_indices`、排除原因和正式报告中记录。单个可疑投影作为问题记录,不直接硬编码排除该帧。已确认的曝光异常须明确作用范围,不能把一个序列的“前两帧有问题”套到所有序列。RGB 编码完好与几何监督可用是两件事,允许保留原图及帧索引而屏蔽对应标注;未发现问题不等于完成全部人工审核,试点待确认时不能作为已验收发布使用。
|
| 296 |
+
|
| 297 |
+
源字段必须按官方语义映射,不能直接按名字复制:
|
| 298 |
+
|
| 299 |
+
| 来源 | 官方含义 | 映射原则 |
|
| 300 |
+
|---|---|---|
|
| 301 |
+
| [H2O](https://github.com/taeinkwon/h2odataset) 的手标注首位 | 0 未标注、1 已标注 | 可作为对应手标注存在性的依据,不推断未标注原因 |
|
| 302 |
+
| [HOT3D](https://github.com/facebookresearch/hot3d#using-mask-files) 的 pose_available、visible、mask_qa_pass | 分别表达姿态存在、可见性、对画面中可见手物位姿的人工 QA | 逐手/物体记录决定存在性,再 AND 当前相机当前帧 QA;QA 是整帧聚合判定,保守排除该帧全部手物几何监督,不声称每个实体均有错误;源可见性基于位姿推导时,其自身 valid 同样受 QA 约束 |
|
| 303 |
+
| [Dex-YCB](https://github.com/NVlabs/dex-ycb-toolkit#loading-dataset-and-visualizing-samples) 的全零 pose_m、全 -1 joints | 不可见的手或缺标注共用占位表示 | 对应组件 valid=false;不能从该值判定 visibility=false,也不能声称原因是动捕缺失 |
|
| 304 |
+
| [ARCTIC](https://github.com/zc-alexfan/arctic/blob/master/docs/data/data_doc.md) 的 is_valid/left_valid/right_valid | 是否有效用于官方评估 | 核实每项筛选依据;不把可见性/评估选择直接等同 QA。本次原始 mano.npy 不含这些派生评估标记,按原记录与数值检查生成 valid,并声明没有额外官方 QA 输入 |
|
| 305 |
+
|
| 306 |
+
源 valid=false 若代表评估筛选或其他条件,应检查实际标注和源约定后映射;不能一律清空坐标。反之,占位零或 -1 只有在源官方明确规定时才判为缺失,不泛化成所有数据的判断规则。
|
| 307 |
+
|
| 308 |
+
`valid=true` 的标注应通过其 schema 的数值与形状检查;检查失败必须报告或修复,不能静默隐藏。QA 不通过应报告排除数量与原因,并保留可追溯信息;不能把这类无效称为缺标注。RGB、深度等观测有效性仍按各自 schema;手物 QA 不自动否定 RGB、静态相机内参或物体资产。相机外参是否过滤须依据其自身来源规则;HOT3D 本次保留源外参用于溯源和诊断,不能用其存在性证明 QA 失败帧的几何监督正确。
|
| 309 |
+
|
| 310 |
+
#### 5.1.2 visibility:可见性属性
|
| 311 |
+
|
| 312 |
+
附加质量属性只保留 `visibility`,存放在对应模态或标注集内,不设 quality 目录。同一份可见性仅存一次;uv 与 xyz 共用时引用同一个文件。
|
| 313 |
+
|
| 314 |
+
visibility 通过所属组件 attributes 登记 data_ref、axes、dtype、visibility_type、meaning、provenance、source_locator;未知值通过属性 valid_ref 标识,全已知可声明 valid=true。比例与布尔值不相互强转,也不按任意阈值二值化。没有 MANO 时,整手可见性挂在 keypoints 组件,使用独立的 whole_hand_visibility.pt,明确 meaning=whole_hand,不与逐关键点可见性混用。
|
| 315 |
+
|
| 316 |
+
`valid` 回答“这项标注能否用于监督”,`visibility` 回答“在当前图像中是否可见(或可见多少)”。不可见的手或关键点仍可有有效标注;不能因 visibility=0 就清空坐标。源没有 visibility 时缺省或标为未知,不由 valid 推断。
|
| 317 |
+
|
| 318 |
+
| 情况 | 手标注 valid | visibility |
|
| 319 |
+
|---|---|---|
|
| 320 |
+
| RGB 已开始录制,动捕尚未开始,没有其他对应手标注 | false | 以独立源可见性标注为准;没有则未知 |
|
| 321 |
+
| 手被遮挡,但源有标注且通过适用有效性检查 | true | 若源声明不可见,则 false 或源可见比例 |
|
| 322 |
+
| 手可见且有对应标注,通过适用 QA | true | 若源有此信息,则 true 或源可见比例 |
|
| 323 |
+
| 手可见,但该帧漏标或动捕中断 | false | 可以为 true,但必须有独立来源依据 |
|
| 324 |
+
| 有手部参数,但官方 QA 明确不通过 | false | 不据此断言不可见;源可见比例若基于不可靠位姿,其属性 valid 也为 false |
|
| 325 |
+
|
| 326 |
+
visibility 自己的 valid_ref 表示该可见性标注是否可用,不复用 MANO 或关键点坐标的 valid_ref;明确记录源存在性及适用的 QA 条件。上述例子不要求凭图像自动生成可见性。
|
| 327 |
+
|
| 328 |
+
不设 quality 组件或目录,不另存拟合误差、曝光、截断比例等通用质量数组。适用的官方 QA 合并进对应 valid,在 `valid_policy` 记录来源与规则;正式校验报告保留原始 QA 时间区间及排除统计。原始 QA 文件仍在 raw,官方 split 保留。
|
| 329 |
+
|
| 330 |
+
### 5.2 mano:参数与整手可见性
|
| 331 |
+
|
| 332 |
+
MANO schema `mano/axis_angle61/v1`:`motion.pt [T,2,61]`,顺序为完整 16 关节 axis-angle 48、shape betas 10、全局平移 3。姿态使用弧度,平移米,位于当前相机系。有效性 `[T,2]`;缺少一侧整槽 NaN。PCA 必须先按对应模型展开,不能将 PCA 系数直接填入 axis-angle。
|
| 333 |
+
|
| 334 |
+
`model_profile` 必须固定 MANO 版本、`flat_hand_mean=true`、左手 shapedirs 修正状态。平移表示模型输出顶点所加的全局平移,不是某个腕关节的坐标;源语义不同须转换。shape 无量纲。模型权重不作为共享数据附带上传。
|
| 335 |
+
|
| 336 |
+
`mano/visibility.pt [T,2]` 保存源整手可见比例时使用 float32 [0,1],`visibility_type=ratio`;只有实际采用 0–100 的百分比才除以100,不能只凭表头判断。HOT3D 的 `visibility_ratio[%]` 实值已经是0–1,官方读取器原样读取,必须保留原值。通过 MANO 组件 attributes 登记,使用独立有效性,不复用 motion_valid。
|
| 337 |
+
|
| 338 |
+
手部共享表示仅保留 MANO 参数与选定关键点,不发布独立手表面几何。需要渲染或接触计算时由 MANO 参数生成,几何引用使用固定 MANO 模型配置与顶点顺序;不影响 object 下的物体模型和材质资产。
|
| 339 |
+
|
| 340 |
+
### 5.3 keypoints:二维点、三维点与逐点可见性
|
| 341 |
+
|
| 342 |
+
关键点独立于 MANO 参数存在;没有 motion 也可有关键点。`uv.pt [T,2,K,2]` 与 `xyz.pt [T,2,K,3]`,有效性 `[T,2,K]`,分别采用 `keypoints/uv/v1` 和 `keypoints/xyz/v1`。K 由 `keypoint_schema` 固定,不能在同一数组中逐帧变化;同体系统一顺序。数值使用像素坐标或米制相机系。
|
| 343 |
+
|
| 344 |
+
| keypoint_schema | K 与固定索引 |
|
| 345 |
+
|---|---|
|
| 346 |
+
| mano21/v1 | 21;wrist 后依次 thumb/index/middle/ring/little,每指由近端至指尖 |
|
| 347 |
+
| rhd21/v1 | 21;保持 wrist,然后五指由近端至指尖;原始每指 tip→palm 反序。只统一顺序,不宣称解剖学位置等价于 MANO |
|
| 348 |
+
|
| 349 |
+
具体名称与源索引映射见 `schema.json`。当前只登记 MANO21 与 RHD21;不登记 MediaPipe、ReInterHand capture21 或 fit24 中间关键点。
|
| 350 |
+
|
| 351 |
+
每个发布中的每个视图只提供一套标准手关键点,直接放在 keypoints 下,不设 annotation_set_id 字段或目录。uv 与 xyz 是这套关键点的二维与三维表示,不是两套标注。provenance 分别记录二者来自原始标注还是计算结果;不要求已有 2D 必须由当前 xyz 重新投影覆盖。
|
| 352 |
+
|
| 353 |
+
ReInterHand 的 Original keypoints���Original fits keypoints 及带前臂关键点不纳入 shared;如需手关键点,从选定 MANO 参数生成 MANO21 并记录模型/指尖回归约定。其他数据集默认使用选定的官方关键点,不额外生成平行的 MANO 派生集合。后续主动更换生成方法或结果时发布新的 dataset_version,不在同一版本内增设方法分支。
|
| 354 |
+
|
| 355 |
+
manual/projection/fitting 只记录在 provenance,不作为目录或类型分支。不得通过坐标为零、是否出画或 visibility 判断标注是否存在。派生标注仅在实际生成并通过数值检查后声明 valid=true;没有生成的项为 false,不伪造坐标。
|
| 356 |
+
|
| 357 |
+
`keypoints/visibility.pt [T,2,K]` 保存源逐点可见性,布尔表示使用 `visibility_type=boolean`。uv 与 xyz 共用时引用同一份文件。整手比例属性没有 MANO 可挂载时使用 `whole_hand_visibility.pt [T,2]`,`meaning=whole_hand`;它与逐点可见性分开,通用登记规则见 5.1。
|
| 358 |
+
|
| 359 |
+
不使用 annotation_set_id;ReInterHand 中间关键点集合不进入 shared,raw 保留来源文件。
|
| 360 |
+
|
| 361 |
+
### 5.4 object:身份、资产、位姿与几何
|
| 362 |
+
|
| 363 |
+
#### 5.4.1 metainfo.json:物体身份与跟踪作用域
|
| 364 |
+
|
| 365 |
+
手用 `hand_left`、`hand_right` 及槽位 0、1 表示,不再另存 entities.json。物体身份登记在 `annotation/object/<object_id>/metainfo.json`,必填 `object_id`、`identity_scope`、`scope_id`、`source_locator`;可含 `category_id`、`source_object_id`、`mesh_ref`、`has_model`、部件引用。即使只有分割、没有 pose/mesh,也可只有这份物体元信息。
|
| 366 |
+
|
| 367 |
+
`identity_scope` 为 frame/subsequence/sequence,`scope_id` 指定具体作用域;跨相机共享身份只在已有源对应证据时使用。VISOR 按官方 subsequence 与实体名关联时记录 `association_basis=official_subsequence_entity_name`,不能声称这是全视频物理实例跟踪。无需与 object_id 一一对应的标准 track_id;官方独立轨迹标识存在时保留为 source_track_id,并声明作用域。手槽不证明跨采集片段的个人身份。
|
| 368 |
+
|
| 369 |
+
#### 5.4.2 assets:网格、材质与纹理
|
| 370 |
+
|
| 371 |
+
资产属于物体,统一存放在 `annotation/object/<object_id>/` 内,可用 `assets/` 子目录组织网格、材质、纹理和部件资产。序列层不设共享 assets。所有引用采用视图根目录为基准;其中物体资产组件的 `data_ref` 与部件的 `mesh_ref` 采用相对于当前视图目录的 POSIX 路径,例如 `annotation/object/cup_01/assets/cup.obj`,且必须指向所属物体目录内的资产。OBJ 内部的材质、纹理引用遵循文件格式自身的相对路径规则,依赖文件一并保留。不同相机视图允许各自保存物体资产,不要求跨视图去重;下载物体时包含其资产依赖。
|
| 372 |
+
|
| 373 |
+
网格 schema 为 `mesh/obj/v1`,顶点米制,静态有效性可直接声明标量 `valid`,或通过 `valid_ref` 指向标量 bool Tensor;不按 T 重复静态资产。由物体/部件通过引用关联,不仅凭文件名猜测。
|
| 374 |
+
|
| 375 |
+
#### 5.4.3 pose.pt、pose_valid.pt 与 visibility.pt
|
| 376 |
+
|
| 377 |
+
刚体 schema 为 `object/rigid/v1`,`pose.pt [T,4,4]` 固定为 `T_camera_from_object`,平移米制,有效性 `[T]`。物体坐标原点、轴向必须与 mesh 一致;旋转块为正交矩阵且 determinant≈1。
|
| 378 |
+
|
| 379 |
+
`object/<id>/visibility.pt [T]` 保存源物体可见比例,float32 [0,1],`visibility_type=ratio`。通过所属物体组件 attributes 登记,独立表达其有效性。
|
| 380 |
+
|
| 381 |
+
#### 5.4.4 articulation.json、部件位姿与 joint_state.pt
|
| 382 |
+
|
| 383 |
+
关节物体:schema `object/articulated/v1`,`articulation.json` 登记 `parts` 与 `joints`。每个 part 有 `part_id`、`parent_id`(根为 null)、`has_model`、`mesh_ref`;has_model=false 时 mesh_ref=null,结构节点允许没有网格。父链不得成环。每个 joint 有唯一 `joint_id`、`parent_part`、`child_part`、`type`;fixed 单位 null、revolute 弧度、prismatic 米。有源限位时保存 `limits:[lower,upper]`;没有时 null,不伪造上下限。部件姿态统一为 `T_camera_from_part [T,4,4]`,不与父局部变换混装。
|
| 384 |
+
|
| 385 |
+
若提供 `joint_state.pt [T,J]`,必须登记固定 joint_order、轴在父部件系的表达、零位变换与正方向,valid 为 `[T,J]`;缺少这些运动学定义时只发布部件位姿与已有来源信息,不伪造可驱动的关节模型。关节值与部件位姿同时存在时需验证一致性。
|
| 386 |
+
|
| 387 |
+
部件层级应声明语义:纯语义包含树允许 `joints=[]`,不将包含关系推断为机械关节。关节状态 schema 为 `object/joint_state/v1`;转动用弧度、移动用米,混合类型按 joint_order 对应的关节定义解释。
|
| 388 |
+
|
| 389 |
+
#### 5.4.5 dimensions、几何关键点与顶点部件标签
|
| 390 |
+
|
| 391 |
+
`dimensions.pt [T,3]` 采用 `object/dimensions/v1`,有效性为 `[T]`。
|
| 392 |
+
|
| 393 |
+
物体/部件 `dimensions` 为 `[length,width,height]` 米,轴顺序与该 mesh 的局部坐标关联,登记 `dimensions_semantics` 和来源。HOI4D dimensions 与 mesh 的具体尺度关���未验证前标为 source_unspecified,保留源值并暂停依赖该关系的几何验收,不能默认为待施加缩放。需要施加缩放时明确 scale_applied_to_mesh,禁止重复应用。
|
| 394 |
+
|
| 395 |
+
源物体关键点放 `object/<id>/keypoints/xyz.pt [T,K,3]`(相机系)或 `template_xyz.pt [K,3]`(物体系),schema 分别为 object_keypoints/camera/v1 和 object_keypoints/template/v1。明确 keypoint_schema、keypoint_names、单位及有效性;模板点配合 pose 可投影,无须重复生成全部帧。H2O 中心/角点/棱中点,以及 ARCTIC 部件点分别登记具体源顺序,不套用手的 21 点 schema。每个发布选择一套源几何点并记录选择,不另建方法分支。
|
| 396 |
+
|
| 397 |
+
`vertex_part_ids.pt [V] int64` 绑定 `mesh_ref` 与 topology_id,登记整数到 part_id 的映射;未知用 -1。ARCTIC 不同拓扑的资产分别绑定,不能共用未经转换的顶点标签。部件层级中 is_instance/has_model 等源属性保留,几何文件仍全部归 object。
|
| 398 |
+
|
| 399 |
+
### 5.5 segment:分割类别、编码与覆盖范围
|
| 400 |
+
|
| 401 |
+
每个发布选择一套任务使用的分割表示,不建立方法/标注集分支。没有分割就不创建 segment 目录,不为其他模态创建空的实体表。
|
| 402 |
+
|
| 403 |
+
| schema_id | 文件与数值语义 |
|
| 404 |
+
|---|---|
|
| 405 |
+
| segment/uint16_labels/v1 | mask.mkv;整数区域编号,通过 instances.jsonl 解释 |
|
| 406 |
+
| segment/instance_polygons/v1 | polygons.jsonl;实例多边形,可重叠;当前不支持孔洞拓扑 |
|
| 407 |
+
| segment/foreground_intensity/v1 | mask.mkv;0–255 前景强度,不是区域编号或经过校准的概率 |
|
| 408 |
+
|
| 409 |
+
#### 5.5.1 uint16 标签图与 instances.jsonl
|
| 410 |
+
|
| 411 |
+
组件声明 `segmentation_type=semantic/instance/part`;同一组件固定一种类型。`mask.mkv` 解码为 `[T,H,W] uint16`,schema `segment/uint16_labels/v1`,使用 `mkv/uint16_ffv1/v1`,FFV1 gray16le 无损;只有所有区域编码均 ≤255 时允许 gray8(pixel_format=gray),读取后转 uint16,数值不变。禁止调色板和有损编码。有效性 `[T]`,表示该帧有可用分割标注。数值 0 固定为 unassigned,65535 固定为 ignore,1–65534 为区域编码,不能直接等同 entity_id。
|
| 412 |
+
|
| 413 |
+
`instances.jsonl` 每帧一行,包含 `frame_index` 与 `labels`。每条标签包含 `mask_value`、`category_id`、`entity_id`、`part_id`;无意义或未知字段为 null。semantic 允许 entity_id=null;instance 必须引用 hand_left/hand_right 或登记的 object_id;part 还须关联登记部件。源实例 ID 和其他属性分别保存在 `source_instance_id`、`source_attributes`。mask 中每个非保留编码必须有且仅有一个映射。
|
| 414 |
+
|
| 415 |
+
FreiHAND 的试点按本任务需要,统一到手/背景类别,保留每个原生区域编码;不要求给原生细分区域猜测手指名称。需要细部件监督时,尚未核实的部件名称必须保持未知,不能因粗粒度手类别已核实便声称部件语义也已统一。
|
| 416 |
+
|
| 417 |
+
#### 5.5.2 重叠实例多边形
|
| 418 |
+
|
| 419 |
+
每发布选择一套任务使用的分割表示,不建立方法/标注集分支。VISOR 的实际试点存在重叠实例多边形,单层标签图不能无损表达。对此补充 `segment/instance_polygons/v1`:`segment/polygons.jsonl` 每帧包含 `frame_index` 和 `instances`,每实例包含 `mask_value` 与 `polygons`(列表,每个多边形为源图像像素坐标顶点序列,保留原始精度)。身份和类别仍由同一 `instances.jsonl` 映射,有效性仍为 `[T]`,通过 schema 区分物理编码。允许多实例重叠,不采用后画覆盖前画。消费者按需栅格化为独立实例二值 mask;不能声称合并的单层 mask 无损。
|
| 420 |
+
|
| 421 |
+
#### 5.5.3 灰度前景强度
|
| 422 |
+
|
| 423 |
+
ReInterHand 的官方渲染 mask 为双手合并的灰度前景掩码,实测存在 0–255 的中间值,不是左右手实例编号。登记 `segment/foreground_intensity/v1`:仍存 `segment/mask.mkv`,解码为 `[T,H,W] uint16`,使用 `mkv/uint16_ffv1/v1`,此类数据优先编码为 FFV1 gray8(pixel_format=gray),读取后转 uint16。有效值范围 0–255,归一化值为 `float32(value)/255`;0 为背景端点、255 为前景端点。组件声明 `foreground_category=hand`、`entity_id=null` 和双手合并语义,不使用区域编号映射。这里保留原始渲染 mask 强度,不把它称为经过校准的概率。若任务需要二值 mask,阈值化属于任务层派生操作,记录阈值;共享层不丢弃中间灰度。不同 schema 的数值含义不同,不能将该文件按整数类别图解码。
|
| 424 |
+
|
| 425 |
+
FreiHAND 训练集的 JPEG mask 使用 `segment/foreground_intensity/v1`,逐像素保留 JPEG 解码后的灰度,`entity_id=hand_right`。该 schema 不限定双手合并:单手或合并范围由 `entity_id` 与 `coverage` 明确声明。评估集整数区域图仍用 `segment/uint16_labels/v1`,两者不能仅凭文件名使用同一种解码语义。
|
| 426 |
+
|
| 427 |
+
#### 5.5.4 coverage 与有效性
|
| 428 |
+
|
| 429 |
+
`coverage.kind=full/selected_entities/partial/unknown`。full 指声明���标注范围完整;selected_entities 还应列出目标范围。无论哪种,0 本身不自动成为背景;背景要有明确类别映射,未标注区域不能用于构造负样本。保留源逐类/逐实例 exhaustive 信息,未知不可改写为完整。
|
| 430 |
+
|
| 431 |
+
三种表示的帧级有效性均为 `[T]`,表示该帧是否提供此分割标注;对应 valid_ref 在组件中登记,仍用小型 bool `.pt` 数组。栅格 mask 必须登记 storage,格式见 3.1.2,所有帧的整数编码或强度逐值完全相同。编码语义由 schema_id 决定,读取器不能仅依据 mask.mkv 文件名选择解码方式。
|
| 432 |
+
|
| 433 |
+
### 5.6 contact:接触、抓取、区域与距离
|
| 434 |
+
|
| 435 |
+
#### 5.6.1 relations.jsonl 与 relations_valid.pt
|
| 436 |
+
|
| 437 |
+
`annotation/contact/relations.jsonl`,schema contact/relations/v1,每帧一行含 frame_index、relations。每条记录含 relation_type(contact/grasp)、subject_id(手槽或登记实体)、object_id、status、source_locator、provenance。status 固定为 positive/negative/unknown/target_unannotated:positive 必须有可解析目标,negative 表示源明确否定该关系,unknown 为不确定,target_unannotated 为确有接触但目标未标注。非 positive 的 object_id 可 null,不能用 null 冒充“不接触”。稀疏源无记录的帧不自动补 negative。
|
| 438 |
+
|
| 439 |
+
VISOR 的对象 mask ID 必须先按同帧 source_instance_id 解析成 object_id;hand-not-in-contact、none-of-the-above、inconclusive 分别映射 negative、target_unannotated、unknown,保留原始字符串。Dex ycb_grasp_ind 通过 ycb_ids 映射到登记物体,以 relation_type=grasp 保存;不得当作逐顶点接触。
|
| 440 |
+
|
| 441 |
+
relations 组件的 valid_ref 指向 `relations_valid.pt [T] bool`,表示该帧是否有可用源关系标注。有效帧中可以存在 status=unknown 的明确不确定标注;无源标注的帧为 valid=false、relations=[]。组件仍声明 available/provenance/source_locator。
|
| 442 |
+
|
| 443 |
+
#### 5.6.2 实体对的顶点区域与距离
|
| 444 |
+
|
| 445 |
+
已发布的接触区域/距离按参与关系的 subject_id 与 object_id 组织,每对实体保留选定的一套结果,以精确 geometry_ref/topology_id 关联到手或物体/部件;不要求每套数据都有。顶点区域 schema contact/vertex_region/v1:bool `[T,V]` 加同形 valid;顶点距离 schema contact/vertex_distance/v1:float32 `[T,V]`、米、同形 valid,声明 source/target geometry_ref、distance_definition(signed/unsigned、测量到点集或表面等明确源定义)。geometry_ref 必须指向已登记 mesh 或由固定 MANO 模型配置确定的拓扑;拓扑/顶点数变化时按拓扑拆分片段。其他源区域表示只有在实际接入并登记 schema 后才可转换,不能随意栅格化宣称等价。
|
| 446 |
+
|
| 447 |
+
顶点区域/距离已有存储定义,但尚未完成真实输入试点;接入时必须提供源语义与几何验收证据,不因已经登记 schema 就视为通过。
|
| 448 |
+
|
| 449 |
+
## 附录:任务范围
|
| 450 |
+
|
| 451 |
+
不强制收录 2D bbox、完整高频动捕、动作程序、身体 SMPL-X、点云或网络特征。范围内的接触、visibility、选定手关键点、物体几何不能因不便处理而静默丢弃。分割采用的物理编码由第 5.5 节决定,存在重叠时不能以单层标签图声称无损。
|
| 452 |
+
|
| 453 |
+
不设置 entities_ref/segment/entities.json,不要求与 object_id 重复的 track_id。MediaPipe 不在当前关键点定义中;旧版本迁移必须保留可追溯关系,不能直接删表。手部共享表示不含独立 hand_mesh。
|
| 454 |
+
|
| 455 |
+
schema.json 是普通注册表,不是 JSON Schema 文档或可执行验收器;定义存在不代表真实数据已验证。验收须保留实测范围与未决项。
|
| 456 |
+
|
| 457 |
+
本存储约定只更新标准,不代表既有 FFV1/depth.pt 试点已迁移。新发布必须显式写 storage 配置;旧产物按其旧定义读取,不能只改文件后缀或版本标识伪装为合规。
|
H2O/shared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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema_version": "hand-warehouse/1.0",
|
| 3 |
+
"validity_revision": "usable-annotation-2026-09-20",
|
| 4 |
+
"annotation_validity": {
|
| 5 |
+
"meaning": "annotation usable for supervision, not merely record presence",
|
| 6 |
+
"formula": "source_annotation_present AND numerical_checks_pass AND applicable_official_QA_pass AND NOT explicitly_reviewed_local_exclusion",
|
| 7 |
+
"without_official_qa": "omit QA term; declare source rules; do not fabricate QA",
|
| 8 |
+
"policy_field": "components.<name>.valid_policy",
|
| 9 |
+
"visibility_is_independent": true,
|
| 10 |
+
"invalid_float_value": "NaN",
|
| 11 |
+
"hot3d": "broadcast per-camera frame manual QA conservatively to hand/object labels and pose-derived visibility; retain RGB and source calibration; keep native QA in raw and review report",
|
| 12 |
+
"hot3d_visibility": "native visibility_ratio[%] already ranges from 0 to 1; do not divide by 100"
|
| 13 |
+
},
|
| 14 |
+
"hand_slots": [
|
| 15 |
+
"left",
|
| 16 |
+
"right"
|
| 17 |
+
],
|
| 18 |
+
"keypoints": {
|
| 19 |
+
"mano21/v1": {
|
| 20 |
+
"count": 21,
|
| 21 |
+
"names": [
|
| 22 |
+
"wrist",
|
| 23 |
+
"thumb_1",
|
| 24 |
+
"thumb_2",
|
| 25 |
+
"thumb_3",
|
| 26 |
+
"thumb_4",
|
| 27 |
+
"index_1",
|
| 28 |
+
"index_2",
|
| 29 |
+
"index_3",
|
| 30 |
+
"index_4",
|
| 31 |
+
"middle_1",
|
| 32 |
+
"middle_2",
|
| 33 |
+
"middle_3",
|
| 34 |
+
"middle_4",
|
| 35 |
+
"ring_1",
|
| 36 |
+
"ring_2",
|
| 37 |
+
"ring_3",
|
| 38 |
+
"ring_4",
|
| 39 |
+
"little_1",
|
| 40 |
+
"little_2",
|
| 41 |
+
"little_3",
|
| 42 |
+
"little_4"
|
| 43 |
+
],
|
| 44 |
+
"source_index_map": null,
|
| 45 |
+
"note": "adapter maps official MANO joint and fingertip convention"
|
| 46 |
+
},
|
| 47 |
+
"rhd21/v1": {
|
| 48 |
+
"count": 21,
|
| 49 |
+
"names": [
|
| 50 |
+
"wrist",
|
| 51 |
+
"thumb_1",
|
| 52 |
+
"thumb_2",
|
| 53 |
+
"thumb_3",
|
| 54 |
+
"thumb_4",
|
| 55 |
+
"index_1",
|
| 56 |
+
"index_2",
|
| 57 |
+
"index_3",
|
| 58 |
+
"index_4",
|
| 59 |
+
"middle_1",
|
| 60 |
+
"middle_2",
|
| 61 |
+
"middle_3",
|
| 62 |
+
"middle_4",
|
| 63 |
+
"ring_1",
|
| 64 |
+
"ring_2",
|
| 65 |
+
"ring_3",
|
| 66 |
+
"ring_4",
|
| 67 |
+
"little_1",
|
| 68 |
+
"little_2",
|
| 69 |
+
"little_3",
|
| 70 |
+
"little_4"
|
| 71 |
+
],
|
| 72 |
+
"source_index_map_per_hand": [
|
| 73 |
+
0,
|
| 74 |
+
4,
|
| 75 |
+
3,
|
| 76 |
+
2,
|
| 77 |
+
1,
|
| 78 |
+
8,
|
| 79 |
+
7,
|
| 80 |
+
6,
|
| 81 |
+
5,
|
| 82 |
+
12,
|
| 83 |
+
11,
|
| 84 |
+
10,
|
| 85 |
+
9,
|
| 86 |
+
16,
|
| 87 |
+
15,
|
| 88 |
+
14,
|
| 89 |
+
13,
|
| 90 |
+
20,
|
| 91 |
+
19,
|
| 92 |
+
18,
|
| 93 |
+
17
|
| 94 |
+
]
|
| 95 |
+
}
|
| 96 |
+
},
|
| 97 |
+
"camera": {
|
| 98 |
+
"opencv_fisheye4": {
|
| 99 |
+
"K": [
|
| 100 |
+
3,
|
| 101 |
+
3
|
| 102 |
+
],
|
| 103 |
+
"distortion": [
|
| 104 |
+
"k1",
|
| 105 |
+
"k2",
|
| 106 |
+
"k3",
|
| 107 |
+
"k4"
|
| 108 |
+
],
|
| 109 |
+
"projection": "theta=atan(r); theta_d=theta*(1+k1*theta^2+k2*theta^4+k3*theta^6+k4*theta^8); source ReInterHand"
|
| 110 |
+
},
|
| 111 |
+
"pinhole": {
|
| 112 |
+
"K": [
|
| 113 |
+
3,
|
| 114 |
+
3
|
| 115 |
+
]
|
| 116 |
+
},
|
| 117 |
+
"fisheye624": {
|
| 118 |
+
"parameters": [
|
| 119 |
+
"f",
|
| 120 |
+
"cx",
|
| 121 |
+
"cy",
|
| 122 |
+
"k0",
|
| 123 |
+
"k1",
|
| 124 |
+
"k2",
|
| 125 |
+
"k3",
|
| 126 |
+
"k4",
|
| 127 |
+
"k5",
|
| 128 |
+
"p0",
|
| 129 |
+
"p1",
|
| 130 |
+
"s0",
|
| 131 |
+
"s1",
|
| 132 |
+
"s2",
|
| 133 |
+
"s3"
|
| 134 |
+
]
|
| 135 |
+
},
|
| 136 |
+
"rational8": {
|
| 137 |
+
"K": [
|
| 138 |
+
3,
|
| 139 |
+
3
|
| 140 |
+
],
|
| 141 |
+
"distortion": [
|
| 142 |
+
"k1",
|
| 143 |
+
"k2",
|
| 144 |
+
"p1",
|
| 145 |
+
"p2",
|
| 146 |
+
"k3",
|
| 147 |
+
"k4",
|
| 148 |
+
"k5",
|
| 149 |
+
"k6"
|
| 150 |
+
]
|
| 151 |
+
}
|
| 152 |
+
},
|
| 153 |
+
"segmentation": {
|
| 154 |
+
"segment/uint16_labels/v1": {
|
| 155 |
+
"storage": "mask.mkv",
|
| 156 |
+
"dtype": "uint16",
|
| 157 |
+
"mapping": "instances.jsonl",
|
| 158 |
+
"valid_shape": [
|
| 159 |
+
"T"
|
| 160 |
+
],
|
| 161 |
+
"required_metadata": [
|
| 162 |
+
"segmentation_type",
|
| 163 |
+
"coverage",
|
| 164 |
+
"mapping_ref",
|
| 165 |
+
"storage"
|
| 166 |
+
],
|
| 167 |
+
"shape": [
|
| 168 |
+
"T",
|
| 169 |
+
"H",
|
| 170 |
+
"W"
|
| 171 |
+
],
|
| 172 |
+
"reserved_codes": {
|
| 173 |
+
"0": "unassigned",
|
| 174 |
+
"65535": "ignore"
|
| 175 |
+
},
|
| 176 |
+
"region_codes": [
|
| 177 |
+
1,
|
| 178 |
+
65534
|
| 179 |
+
],
|
| 180 |
+
"allowed_storage_profiles": [
|
| 181 |
+
"mkv/uint16_ffv1/v1"
|
| 182 |
+
]
|
| 183 |
+
},
|
| 184 |
+
"segment/instance_polygons/v1": {
|
| 185 |
+
"storage": "polygons.jsonl",
|
| 186 |
+
"mapping": "instances.jsonl",
|
| 187 |
+
"frame_keys": [
|
| 188 |
+
"frame_index",
|
| 189 |
+
"instances"
|
| 190 |
+
],
|
| 191 |
+
"instance_keys": [
|
| 192 |
+
"mask_value",
|
| 193 |
+
"polygons"
|
| 194 |
+
],
|
| 195 |
+
"coordinate_unit": "pixel",
|
| 196 |
+
"overlap_allowed": true,
|
| 197 |
+
"valid_shape": [
|
| 198 |
+
"T"
|
| 199 |
+
],
|
| 200 |
+
"required_metadata": [
|
| 201 |
+
"segmentation_type",
|
| 202 |
+
"coverage",
|
| 203 |
+
"mapping_ref"
|
| 204 |
+
],
|
| 205 |
+
"polygon_shape": [
|
| 206 |
+
"N",
|
| 207 |
+
2
|
| 208 |
+
],
|
| 209 |
+
"holes_supported": false
|
| 210 |
+
},
|
| 211 |
+
"segment/foreground_intensity/v1": {
|
| 212 |
+
"storage": "mask.mkv",
|
| 213 |
+
"dtype": "uint16",
|
| 214 |
+
"value_range": [
|
| 215 |
+
0,
|
| 216 |
+
255
|
| 217 |
+
],
|
| 218 |
+
"normalization_scale": 0.00392156862745098,
|
| 219 |
+
"axes": [
|
| 220 |
+
"T",
|
| 221 |
+
"height",
|
| 222 |
+
"width"
|
| 223 |
+
],
|
| 224 |
+
"meaning": "native hand foreground intensity; individual hand or union declared in metadata; not instance codes or calibrated probability",
|
| 225 |
+
"zero": "background",
|
| 226 |
+
"full_scale": "foreground",
|
| 227 |
+
"mapping": "foreground_category in component metadata",
|
| 228 |
+
"valid_shape": [
|
| 229 |
+
"T"
|
| 230 |
+
],
|
| 231 |
+
"required_metadata": [
|
| 232 |
+
"segmentation_type",
|
| 233 |
+
"coverage",
|
| 234 |
+
"value_range",
|
| 235 |
+
"normalization_scale",
|
| 236 |
+
"foreground_category",
|
| 237 |
+
"entity_id",
|
| 238 |
+
"storage"
|
| 239 |
+
],
|
| 240 |
+
"shape": [
|
| 241 |
+
"T",
|
| 242 |
+
"H",
|
| 243 |
+
"W"
|
| 244 |
+
],
|
| 245 |
+
"allowed_storage_profiles": [
|
| 246 |
+
"mkv/uint16_ffv1/v1"
|
| 247 |
+
]
|
| 248 |
+
}
|
| 249 |
+
},
|
| 250 |
+
"note": "Registry for hand-warehouse/1.0. Read CONTRACT.md for field semantics. This is not a JSON Schema document or executable validator.",
|
| 251 |
+
"components": {
|
| 252 |
+
"mano/axis_angle61/v1": {
|
| 253 |
+
"storage": "pt",
|
| 254 |
+
"dtype": "float32",
|
| 255 |
+
"shape": [
|
| 256 |
+
"T",
|
| 257 |
+
2,
|
| 258 |
+
61
|
| 259 |
+
],
|
| 260 |
+
"valid_shape": [
|
| 261 |
+
"T",
|
| 262 |
+
2
|
| 263 |
+
],
|
| 264 |
+
"unit": "m",
|
| 265 |
+
"angle_unit": "rad",
|
| 266 |
+
"coordinate_frame": "camera",
|
| 267 |
+
"layout": {
|
| 268 |
+
"pose_axis_angle": [
|
| 269 |
+
0,
|
| 270 |
+
48
|
| 271 |
+
],
|
| 272 |
+
"shape": [
|
| 273 |
+
48,
|
| 274 |
+
58
|
| 275 |
+
],
|
| 276 |
+
"translation": [
|
| 277 |
+
58,
|
| 278 |
+
61
|
| 279 |
+
]
|
| 280 |
+
}
|
| 281 |
+
},
|
| 282 |
+
"keypoints/uv/v1": {
|
| 283 |
+
"storage": "pt",
|
| 284 |
+
"dtype": "float32",
|
| 285 |
+
"shape": [
|
| 286 |
+
"T",
|
| 287 |
+
2,
|
| 288 |
+
21,
|
| 289 |
+
2
|
| 290 |
+
],
|
| 291 |
+
"valid_shape": [
|
| 292 |
+
"T",
|
| 293 |
+
2,
|
| 294 |
+
21
|
| 295 |
+
],
|
| 296 |
+
"unit": "pixel",
|
| 297 |
+
"required_metadata": [
|
| 298 |
+
"keypoint_schema"
|
| 299 |
+
]
|
| 300 |
+
},
|
| 301 |
+
"keypoints/xyz/v1": {
|
| 302 |
+
"storage": "pt",
|
| 303 |
+
"dtype": "float32",
|
| 304 |
+
"shape": [
|
| 305 |
+
"T",
|
| 306 |
+
2,
|
| 307 |
+
21,
|
| 308 |
+
3
|
| 309 |
+
],
|
| 310 |
+
"valid_shape": [
|
| 311 |
+
"T",
|
| 312 |
+
2,
|
| 313 |
+
21
|
| 314 |
+
],
|
| 315 |
+
"unit": "m",
|
| 316 |
+
"required_metadata": [
|
| 317 |
+
"keypoint_schema"
|
| 318 |
+
]
|
| 319 |
+
},
|
| 320 |
+
"depth/z_float32/v1": {
|
| 321 |
+
"storage": "mkv",
|
| 322 |
+
"dtype": "float32",
|
| 323 |
+
"shape": [
|
| 324 |
+
"T",
|
| 325 |
+
"H",
|
| 326 |
+
"W"
|
| 327 |
+
],
|
| 328 |
+
"valid_shape": [
|
| 329 |
+
"T",
|
| 330 |
+
"H",
|
| 331 |
+
"W"
|
| 332 |
+
],
|
| 333 |
+
"unit": "m",
|
| 334 |
+
"depth_type": "z",
|
| 335 |
+
"pixel_grid": "current_rgb",
|
| 336 |
+
"coordinate_frame": "current_rgb_camera",
|
| 337 |
+
"valid_storage": "mkv",
|
| 338 |
+
"allowed_storage_profiles": [
|
| 339 |
+
"mkv/depth_float32_bits/v1"
|
| 340 |
+
],
|
| 341 |
+
"allowed_valid_storage_profiles": [
|
| 342 |
+
"mkv/bool_ffv1/v1"
|
| 343 |
+
],
|
| 344 |
+
"required_metadata": [
|
| 345 |
+
"storage",
|
| 346 |
+
"valid_storage",
|
| 347 |
+
"depth_origin"
|
| 348 |
+
],
|
| 349 |
+
"depth_origin_values": [
|
| 350 |
+
"measured",
|
| 351 |
+
"rendered",
|
| 352 |
+
"unknown"
|
| 353 |
+
]
|
| 354 |
+
},
|
| 355 |
+
"transform/se3/v1": {
|
| 356 |
+
"storage": "pt",
|
| 357 |
+
"dtype": "float32",
|
| 358 |
+
"shape": [
|
| 359 |
+
"T",
|
| 360 |
+
4,
|
| 361 |
+
4
|
| 362 |
+
],
|
| 363 |
+
"valid_shape": [
|
| 364 |
+
"T"
|
| 365 |
+
],
|
| 366 |
+
"unit": "m",
|
| 367 |
+
"required_metadata": [
|
| 368 |
+
"convention"
|
| 369 |
+
]
|
| 370 |
+
},
|
| 371 |
+
"object/rigid/v1": {
|
| 372 |
+
"storage": "pt",
|
| 373 |
+
"dtype": "float32",
|
| 374 |
+
"shape": [
|
| 375 |
+
"T",
|
| 376 |
+
4,
|
| 377 |
+
4
|
| 378 |
+
],
|
| 379 |
+
"valid_shape": [
|
| 380 |
+
"T"
|
| 381 |
+
],
|
| 382 |
+
"unit": "m",
|
| 383 |
+
"required_metadata": [
|
| 384 |
+
"convention"
|
| 385 |
+
]
|
| 386 |
+
},
|
| 387 |
+
"camera/pinhole/v1": {
|
| 388 |
+
"storage": "pt",
|
| 389 |
+
"dtype": "float32",
|
| 390 |
+
"shape": [
|
| 391 |
+
"T",
|
| 392 |
+
3,
|
| 393 |
+
3
|
| 394 |
+
],
|
| 395 |
+
"valid_shape": [
|
| 396 |
+
"T"
|
| 397 |
+
]
|
| 398 |
+
},
|
| 399 |
+
"camera/rational8/v1": {
|
| 400 |
+
"storage": "pt",
|
| 401 |
+
"dtype": "float32",
|
| 402 |
+
"shape": [
|
| 403 |
+
"T",
|
| 404 |
+
3,
|
| 405 |
+
3
|
| 406 |
+
],
|
| 407 |
+
"valid_shape": [
|
| 408 |
+
"T"
|
| 409 |
+
]
|
| 410 |
+
},
|
| 411 |
+
"camera/opencv_fisheye4/v1": {
|
| 412 |
+
"storage": "pt",
|
| 413 |
+
"dtype": "float32",
|
| 414 |
+
"shape": [
|
| 415 |
+
"T",
|
| 416 |
+
3,
|
| 417 |
+
3
|
| 418 |
+
],
|
| 419 |
+
"valid_shape": [
|
| 420 |
+
"T"
|
| 421 |
+
]
|
| 422 |
+
},
|
| 423 |
+
"camera/fisheye624/v1": {
|
| 424 |
+
"storage": "pt",
|
| 425 |
+
"dtype": "float32",
|
| 426 |
+
"shape": [
|
| 427 |
+
"T",
|
| 428 |
+
15
|
| 429 |
+
],
|
| 430 |
+
"valid_shape": [
|
| 431 |
+
"T"
|
| 432 |
+
]
|
| 433 |
+
},
|
| 434 |
+
"camera/distortion8/v1": {
|
| 435 |
+
"storage": "pt",
|
| 436 |
+
"dtype": "float32",
|
| 437 |
+
"shape": [
|
| 438 |
+
"T",
|
| 439 |
+
8
|
| 440 |
+
],
|
| 441 |
+
"valid_shape": [
|
| 442 |
+
"T"
|
| 443 |
+
]
|
| 444 |
+
},
|
| 445 |
+
"camera/fisheye4_distortion/v1": {
|
| 446 |
+
"storage": "pt",
|
| 447 |
+
"dtype": "float32",
|
| 448 |
+
"shape": [
|
| 449 |
+
"T",
|
| 450 |
+
4
|
| 451 |
+
],
|
| 452 |
+
"valid_shape": [
|
| 453 |
+
"T"
|
| 454 |
+
]
|
| 455 |
+
},
|
| 456 |
+
"object/joint_state/v1": {
|
| 457 |
+
"storage": "pt",
|
| 458 |
+
"dtype": "float32",
|
| 459 |
+
"shape": [
|
| 460 |
+
"T",
|
| 461 |
+
"J"
|
| 462 |
+
],
|
| 463 |
+
"valid_shape": [
|
| 464 |
+
"T",
|
| 465 |
+
"J"
|
| 466 |
+
],
|
| 467 |
+
"required_metadata": [
|
| 468 |
+
"joint_order"
|
| 469 |
+
],
|
| 470 |
+
"unit_rule": "revolute radians; prismatic metres; mixed types declared per joint"
|
| 471 |
+
},
|
| 472 |
+
"object_keypoints/camera/v1": {
|
| 473 |
+
"storage": "pt",
|
| 474 |
+
"dtype": "float32",
|
| 475 |
+
"shape": [
|
| 476 |
+
"T",
|
| 477 |
+
"K",
|
| 478 |
+
3
|
| 479 |
+
],
|
| 480 |
+
"valid_shape": [
|
| 481 |
+
"T",
|
| 482 |
+
"K"
|
| 483 |
+
],
|
| 484 |
+
"unit": "m",
|
| 485 |
+
"coordinate_frame": "camera",
|
| 486 |
+
"required_metadata": [
|
| 487 |
+
"keypoint_schema"
|
| 488 |
+
]
|
| 489 |
+
},
|
| 490 |
+
"object/dimensions/v1": {
|
| 491 |
+
"storage": "pt",
|
| 492 |
+
"dtype": "float32",
|
| 493 |
+
"shape": [
|
| 494 |
+
"T",
|
| 495 |
+
3
|
| 496 |
+
],
|
| 497 |
+
"valid_shape": [
|
| 498 |
+
"T"
|
| 499 |
+
],
|
| 500 |
+
"unit": "m",
|
| 501 |
+
"required_metadata": [
|
| 502 |
+
"dimensions_semantics"
|
| 503 |
+
],
|
| 504 |
+
"axis_order": [
|
| 505 |
+
"length",
|
| 506 |
+
"width",
|
| 507 |
+
"height"
|
| 508 |
+
],
|
| 509 |
+
"scale_rule": "do not apply to mesh without source-supported size/scale relation"
|
| 510 |
+
},
|
| 511 |
+
"object_keypoints/template/v1": {
|
| 512 |
+
"storage": "pt",
|
| 513 |
+
"dtype": "float32",
|
| 514 |
+
"shape": [
|
| 515 |
+
"K",
|
| 516 |
+
3
|
| 517 |
+
],
|
| 518 |
+
"valid_shape": [
|
| 519 |
+
"K"
|
| 520 |
+
],
|
| 521 |
+
"unit": "m",
|
| 522 |
+
"coordinate_frame": "object",
|
| 523 |
+
"static": true,
|
| 524 |
+
"required_metadata": [
|
| 525 |
+
"keypoint_schema"
|
| 526 |
+
]
|
| 527 |
+
},
|
| 528 |
+
"mesh/obj/v1": {
|
| 529 |
+
"storage": "obj",
|
| 530 |
+
"unit": "m",
|
| 531 |
+
"static": true,
|
| 532 |
+
"valid_shape": [],
|
| 533 |
+
"dependencies": "MTL and textures retained under owning object"
|
| 534 |
+
},
|
| 535 |
+
"rgb/uint8/v1": {
|
| 536 |
+
"storage": "mkv",
|
| 537 |
+
"dtype": "uint8",
|
| 538 |
+
"shape": [
|
| 539 |
+
"T",
|
| 540 |
+
"H",
|
| 541 |
+
"W",
|
| 542 |
+
3
|
| 543 |
+
],
|
| 544 |
+
"valid_shape": [
|
| 545 |
+
"T"
|
| 546 |
+
],
|
| 547 |
+
"color_order": "RGB",
|
| 548 |
+
"allowed_storage_profiles": [
|
| 549 |
+
"mkv/mjpeg_copy/v1",
|
| 550 |
+
"mkv/source_copy/v1",
|
| 551 |
+
"mkv/h264_rgb_lossless/v1",
|
| 552 |
+
"mkv/ffv1_rgb/v1"
|
| 553 |
+
],
|
| 554 |
+
"required_metadata": [
|
| 555 |
+
"storage"
|
| 556 |
+
]
|
| 557 |
+
},
|
| 558 |
+
"contact/relations/v1": {
|
| 559 |
+
"storage": "jsonl",
|
| 560 |
+
"valid_shape": [
|
| 561 |
+
"T"
|
| 562 |
+
],
|
| 563 |
+
"frame_keys": [
|
| 564 |
+
"frame_index",
|
| 565 |
+
"relations"
|
| 566 |
+
],
|
| 567 |
+
"absence_semantics": "no record is not a negative contact annotation"
|
| 568 |
+
},
|
| 569 |
+
"contact/vertex_region/v1": {
|
| 570 |
+
"storage": "pt",
|
| 571 |
+
"dtype": "bool",
|
| 572 |
+
"shape": [
|
| 573 |
+
"T",
|
| 574 |
+
"V"
|
| 575 |
+
],
|
| 576 |
+
"valid_shape": [
|
| 577 |
+
"T",
|
| 578 |
+
"V"
|
| 579 |
+
],
|
| 580 |
+
"required_metadata": [
|
| 581 |
+
"source_geometry_ref",
|
| 582 |
+
"target_geometry_ref",
|
| 583 |
+
"topology_id"
|
| 584 |
+
],
|
| 585 |
+
"pilot_status": "defined_not_empirically_validated"
|
| 586 |
+
},
|
| 587 |
+
"contact/vertex_distance/v1": {
|
| 588 |
+
"storage": "pt",
|
| 589 |
+
"dtype": "float32",
|
| 590 |
+
"shape": [
|
| 591 |
+
"T",
|
| 592 |
+
"V"
|
| 593 |
+
],
|
| 594 |
+
"valid_shape": [
|
| 595 |
+
"T",
|
| 596 |
+
"V"
|
| 597 |
+
],
|
| 598 |
+
"unit": "m",
|
| 599 |
+
"required_metadata": [
|
| 600 |
+
"source_geometry_ref",
|
| 601 |
+
"target_geometry_ref",
|
| 602 |
+
"topology_id",
|
| 603 |
+
"distance_definition"
|
| 604 |
+
],
|
| 605 |
+
"pilot_status": "defined_not_empirically_validated"
|
| 606 |
+
},
|
| 607 |
+
"object/articulated/v1": {
|
| 608 |
+
"storage": "json",
|
| 609 |
+
"required_keys": [
|
| 610 |
+
"parts",
|
| 611 |
+
"joints"
|
| 612 |
+
],
|
| 613 |
+
"part_keys": [
|
| 614 |
+
"part_id",
|
| 615 |
+
"parent_id",
|
| 616 |
+
"has_model",
|
| 617 |
+
"mesh_ref"
|
| 618 |
+
],
|
| 619 |
+
"hierarchy_semantics": "declare mechanical articulation or semantic containment; containment alone does not imply joints",
|
| 620 |
+
"acyclic": true
|
| 621 |
+
},
|
| 622 |
+
"segment/uint16_labels/v1": {
|
| 623 |
+
"storage": "mkv",
|
| 624 |
+
"dtype": "uint16",
|
| 625 |
+
"mapping": "instances.jsonl",
|
| 626 |
+
"valid_shape": [
|
| 627 |
+
"T"
|
| 628 |
+
],
|
| 629 |
+
"required_metadata": [
|
| 630 |
+
"segmentation_type",
|
| 631 |
+
"coverage",
|
| 632 |
+
"mapping_ref",
|
| 633 |
+
"storage"
|
| 634 |
+
],
|
| 635 |
+
"shape": [
|
| 636 |
+
"T",
|
| 637 |
+
"H",
|
| 638 |
+
"W"
|
| 639 |
+
],
|
| 640 |
+
"reserved_codes": {
|
| 641 |
+
"0": "unassigned",
|
| 642 |
+
"65535": "ignore"
|
| 643 |
+
},
|
| 644 |
+
"region_codes": [
|
| 645 |
+
1,
|
| 646 |
+
65534
|
| 647 |
+
],
|
| 648 |
+
"allowed_storage_profiles": [
|
| 649 |
+
"mkv/uint16_ffv1/v1"
|
| 650 |
+
]
|
| 651 |
+
},
|
| 652 |
+
"segment/instance_polygons/v1": {
|
| 653 |
+
"storage": "jsonl",
|
| 654 |
+
"mapping": "instances.jsonl",
|
| 655 |
+
"frame_keys": [
|
| 656 |
+
"frame_index",
|
| 657 |
+
"instances"
|
| 658 |
+
],
|
| 659 |
+
"instance_keys": [
|
| 660 |
+
"mask_value",
|
| 661 |
+
"polygons"
|
| 662 |
+
],
|
| 663 |
+
"coordinate_unit": "pixel",
|
| 664 |
+
"overlap_allowed": true,
|
| 665 |
+
"valid_shape": [
|
| 666 |
+
"T"
|
| 667 |
+
],
|
| 668 |
+
"required_metadata": [
|
| 669 |
+
"segmentation_type",
|
| 670 |
+
"coverage",
|
| 671 |
+
"mapping_ref"
|
| 672 |
+
],
|
| 673 |
+
"polygon_shape": [
|
| 674 |
+
"N",
|
| 675 |
+
2
|
| 676 |
+
],
|
| 677 |
+
"holes_supported": false
|
| 678 |
+
},
|
| 679 |
+
"segment/foreground_intensity/v1": {
|
| 680 |
+
"storage": "mkv",
|
| 681 |
+
"dtype": "uint16",
|
| 682 |
+
"value_range": [
|
| 683 |
+
0,
|
| 684 |
+
255
|
| 685 |
+
],
|
| 686 |
+
"normalization_scale": 0.00392156862745098,
|
| 687 |
+
"axes": [
|
| 688 |
+
"T",
|
| 689 |
+
"height",
|
| 690 |
+
"width"
|
| 691 |
+
],
|
| 692 |
+
"meaning": "native hand foreground intensity; individual hand or union declared in metadata; not instance codes or calibrated probability",
|
| 693 |
+
"zero": "background",
|
| 694 |
+
"full_scale": "foreground",
|
| 695 |
+
"mapping": "foreground_category in component metadata",
|
| 696 |
+
"valid_shape": [
|
| 697 |
+
"T"
|
| 698 |
+
],
|
| 699 |
+
"required_metadata": [
|
| 700 |
+
"segmentation_type",
|
| 701 |
+
"coverage",
|
| 702 |
+
"value_range",
|
| 703 |
+
"normalization_scale",
|
| 704 |
+
"foreground_category",
|
| 705 |
+
"entity_id",
|
| 706 |
+
"storage"
|
| 707 |
+
],
|
| 708 |
+
"shape": [
|
| 709 |
+
"T",
|
| 710 |
+
"H",
|
| 711 |
+
"W"
|
| 712 |
+
],
|
| 713 |
+
"allowed_storage_profiles": [
|
| 714 |
+
"mkv/uint16_ffv1/v1"
|
| 715 |
+
]
|
| 716 |
+
}
|
| 717 |
+
},
|
| 718 |
+
"storage_revision": "lossless-video-2026-09-18",
|
| 719 |
+
"sampling": {
|
| 720 |
+
"image": {
|
| 721 |
+
"single": {
|
| 722 |
+
"T": 1
|
| 723 |
+
},
|
| 724 |
+
"independent": {
|
| 725 |
+
"T": ">=2",
|
| 726 |
+
"required_frame_fields": [
|
| 727 |
+
"sample_id",
|
| 728 |
+
"source_locator"
|
| 729 |
+
],
|
| 730 |
+
"temporal_relationship": false
|
| 731 |
+
},
|
| 732 |
+
"source_fps": null
|
| 733 |
+
},
|
| 734 |
+
"video": {
|
| 735 |
+
"sampling_types": [
|
| 736 |
+
"dense",
|
| 737 |
+
"sparse"
|
| 738 |
+
]
|
| 739 |
+
}
|
| 740 |
+
},
|
| 741 |
+
"storage_profiles": {
|
| 742 |
+
"mkv/mjpeg_copy/v1": {
|
| 743 |
+
"container": "matroska",
|
| 744 |
+
"codec": "mjpeg",
|
| 745 |
+
"method": "stream_copy_from_source_jpeg",
|
| 746 |
+
"logical_dtype": "uint8",
|
| 747 |
+
"decoded_pixel_format": "rgb24",
|
| 748 |
+
"validation": [
|
| 749 |
+
"source_jpeg_packet_sha256_exact",
|
| 750 |
+
"all_packet_count_order_and_dimensions_exact",
|
| 751 |
+
"deterministic_decoded_rgb_sample_exact",
|
| 752 |
+
"pilot_and_final_selected_whole_sequences_decoded_rgb_exact"
|
| 753 |
+
],
|
| 754 |
+
"validation_policy": {
|
| 755 |
+
"id": "jpeg-packets-all-rgb-sample16/v1",
|
| 756 |
+
"sample_count_per_view": 16,
|
| 757 |
+
"short_views": "all_frames_if_T_less_than_16",
|
| 758 |
+
"fixed_indices": "0,T-1,T//4,T//2,3*T//4, deduplicated",
|
| 759 |
+
"remaining_indices": "sample without replacement to min(T,16) using Python random.Random(seed)",
|
| 760 |
+
"seed": "first 8 bytes of SHA256(sequence_id/camera_id/20260920), big-endian integer",
|
| 761 |
+
"report": "policy, exact selected frame indices, seed, separate packet and pixel coverage",
|
| 762 |
+
"legacy_all_frame_pixel_proofs": "still accepted; preserve historical evidence"
|
| 763 |
+
}
|
| 764 |
+
},
|
| 765 |
+
"mkv/source_copy/v1": {
|
| 766 |
+
"container": "matroska",
|
| 767 |
+
"codec": "source_codec_declared_in_metadata",
|
| 768 |
+
"method": "stream_copy_only",
|
| 769 |
+
"logical_dtype": "uint8",
|
| 770 |
+
"decoded_pixel_format": "rgb24",
|
| 771 |
+
"validation": [
|
| 772 |
+
"no_reencoding",
|
| 773 |
+
"all_decoded_rgb_frames_exact",
|
| 774 |
+
"presentation_frame_order_exact"
|
| 775 |
+
]
|
| 776 |
+
},
|
| 777 |
+
"mkv/h264_rgb_lossless/v1": {
|
| 778 |
+
"container": "matroska",
|
| 779 |
+
"codec": "h264",
|
| 780 |
+
"encoder": "libx264rgb",
|
| 781 |
+
"crf": 0,
|
| 782 |
+
"decoded_pixel_format": "rgb24",
|
| 783 |
+
"logical_dtype": "uint8",
|
| 784 |
+
"gop": "declared_in_encoder_parameters",
|
| 785 |
+
"validation": [
|
| 786 |
+
"all_decoded_rgb_frames_exact"
|
| 787 |
+
],
|
| 788 |
+
"forbidden": [
|
| 789 |
+
"lossy_rate_control",
|
| 790 |
+
"rgb_to_yuv420_subsampling"
|
| 791 |
+
]
|
| 792 |
+
},
|
| 793 |
+
"mkv/ffv1_rgb/v1": {
|
| 794 |
+
"container": "matroska",
|
| 795 |
+
"codec": "ffv1",
|
| 796 |
+
"decoded_pixel_format": "rgb24",
|
| 797 |
+
"logical_dtype": "uint8",
|
| 798 |
+
"validation": [
|
| 799 |
+
"all_decoded_rgb_frames_exact"
|
| 800 |
+
]
|
| 801 |
+
},
|
| 802 |
+
"mkv/depth_float32_bits/v1": {
|
| 803 |
+
"container": "matroska",
|
| 804 |
+
"codec": "ffv1",
|
| 805 |
+
"pixel_format": "gray16le",
|
| 806 |
+
"logical_dtype": "float32",
|
| 807 |
+
"logical_shape": [
|
| 808 |
+
"T",
|
| 809 |
+
"H",
|
| 810 |
+
"W"
|
| 811 |
+
],
|
| 812 |
+
"encoded_shape": [
|
| 813 |
+
"T",
|
| 814 |
+
"H",
|
| 815 |
+
"2*W"
|
| 816 |
+
],
|
| 817 |
+
"packing": "IEEE754 little-endian float32 bits; low uint16 in first W columns, high uint16 in last W columns",
|
| 818 |
+
"decode": "reinterpret_float32(uint32(low) | (uint32(high) << 16))",
|
| 819 |
+
"validation": [
|
| 820 |
+
"all_float32_bits_exact_including_nan"
|
| 821 |
+
]
|
| 822 |
+
},
|
| 823 |
+
"mkv/bool_ffv1/v1": {
|
| 824 |
+
"container": "matroska",
|
| 825 |
+
"codec": "ffv1",
|
| 826 |
+
"pixel_format": "gray",
|
| 827 |
+
"logical_dtype": "bool",
|
| 828 |
+
"stored_values": [
|
| 829 |
+
0,
|
| 830 |
+
1
|
| 831 |
+
],
|
| 832 |
+
"validation": [
|
| 833 |
+
"all_bool_values_exact"
|
| 834 |
+
]
|
| 835 |
+
},
|
| 836 |
+
"mkv/uint16_ffv1/v1": {
|
| 837 |
+
"container": "matroska",
|
| 838 |
+
"codec": "ffv1",
|
| 839 |
+
"pixel_formats": [
|
| 840 |
+
"gray",
|
| 841 |
+
"gray16le"
|
| 842 |
+
],
|
| 843 |
+
"logical_dtype": "uint16",
|
| 844 |
+
"gray_condition": "all values <=255; decode by exact uint8-to-uint16 promotion",
|
| 845 |
+
"validation": [
|
| 846 |
+
"all_integer_values_exact"
|
| 847 |
+
]
|
| 848 |
+
}
|
| 849 |
+
},
|
| 850 |
+
"video_metadata": {
|
| 851 |
+
"required": [
|
| 852 |
+
"profile",
|
| 853 |
+
"codec",
|
| 854 |
+
"pixel_format",
|
| 855 |
+
"encoded_size",
|
| 856 |
+
"decoder",
|
| 857 |
+
"encoder_parameters",
|
| 858 |
+
"source_lossy"
|
| 859 |
+
],
|
| 860 |
+
"source_lossy_values": [
|
| 861 |
+
true,
|
| 862 |
+
false,
|
| 863 |
+
"unknown"
|
| 864 |
+
],
|
| 865 |
+
"timebase_role": "index_only",
|
| 866 |
+
"lossless_reference": "source compressed packets or fixed-decoder source pixels; depth uses normalized standard float32 bits",
|
| 867 |
+
"selection": "choose smaller complete candidate only after exact roundtrip validation"
|
| 868 |
+
}
|
| 869 |
+
}
|
H2O/shared-v1.1/script/v1_0_snapshot/script/check_dexycb_projection.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Check saved Dex-YCB source 3D joints against saved source 2D joints in sampled views."""
|
| 3 |
+
import json
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
import sys
|
| 6 |
+
|
| 7 |
+
import numpy as np
|
| 8 |
+
import torch
|
| 9 |
+
|
| 10 |
+
root = Path(sys.argv[1])
|
| 11 |
+
report = json.loads((root / 'doc/validation/STRUCTURAL_AUDIT.json').read_text())
|
| 12 |
+
checks = []
|
| 13 |
+
for name in report['sampled_views']:
|
| 14 |
+
view = root / name
|
| 15 |
+
load = lambda path: torch.load(view / path, weights_only=True, map_location='cpu').numpy()
|
| 16 |
+
k = load('camera/intrinsic.pt')
|
| 17 |
+
xyz = load('annotation/keypoints/xyz.pt')
|
| 18 |
+
uv = load('annotation/keypoints/uv.pt')
|
| 19 |
+
valid = load('annotation/keypoints/xyz_valid.pt') & load('annotation/keypoints/uv_valid.pt')
|
| 20 |
+
z = xyz[..., 2]
|
| 21 |
+
valid &= np.isfinite(xyz).all(axis=-1) & np.isfinite(uv).all(axis=-1) & (z > 0)
|
| 22 |
+
z = np.where(valid, z, 1)
|
| 23 |
+
pred = np.stack((k[:, 0, 0, None, None] * xyz[..., 0] / z + k[:, 0, 2, None, None],
|
| 24 |
+
k[:, 1, 1, None, None] * xyz[..., 1] / z + k[:, 1, 2, None, None]), axis=-1)
|
| 25 |
+
errors = np.linalg.norm(pred[valid] - uv[valid], axis=-1)
|
| 26 |
+
checks.append(dict(view=name, points=int(errors.size), median_px=float(np.median(errors)) if errors.size else None,
|
| 27 |
+
p95_px=float(np.percentile(errors, 95)) if errors.size else None))
|
| 28 |
+
(root / 'doc/validation/KEYPOINT_PROJECTION_QC.json').write_text(json.dumps({
|
| 29 |
+
'scope': 'Saved source 3D joints projected with saved color intrinsics vs saved source 2D joints; independent of hand mesh rendering.',
|
| 30 |
+
'views': checks}, ensure_ascii=False, indent=2) + '\n')
|
| 31 |
+
print(json.dumps(checks, ensure_ascii=False), flush=True)
|
H2O/shared-v1.1/script/v1_0_snapshot/script/config.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"root": "/home/xuzhefeng/Datasets/Hand-Datasets-Raw/H2O",
|
| 3 |
+
"out": "/home/xuzhefeng/Datasets/uni-hoi-h2o-full-20260930-process16-pipe",
|
| 4 |
+
"release_id": "shared-v1.0",
|
| 5 |
+
"limit": null,
|
| 6 |
+
"max_frames": null,
|
| 7 |
+
"mano_dir": "/home/xuzhefeng/Projects/WiLoR/mano_data",
|
| 8 |
+
"views": null,
|
| 9 |
+
"jpeg_full_check": false,
|
| 10 |
+
"workers": 4,
|
| 11 |
+
"view_backend": "processes",
|
| 12 |
+
"camera_pipeline": true,
|
| 13 |
+
"ffv1_slices": 16,
|
| 14 |
+
"view_workers": 16,
|
| 15 |
+
"ram_stage_dir": "/dev/shm/xuzhefeng-h2o-full-process16-20260930",
|
| 16 |
+
"ram_stage_gib": 32,
|
| 17 |
+
"stream_media": true,
|
| 18 |
+
"codec_threads": 10,
|
| 19 |
+
"decode_threads": 10,
|
| 20 |
+
"depth_threads": 4,
|
| 21 |
+
"subjects": null,
|
| 22 |
+
"include_casa": false,
|
| 23 |
+
"archive": null
|
| 24 |
+
}
|
H2O/shared-v1.1/script/v1_0_snapshot/script/convert_dexycb_v1.0.py
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Dex-YCB source annotations → CONTRACT.md v1.0. No derived annotations."""
|
| 3 |
+
import io
|
| 4 |
+
import re
|
| 5 |
+
import shutil
|
| 6 |
+
import tarfile
|
| 7 |
+
import tempfile
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
|
| 10 |
+
import numpy as np
|
| 11 |
+
from PIL import Image
|
| 12 |
+
import yaml
|
| 13 |
+
|
| 14 |
+
from warehouse_v1_0 import (View, build_record, find_file, locator, mano_models, mesh_asset,
|
| 15 |
+
model_profile, parser, pca_to_axis_angle, release, roots, safe_member, sequence_dir)
|
| 16 |
+
|
| 17 |
+
IMG_W, IMG_H = 640, 480
|
| 18 |
+
|
| 19 |
+
class _Loader(yaml.SafeLoader):
|
| 20 |
+
pass
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
_Loader.add_constructor("tag:yaml.org,2002:python/tuple",
|
| 24 |
+
lambda l, n: tuple(l.construct_sequence(n)))
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def yaml_load_bytes(data: bytes):
|
| 28 |
+
return yaml.load(io.BytesIO(data), Loader=_Loader)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
class Calibration:
|
| 32 |
+
def __init__(self, dexycb_root: Path):
|
| 33 |
+
self.intrinsics = {} # serial -> {fx,fy,cx,cy,w,h}
|
| 34 |
+
self.extrinsics = {} # group -> {serial: [12] 行优先 3×4 cam→world}
|
| 35 |
+
self.betas = {} # mano_calib_name -> [10]
|
| 36 |
+
calib_dir = dexycb_root / "calibration"
|
| 37 |
+
if calib_dir.is_dir():
|
| 38 |
+
self._load((p.as_posix(), p.read_bytes())
|
| 39 |
+
for p in sorted(calib_dir.rglob("*")) if p.is_file())
|
| 40 |
+
else:
|
| 41 |
+
tar_path = dexycb_root / "calibration.tar.gz"
|
| 42 |
+
if not tar_path.exists():
|
| 43 |
+
raise FileNotFoundError(f"no calibration/ nor calibration.tar.gz in {dexycb_root}")
|
| 44 |
+
with tarfile.open(tar_path, "r:gz") as tf:
|
| 45 |
+
self._load((m.name, tf.extractfile(m).read()) for m in tf if m.isfile())
|
| 46 |
+
|
| 47 |
+
_RE_INTR = re.compile(r"(?:^|/)intrinsics/(\d+)_\d+x\d+\.yml$")
|
| 48 |
+
_RE_EXTRA = re.compile(r"(?:^|/)extrinsics_(\d{8}_\d{6})/extrinsics\.yml$")
|
| 49 |
+
_RE_MANO = re.compile(r"(?:^|/)mano_(\d{8}_\d{6}_subject-\d{2}_right)/mano\.yml$")
|
| 50 |
+
|
| 51 |
+
def _load(self, files):
|
| 52 |
+
for rel, data in files:
|
| 53 |
+
m = self._RE_INTR.search(rel)
|
| 54 |
+
if m:
|
| 55 |
+
c = yaml_load_bytes(data)["color"]
|
| 56 |
+
self.intrinsics[m.group(1)] = {"fx": float(c["fx"]), "fy": float(c["fy"]),
|
| 57 |
+
"cx": float(c["ppx"]), "cy": float(c["ppy"]),
|
| 58 |
+
"w": IMG_W, "h": IMG_H}
|
| 59 |
+
continue
|
| 60 |
+
m = self._RE_EXTRA.search(rel)
|
| 61 |
+
if m:
|
| 62 |
+
raw = yaml_load_bytes(data)["extrinsics"]
|
| 63 |
+
self.extrinsics[m.group(1)] = {
|
| 64 |
+
str(s): [float(x) for x in np.asarray(v).ravel()] for s, v in raw.items()}
|
| 65 |
+
continue
|
| 66 |
+
m = self._RE_MANO.search(rel)
|
| 67 |
+
if m:
|
| 68 |
+
self.betas[m.group(1)] = [float(b) for b in yaml_load_bytes(data)["betas"]]
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
def calibration_locator(path, member, **extra):
|
| 73 |
+
if path.is_dir():
|
| 74 |
+
return locator(path / member.removeprefix('calibration/'), **extra)
|
| 75 |
+
return locator(path, member, **extra)
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def prepare_models(root, destination):
|
| 79 |
+
archive = find_file(root, 'models.tar.gz')
|
| 80 |
+
if archive is None:
|
| 81 |
+
return {}, None
|
| 82 |
+
pattern = re.compile(r'^models/(\d{3}_[a-z0-9_]+)/(textured_simple\.obj(?:\.mtl)?|texture_map\.png)$')
|
| 83 |
+
names = set()
|
| 84 |
+
with tarfile.open(archive, 'r|gz') as tf:
|
| 85 |
+
for member in tf:
|
| 86 |
+
match = pattern.fullmatch(member.name)
|
| 87 |
+
if member.isfile() and match:
|
| 88 |
+
names.add(match[1])
|
| 89 |
+
path = safe_member(destination, '/'.join(match.groups()))
|
| 90 |
+
path.parent.mkdir(parents=True, exist_ok=True)
|
| 91 |
+
path.write_bytes(tf.extractfile(member).read())
|
| 92 |
+
if len(names) != 21:
|
| 93 |
+
raise ValueError('expected all 21 source YCB model directories')
|
| 94 |
+
return {i: destination / name for i, name in enumerate(sorted(names), 1)}, archive
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
def convert_view(path, args, seq, serial, frames, meta, meta_loc, calib, calib_path, models, assets, asset_archive):
|
| 98 |
+
total = int(meta.get('num_frames', max(frames) + 1))
|
| 99 |
+
ids = list(range(min(total, args.max_frames) if args.max_frames else total))
|
| 100 |
+
for f in ids:
|
| 101 |
+
frames.setdefault(f, {})
|
| 102 |
+
if not ids:
|
| 103 |
+
raise ValueError('no RGB frames')
|
| 104 |
+
source_rows = []
|
| 105 |
+
for f in ids:
|
| 106 |
+
row = frames[f]
|
| 107 |
+
source_rows.append(dict(source_frame_id=f, sync_id=f'{seq}:{f}',
|
| 108 |
+
source_locator=row['color'][1] if 'color' in row else (meta_loc | {'source_frame_id': f, 'missing_rgb': True}), annotation_matches={
|
| 109 |
+
'labels': {'source_frame_id': f, 'source_timestamp_ns': None, 'clock_domain': None,
|
| 110 |
+
'match_method': 'index_map', 'delta_ns': None, 'source_locator': row['labels'][1]}
|
| 111 |
+
for _ in [0] if 'labels' in row},
|
| 112 |
+
component_sources={k: v[1] for k, v in row.items()}))
|
| 113 |
+
view = View(path, 'dex-ycb', args.release_id, seq, serial, source_rows,
|
| 114 |
+
sampling='dense' if ids == list(range(ids[0], ids[-1] + 1)) else 'sparse')
|
| 115 |
+
view.valid_rules = {
|
| 116 |
+
'mano': 'Source pose_m present and not all zero; side model/calibration available',
|
| 117 |
+
'keypoints': 'Corresponding joint_2d/joint_3d present; whole-hand all -1 is missing, broadcast to its 21 points',
|
| 118 |
+
'pose': 'Source pose_y for this ycb_ids slot present and not an all-zero matrix',
|
| 119 |
+
'segment': 'Source seg array provided for this frame; region codes and entity references validated',
|
| 120 |
+
'relations': 'Source sequence ycb_grasp_ind resolves through ycb_ids; broadcast sequence grasp to selected frames',
|
| 121 |
+
}
|
| 122 |
+
view.full_jpeg = getattr(args, 'jpeg_full_check', False)
|
| 123 |
+
view.meta['view_type'] = 'exo'
|
| 124 |
+
view.meta['sampling']['selection'] = {'max_frames': args.max_frames, 'views': args.views}
|
| 125 |
+
subject = re.search(r'subject-(\d+)', seq)
|
| 126 |
+
if subject and 1 <= int(subject[1]) <= 10:
|
| 127 |
+
index = int(subject[1])
|
| 128 |
+
view.meta.update(split='val' if index == 7 else 'test' if index in (8, 9) else 'train',
|
| 129 |
+
split_scheme='Dex-YCB/s1', split_source_locator={
|
| 130 |
+
'url': 'https://github.com/NVlabs/dex-ycb-toolkit/blob/master/dex_ycb_toolkit/dex_ycb.py',
|
| 131 |
+
'rule': 's1 unseen-subject: 01-06/10 train, 07 val, 08-09 test'})
|
| 132 |
+
view.meta.pop('split_reason', None)
|
| 133 |
+
view.rgb([frames[f]['color'][0] if 'color' in frames[f] else None for f in ids], {'frames_ref': 'camera/frames.jsonl'})
|
| 134 |
+
n = len(ids)
|
| 135 |
+
intr = calib.intrinsics.get(serial)
|
| 136 |
+
K = None if intr is None else np.array([[intr['fx'], 0, intr['cx']], [0, intr['fy'], intr['cy']], [0, 0, 1]])
|
| 137 |
+
ext = calib.extrinsics.get(str(meta['extrinsics']), {}).get(serial)
|
| 138 |
+
E = None
|
| 139 |
+
if ext is not None:
|
| 140 |
+
E = np.eye(4)
|
| 141 |
+
E[:3] = np.asarray(ext).reshape(3, 4)
|
| 142 |
+
E = np.linalg.inv(E)
|
| 143 |
+
view.camera(K, calibration_locator(calib_path, f'calibration/intrinsics/{serial}_640x480.yml'), E,
|
| 144 |
+
calibration_locator(calib_path, f'calibration/extrinsics_{meta["extrinsics"]}/extrinsics.yml',
|
| 145 |
+
conversion='inverse of source T_world_from_camera'))
|
| 146 |
+
sides = meta.get('mano_sides')
|
| 147 |
+
if sides not in (['left'], ['right']):
|
| 148 |
+
raise ValueError(f'expected exactly one anatomical source hand: {sides}')
|
| 149 |
+
side = sides[0]
|
| 150 |
+
slot = ['left', 'right'].index(side)
|
| 151 |
+
cal_name = meta['mano_calib'][0] if isinstance(meta['mano_calib'], list) else meta['mano_calib']
|
| 152 |
+
labels = [dict(np.load(frames[f]['labels'][0])) if 'labels' in frames[f] else {} for f in ids]
|
| 153 |
+
label_loc = {'frames_ref': 'camera/frames.jsonl', 'source_field': 'component_sources.labels'}
|
| 154 |
+
motion = np.full((n, 2, 61), np.nan, np.float32)
|
| 155 |
+
mv = np.zeros((n, 2), bool)
|
| 156 |
+
if side in models and any('pose_m' in lab for lab in labels):
|
| 157 |
+
for i, lab in enumerate(labels):
|
| 158 |
+
if 'pose_m' not in lab:
|
| 159 |
+
continue
|
| 160 |
+
pose = np.asarray(lab['pose_m']).reshape(51)
|
| 161 |
+
if not np.any(pose): # Official Dex-YCB missing-pose sentinel, independent of joints/seg.
|
| 162 |
+
continue
|
| 163 |
+
motion[i, slot] = np.r_[pose[:3], pca_to_axis_angle(pose[3:48], models[side]),
|
| 164 |
+
calib.betas[cal_name], pose[48:51]]
|
| 165 |
+
mv[i, slot] = True
|
| 166 |
+
view.tensor('mano', 'mano/axis_angle61/v1', 'annotation/mano/motion.pt', motion, mv,
|
| 167 |
+
['T', 'hand', 'parameter'], label_loc, model_profile=model_profile(models),
|
| 168 |
+
calibration_source=calibration_locator(calib_path, f'calibration/mano_{cal_name}/mano.yml'),
|
| 169 |
+
provenance={'kind': 'format_conversion', 'method': 'source PCA @ hands_components + hands_mean; explicit axis-angle consumed with flat_hand_mean=true'})
|
| 170 |
+
elif any('pose_m' in lab for lab in labels):
|
| 171 |
+
view.absent('mano', 'Source PCA exists; provide --mano-dir to expand it', 'dependency_missing')
|
| 172 |
+
else:
|
| 173 |
+
view.absent('mano', 'No source pose_m field')
|
| 174 |
+
for source_key, key, dim, unit in [('joint_2d', 'uv', 2, 'pixel'), ('joint_3d', 'xyz', 3, 'm')]:
|
| 175 |
+
if not any(source_key in x for x in labels):
|
| 176 |
+
view.absent('keypoints_' + key, 'No source ' + source_key)
|
| 177 |
+
continue
|
| 178 |
+
points = np.full((n, 2, 21, dim), np.nan, np.float32)
|
| 179 |
+
valid = np.zeros((n, 2, 21), bool)
|
| 180 |
+
for i, lab in enumerate(labels):
|
| 181 |
+
if source_key not in lab:
|
| 182 |
+
continue
|
| 183 |
+
p = np.asarray(lab[source_key]).reshape(21, dim)
|
| 184 |
+
points[i, slot] = p
|
| 185 |
+
valid[i, slot] = not np.all(p == -1) # Official sentinel covers the whole source hand.
|
| 186 |
+
# An individual off-image point (-1, -1) is not evidence of missing annotation.
|
| 187 |
+
view.tensor('keypoints_' + key, f'keypoints/{key}/v1', f'annotation/keypoints/{key}.pt',
|
| 188 |
+
points, valid, ['T', 'hand', 'keypoint', 'coordinate'], label_loc,
|
| 189 |
+
keypoint_schema='mano21/v1', unit=unit)
|
| 190 |
+
ycb_ids = [int(x) for x in meta['ycb_ids']]
|
| 191 |
+
for j, oid in enumerate(ycb_ids):
|
| 192 |
+
entity = f'ycb_{oid:02d}'
|
| 193 |
+
view.object(entity, meta_loc, source_object_id=oid, category_id=oid)
|
| 194 |
+
poses = np.full((n, 4, 4), np.nan, np.float32)
|
| 195 |
+
valid = np.zeros(n, bool)
|
| 196 |
+
for i, lab in enumerate(labels):
|
| 197 |
+
if 'pose_y' in lab:
|
| 198 |
+
pose = np.asarray(lab['pose_y'])
|
| 199 |
+
if pose.shape != (len(ycb_ids), 3, 4):
|
| 200 |
+
raise ValueError('pose_y shape differs from ycb_ids')
|
| 201 |
+
if np.any(pose[j]): # Official all-zero missing object pose sentinel.
|
| 202 |
+
poses[i] = np.eye(4)
|
| 203 |
+
poses[i, :3] = pose[j]
|
| 204 |
+
valid[i] = True
|
| 205 |
+
if any('pose_y' in lab for lab in labels):
|
| 206 |
+
view.tensor('pose_' + entity, 'object/rigid/v1', f'annotation/object/{entity}/pose.pt',
|
| 207 |
+
poses, valid, ['T', 'row', 'column'], label_loc,
|
| 208 |
+
convention='T_camera_from_object', unit='m')
|
| 209 |
+
else:
|
| 210 |
+
view.absent('pose_' + entity, 'No source pose_y field')
|
| 211 |
+
if oid in assets:
|
| 212 |
+
mesh_asset(view, entity, assets[oid], assets[oid] / 'textured_simple.obj',
|
| 213 |
+
locator(asset_archive, f'models/{assets[oid].name}/textured_simple.obj'))
|
| 214 |
+
else:
|
| 215 |
+
view.absent('mesh_' + entity, 'models.tar.gz unavailable', 'not_downloaded')
|
| 216 |
+
if any('seg' in lab for lab in labels):
|
| 217 |
+
mask_rows = []
|
| 218 |
+
width, height = view.meta['camera']['image_size']
|
| 219 |
+
for i, lab in enumerate(labels):
|
| 220 |
+
values = np.unique(lab.get('seg', np.zeros((height, width), np.uint8)))
|
| 221 |
+
mappings = []
|
| 222 |
+
for value in values:
|
| 223 |
+
value = int(value)
|
| 224 |
+
if value == 0:
|
| 225 |
+
continue
|
| 226 |
+
if value != 255 and value not in ycb_ids:
|
| 227 |
+
raise ValueError(f'unknown Dex-YCB region value {value}')
|
| 228 |
+
mappings.append(dict(mask_value=value, category_id='hand' if value == 255 else value,
|
| 229 |
+
entity_id='hand_' + side if value == 255 else f'ycb_{value:02d}', part_id=None,
|
| 230 |
+
source_instance_id=value))
|
| 231 |
+
mask_rows.append(dict(frame_index=i, labels=mappings))
|
| 232 |
+
view.raster('segment', (lab.get('seg', np.zeros((height, width), np.uint16)) for lab in labels),
|
| 233 |
+
['seg' in lab for lab in labels], label_loc, mask_rows)
|
| 234 |
+
view.meta['components']['segment'].update(coverage={'kind': 'selected_entities',
|
| 235 |
+
'entities': ['hand_' + side] + [f'ycb_{o:02d}' for o in ycb_ids]}, source_zero_meaning='background')
|
| 236 |
+
else:
|
| 237 |
+
view.absent('segment', 'No source seg field')
|
| 238 |
+
if any('aligned_depth_to_color' in frames[f] for f in ids):
|
| 239 |
+
def depths():
|
| 240 |
+
width, height = view.meta['camera']['image_size']
|
| 241 |
+
for f in ids:
|
| 242 |
+
item = frames[f].get('aligned_depth_to_color')
|
| 243 |
+
if item is None:
|
| 244 |
+
yield np.full((height, width), np.nan, np.float32)
|
| 245 |
+
else:
|
| 246 |
+
with Image.open(item[0]) as im:
|
| 247 |
+
yield np.asarray(im).astype(np.float32) / 1000.0
|
| 248 |
+
view.raster('depth', depths(), None, {'frames_ref': 'camera/frames.jsonl',
|
| 249 |
+
'source_field': 'component_sources.aligned_depth_to_color', 'conversion': 'millimetres to metres'})
|
| 250 |
+
else:
|
| 251 |
+
view.absent('depth', 'No source aligned_depth_to_color frames')
|
| 252 |
+
grasp = meta.get('ycb_grasp_ind')
|
| 253 |
+
if grasp is not None:
|
| 254 |
+
if not 0 <= int(grasp) < len(ycb_ids):
|
| 255 |
+
raise ValueError('invalid ycb_grasp_ind')
|
| 256 |
+
relation = dict(relation_type='grasp', subject_id='hand_' + side,
|
| 257 |
+
object_id=f'ycb_{ycb_ids[int(grasp)]:02d}', status='positive', source_locator=meta_loc,
|
| 258 |
+
provenance={'kind': 'source', 'method': 'sequence ycb_grasp_ind resolved through ycb_ids; not per-frame contact'})
|
| 259 |
+
view.relations([{'frame_index': i, 'relations': [relation]} for i in range(n)], np.ones(n, bool), meta_loc)
|
| 260 |
+
else:
|
| 261 |
+
view.absent('relations', 'No source grasp/contact relation')
|
| 262 |
+
return view.finish()
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
MEMBER = re.compile(r'^([^/]+)/(\d{8}_\d{6})/(meta\.yml|(\d{12})/(color|labels|aligned_depth_to_color)_(\d+)\.(jpg|npz|png))$')
|
| 266 |
+
|
| 267 |
+
|
| 268 |
+
def convert_archive(archive, args, out, calib, calib_path, models, assets, asset_archive):
|
| 269 |
+
selected_views = set(args.views.split(',')) if args.views else None
|
| 270 |
+
done = 0
|
| 271 |
+
current, meta, meta_loc, rows = None, None, None, {}
|
| 272 |
+
with tempfile.TemporaryDirectory(prefix='dex-source-') as wd:
|
| 273 |
+
work = Path(wd)
|
| 274 |
+
def flush():
|
| 275 |
+
nonlocal done
|
| 276 |
+
if not rows:
|
| 277 |
+
return
|
| 278 |
+
seq = archive.name.split('.tar')[0] + '_' + current
|
| 279 |
+
reports = {}
|
| 280 |
+
with sequence_dir(out, seq) as target:
|
| 281 |
+
for serial, frames in sorted(rows.items()):
|
| 282 |
+
reports[serial] = convert_view(target / serial, args, seq, serial, frames, meta,
|
| 283 |
+
meta_loc, calib, calib_path, models, assets, asset_archive)
|
| 284 |
+
build_record(out, seq, reports)
|
| 285 |
+
for staged in list(work.iterdir()):
|
| 286 |
+
if staged.is_dir():
|
| 287 |
+
shutil.rmtree(staged)
|
| 288 |
+
else:
|
| 289 |
+
staged.unlink()
|
| 290 |
+
done += 1
|
| 291 |
+
print(f'Converted {seq}', flush=True)
|
| 292 |
+
with tarfile.open(archive, 'r|gz') as tf:
|
| 293 |
+
for member in tf:
|
| 294 |
+
match = MEMBER.fullmatch(member.name)
|
| 295 |
+
if not member.isfile() or not match:
|
| 296 |
+
continue
|
| 297 |
+
seq = match[2]
|
| 298 |
+
if seq != current:
|
| 299 |
+
flush()
|
| 300 |
+
if args.limit and done >= args.limit:
|
| 301 |
+
break
|
| 302 |
+
current, meta, meta_loc, rows = seq, None, None, {}
|
| 303 |
+
data_kind = match[3]
|
| 304 |
+
if data_kind == 'meta.yml':
|
| 305 |
+
data = tf.extractfile(member).read()
|
| 306 |
+
meta = yaml_load_bytes(data)
|
| 307 |
+
meta_loc = locator(archive, member.name, data)
|
| 308 |
+
continue
|
| 309 |
+
serial, kind, f = match[4], match[5], int(match[6])
|
| 310 |
+
if selected_views and serial not in selected_views or args.max_frames and f >= args.max_frames:
|
| 311 |
+
continue
|
| 312 |
+
data = tf.extractfile(member).read()
|
| 313 |
+
dest = safe_member(work, member.name)
|
| 314 |
+
dest.parent.mkdir(parents=True, exist_ok=True)
|
| 315 |
+
dest.write_bytes(data)
|
| 316 |
+
row = rows.setdefault(serial, {}).setdefault(f, {})
|
| 317 |
+
if kind in row:
|
| 318 |
+
raise ValueError('duplicate archive frame')
|
| 319 |
+
row[kind] = (dest, locator(archive, member.name, data))
|
| 320 |
+
else:
|
| 321 |
+
flush()
|
| 322 |
+
return done
|
| 323 |
+
|
| 324 |
+
|
| 325 |
+
def main(argv=None):
|
| 326 |
+
p = parser('dex-ycb', __doc__)
|
| 327 |
+
p.add_argument('--subjects')
|
| 328 |
+
args = p.parse_args(argv)
|
| 329 |
+
archives = sorted({a for r in roots(args.root) for a in r.glob('*-subject-*.tar.gz')})
|
| 330 |
+
if args.subjects:
|
| 331 |
+
subjects = {s.strip().zfill(2) for s in args.subjects.split(',')}
|
| 332 |
+
archives = [a for a in archives if re.search(r'subject-(\d+)', a.name)[1] in subjects]
|
| 333 |
+
if not archives:
|
| 334 |
+
p.error('no Dex-YCB subject archives found')
|
| 335 |
+
cp = find_file(args.root, 'calibration.tar.gz') or find_file(args.root, 'calibration')
|
| 336 |
+
if cp is None:
|
| 337 |
+
p.error('calibration source missing')
|
| 338 |
+
calib = Calibration(cp.parent)
|
| 339 |
+
models = mano_models(args.mano_dir)
|
| 340 |
+
out = release(args, 'dex-ycb')
|
| 341 |
+
with tempfile.TemporaryDirectory(prefix='dex-models-') as wd:
|
| 342 |
+
assets, asset_archive = prepare_models(args.root, Path(wd))
|
| 343 |
+
for archive in archives:
|
| 344 |
+
convert_archive(archive, args, out, calib, cp, models, assets, asset_archive)
|
| 345 |
+
return 0
|
| 346 |
+
|
| 347 |
+
|
| 348 |
+
if __name__ == '__main__':
|
| 349 |
+
raise SystemExit(main())
|
H2O/shared-v1.1/script/v1_0_snapshot/script/convert_h2o_v1.0.py
ADDED
|
@@ -0,0 +1,678 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""H2O native RGB-D, MANO, joints and objects → CONTRACT.md v1.0 (no rendered masks)."""
|
| 3 |
+
from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor
|
| 4 |
+
import io
|
| 5 |
+
import json
|
| 6 |
+
import multiprocessing
|
| 7 |
+
import os
|
| 8 |
+
import re
|
| 9 |
+
import shutil
|
| 10 |
+
import tarfile
|
| 11 |
+
import tempfile
|
| 12 |
+
import threading
|
| 13 |
+
from pathlib import Path
|
| 14 |
+
import zipfile
|
| 15 |
+
|
| 16 |
+
# Bound native libraries before loading NumPy/Torch; each worker still uses independent FFmpeg processes.
|
| 17 |
+
for key in ('OMP_NUM_THREADS', 'OPENBLAS_NUM_THREADS', 'MKL_NUM_THREADS', 'NUMEXPR_NUM_THREADS'):
|
| 18 |
+
os.environ[key] = '1'
|
| 19 |
+
|
| 20 |
+
import numpy as np
|
| 21 |
+
from PIL import Image
|
| 22 |
+
import torch
|
| 23 |
+
|
| 24 |
+
from warehouse_v1_0 import (View, build_record, check_mesh, find_file, locator, mano_models, mesh_asset,
|
| 25 |
+
model_profile, parser, release, roots, safe_member, sequence_dir, sha256)
|
| 26 |
+
|
| 27 |
+
OBJECTS = {1: 'book', 2: 'espresso', 3: 'lotion', 4: 'spray',
|
| 28 |
+
5: 'milk', 6: 'cocoa', 7: 'chips', 8: 'cappuccino'}
|
| 29 |
+
MEMBER = re.compile(r'^(?:h2o_CASA/)?(subject\d+)/([^/]+)/(\d+)/(cam\d)/(.+)$')
|
| 30 |
+
FRAME = re.compile(r'(rgb|depth|cam_pose|hand_pose|hand_pose_mano|obj_pose|obj_pose_rt)/(\d+)\.(png|jpg|txt)$')
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def load_splits(root):
|
| 34 |
+
archive = find_file(root, 'label_split.zip')
|
| 35 |
+
result = {}
|
| 36 |
+
if archive is not None:
|
| 37 |
+
with zipfile.ZipFile(archive) as z:
|
| 38 |
+
for split in ('train', 'val', 'test'):
|
| 39 |
+
member = f'label_split/action_{split}.txt'
|
| 40 |
+
for line_no, line in enumerate(z.read(member).decode().splitlines(), 1):
|
| 41 |
+
fields = line.split()
|
| 42 |
+
if len(fields) < 2 or fields[1] == 'path':
|
| 43 |
+
continue
|
| 44 |
+
key = fields[1]
|
| 45 |
+
if key in result and result[key][0] != split:
|
| 46 |
+
raise ValueError('conflicting official splits')
|
| 47 |
+
result[key] = (split, locator(archive, member, record=line_no))
|
| 48 |
+
return result
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def load_assets(root, work):
|
| 52 |
+
archive = find_file(root, 'object.zip')
|
| 53 |
+
if archive is None:
|
| 54 |
+
return {}, None
|
| 55 |
+
with zipfile.ZipFile(archive) as z:
|
| 56 |
+
for member in z.infolist():
|
| 57 |
+
if member.is_dir():
|
| 58 |
+
continue
|
| 59 |
+
path = safe_member(work, member.filename)
|
| 60 |
+
path.parent.mkdir(parents=True, exist_ok=True)
|
| 61 |
+
path.write_bytes(z.read(member))
|
| 62 |
+
result = {}
|
| 63 |
+
for oid, name in OBJECTS.items():
|
| 64 |
+
directory = work / 'object' / name
|
| 65 |
+
aliases = []
|
| 66 |
+
# Source cocoa.obj -> ovomaltine.mtl -> cocoa.png, but the ZIP names the
|
| 67 |
+
# supplied texture ovomaltine.png. Keep all originals and add a byte-identical alias.
|
| 68 |
+
if name == 'cocoa' and not (directory / 'cocoa.png').exists():
|
| 69 |
+
mtl = directory / 'ovomaltine.mtl'
|
| 70 |
+
if mtl.is_file() and 'map_Kd cocoa.png' in mtl.read_text().splitlines():
|
| 71 |
+
texture = directory / 'ovomaltine.png'
|
| 72 |
+
shutil.copyfile(texture, directory / 'cocoa.png')
|
| 73 |
+
aliases.append({'file': 'cocoa.png', 'sha256': sha256(texture),
|
| 74 |
+
'source': locator(archive, 'object/cocoa/ovomaltine.png')})
|
| 75 |
+
candidates = list(directory.glob('*.obj'))
|
| 76 |
+
if len(candidates) != 1:
|
| 77 |
+
raise ValueError(f'expected one source OBJ for {name}')
|
| 78 |
+
check_mesh(candidates[0], directory) # Fail before decoding any large subject archive.
|
| 79 |
+
result[oid] = (directory, candidates[0], aliases)
|
| 80 |
+
return result, archive
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
def convert_view(path, args, seq, cam, rows, intr, splits, models, assets, asset_archive):
|
| 84 |
+
codec_threads = getattr(args, 'codec_threads', 1)
|
| 85 |
+
ids = list(range(min(rows), max(rows) + 1))
|
| 86 |
+
for f in ids:
|
| 87 |
+
rows.setdefault(f, {})
|
| 88 |
+
n = len(ids)
|
| 89 |
+
if not n:
|
| 90 |
+
raise ValueError('no RGB frames')
|
| 91 |
+
split, split_loc = splits.get(seq, ('unknown', None))
|
| 92 |
+
frame_rows = [dict(source_frame_id=f, sync_id=f'{seq}:{f}', source_locator=rows[f]['rgb'][1] if 'rgb' in rows[f] else {'sequence': seq, 'camera': cam, 'source_frame_id': f, 'missing_rgb': True},
|
| 93 |
+
component_sources={k: item[1] for k, item in rows[f].items()},
|
| 94 |
+
annotation_matches={k: dict(source_frame_id=f, source_timestamp_ns=None,
|
| 95 |
+
clock_domain=None, match_method='index_map', delta_ns=None)
|
| 96 |
+
for k in rows[f] if k != 'rgb'}) for f in ids]
|
| 97 |
+
view = View(path, 'H2O', args.release_id, seq.replace('/', '_'), cam, frame_rows, split=split)
|
| 98 |
+
view.valid_rules = {
|
| 99 |
+
'mano': 'Per-hand hand_pose_mano flag equals 1; corresponding side model available',
|
| 100 |
+
'keypoints': "Per-hand hand_pose flag equals 1, broadcast to that hand's 21 source points independently of MANO",
|
| 101 |
+
'pose': 'Source obj_pose_rt class equals this nonzero object class',
|
| 102 |
+
'points': 'Source obj_pose class equals this nonzero object class, broadcast to its 21 points',
|
| 103 |
+
}
|
| 104 |
+
view.full_jpeg = getattr(args, 'jpeg_full_check', False)
|
| 105 |
+
view.meta['view_type'] = 'ego' if cam == 'cam4' else 'exo' if cam in ('cam0', 'cam1', 'cam2', 'cam3') else 'unknown'
|
| 106 |
+
view.meta['sampling']['selection'] = {'max_frames': args.max_frames, 'views': args.views}
|
| 107 |
+
if split_loc:
|
| 108 |
+
view.meta.update(split_scheme='official_action_split', split_source_locator=split_loc)
|
| 109 |
+
# In the measured 275 H2O views, exact FFV1 was always smaller than exact H.264.
|
| 110 |
+
view.rgb([rows[f]['rgb'][0] if 'rgb' in rows[f] else None for f in ids],
|
| 111 |
+
{'frames_ref': 'camera/frames.jsonl'}, ffv1_first=True, codec_threads=codec_threads,
|
| 112 |
+
stream_source=getattr(args, 'stream_media', False))
|
| 113 |
+
loc = {'frames_ref': 'camera/frames.jsonl', 'source_field': 'component_sources'}
|
| 114 |
+
if intr is not None:
|
| 115 |
+
fx, fy, cx, cy, width, height = np.loadtxt(io.BytesIO(intr[0])).ravel()
|
| 116 |
+
if [int(width), int(height)] != view.meta['camera']['image_size']:
|
| 117 |
+
raise ValueError('source intrinsics resolution mismatch')
|
| 118 |
+
K = np.array([[fx, 0, cx], [0, fy, cy], [0, 0, 1]])
|
| 119 |
+
view.camera(K, intr[1])
|
| 120 |
+
camps = np.full((n, 4, 4), np.nan, np.float32)
|
| 121 |
+
cv = np.zeros(n, bool)
|
| 122 |
+
data = []
|
| 123 |
+
for i, f in enumerate(ids):
|
| 124 |
+
lab = {k: np.loadtxt(io.BytesIO(item[0])).ravel() for k, item in rows[f].items() if k not in ('rgb', 'depth')}
|
| 125 |
+
data.append(lab)
|
| 126 |
+
if 'cam_pose' in lab:
|
| 127 |
+
camps[i] = np.linalg.inv(lab['cam_pose'].reshape(4, 4))
|
| 128 |
+
cv[i] = True
|
| 129 |
+
if cv.any():
|
| 130 |
+
view.tensor('extrinsic', 'transform/se3/v1', 'camera/extrinsic.pt', camps, cv,
|
| 131 |
+
['T', 'row', 'column'], loc, convention='T_camera_from_world',
|
| 132 |
+
source_convention='T_world_from_camera')
|
| 133 |
+
motion, mv = np.full((n, 2, 61), np.nan, np.float32), np.zeros((n, 2), bool)
|
| 134 |
+
points, pv = np.full((n, 2, 21, 3), np.nan, np.float32), np.zeros((n, 2, 21), bool)
|
| 135 |
+
object_ids = set()
|
| 136 |
+
for i, lab in enumerate(data):
|
| 137 |
+
if 'hand_pose_mano' in lab:
|
| 138 |
+
hands = lab['hand_pose_mano'].reshape(2, 62)
|
| 139 |
+
for side, row in enumerate(hands):
|
| 140 |
+
if row[0] not in (0, 1):
|
| 141 |
+
raise ValueError('unexpected H2O MANO presence flag')
|
| 142 |
+
if row[0] == 1:
|
| 143 |
+
motion[i, side] = np.r_[row[4:52], row[52:62], row[1:4]]
|
| 144 |
+
mv[i, side] = True
|
| 145 |
+
if 'hand_pose' in lab:
|
| 146 |
+
hands = lab['hand_pose'].reshape(2, 64)
|
| 147 |
+
for side, row in enumerate(hands):
|
| 148 |
+
if row[0] not in (0, 1):
|
| 149 |
+
raise ValueError('unexpected H2O keypoint presence flag')
|
| 150 |
+
if row[0] == 1:
|
| 151 |
+
points[i, side] = row[1:].reshape(21, 3)
|
| 152 |
+
pv[i, side] = True
|
| 153 |
+
for key in ('obj_pose', 'obj_pose_rt'):
|
| 154 |
+
if key in lab and lab[key][0] != 0:
|
| 155 |
+
object_ids.add(int(lab[key][0]))
|
| 156 |
+
if any('hand_pose_mano' in lab for lab in data):
|
| 157 |
+
if len(models) == 2:
|
| 158 |
+
view.tensor('mano', 'mano/axis_angle61/v1', 'annotation/mano/motion.pt', motion, mv,
|
| 159 |
+
['T', 'hand', 'parameter'], loc, model_profile=model_profile(models))
|
| 160 |
+
else:
|
| 161 |
+
view.absent('mano', 'Source parameters exist; --mano-dir must identify both model profiles', 'dependency_missing')
|
| 162 |
+
if any('hand_pose' in lab for lab in data):
|
| 163 |
+
view.tensor('keypoints_xyz', 'keypoints/xyz/v1', 'annotation/keypoints/xyz.pt', points, pv,
|
| 164 |
+
['T', 'hand', 'keypoint', 'coordinate'], loc, keypoint_schema='mano21/v1', unit='m')
|
| 165 |
+
for oid in sorted(object_ids):
|
| 166 |
+
if oid not in OBJECTS:
|
| 167 |
+
raise ValueError(f'unknown H2O object class {oid}')
|
| 168 |
+
entity = OBJECTS[oid]
|
| 169 |
+
view.object(entity, loc, category_id=oid, source_object_id=oid)
|
| 170 |
+
poses, ov = np.full((n, 4, 4), np.nan, np.float32), np.zeros(n, bool)
|
| 171 |
+
pts, kv = np.full((n, 21, 3), np.nan, np.float32), np.zeros((n, 21), bool)
|
| 172 |
+
for i, lab in enumerate(data):
|
| 173 |
+
if 'obj_pose_rt' in lab and lab['obj_pose_rt'][0] == oid:
|
| 174 |
+
poses[i] = lab['obj_pose_rt'][1:].reshape(4, 4)
|
| 175 |
+
ov[i] = True
|
| 176 |
+
if 'obj_pose' in lab and lab['obj_pose'][0] == oid:
|
| 177 |
+
pts[i] = lab['obj_pose'][1:].reshape(21, 3)
|
| 178 |
+
kv[i] = True
|
| 179 |
+
if ov.any():
|
| 180 |
+
view.tensor('pose_' + entity, 'object/rigid/v1', f'annotation/object/{entity}/pose.pt',
|
| 181 |
+
poses, ov, ['T', 'row', 'column'], loc, convention='T_camera_from_object', unit='m')
|
| 182 |
+
if kv.any():
|
| 183 |
+
view.tensor('points_' + entity, 'object_keypoints/camera/v1',
|
| 184 |
+
f'annotation/object/{entity}/keypoints/xyz.pt', pts, kv,
|
| 185 |
+
['T', 'keypoint', 'coordinate'], loc, keypoint_schema='H2O_official_object21',
|
| 186 |
+
keypoint_names=['center'] + [f'corner_{i}' for i in range(8)] + [f'edge_midpoint_{i}' for i in range(12)],
|
| 187 |
+
source_order='official obj_point_order.jpg: center, 8 corners, 12 edge midpoints', unit='m')
|
| 188 |
+
if oid in assets:
|
| 189 |
+
directory, obj, aliases = assets[oid]
|
| 190 |
+
asset_loc = locator(asset_archive, f'object/{entity}/{obj.name}')
|
| 191 |
+
if aliases:
|
| 192 |
+
asset_loc['texture_aliases'] = aliases
|
| 193 |
+
mesh_asset(view, entity, directory, obj, asset_loc)
|
| 194 |
+
else:
|
| 195 |
+
view.absent('mesh_' + entity, 'Source object.zip unavailable', 'not_downloaded')
|
| 196 |
+
if any('depth' in rows[f] for f in ids):
|
| 197 |
+
width, height = view.meta['camera']['image_size']
|
| 198 |
+
depth_threads = getattr(args, 'depth_threads', 1)
|
| 199 |
+
def read_depth(f):
|
| 200 |
+
item = rows[f].get('depth')
|
| 201 |
+
if item:
|
| 202 |
+
with Image.open(item[0]) as im:
|
| 203 |
+
return np.asarray(im).astype(np.float32) / 1000.0
|
| 204 |
+
return np.full((height, width), np.nan, np.float32)
|
| 205 |
+
def depths():
|
| 206 |
+
if depth_threads == 1:
|
| 207 |
+
yield from map(read_depth, ids)
|
| 208 |
+
else:
|
| 209 |
+
with ThreadPoolExecutor(max_workers=depth_threads) as pool:
|
| 210 |
+
# Ordered batches bound decoded arrays to depth_threads frames per view.
|
| 211 |
+
for start in range(0, len(ids), depth_threads):
|
| 212 |
+
yield from pool.map(read_depth, ids[start:start + depth_threads])
|
| 213 |
+
view.raster('depth', depths(), None, loc | {'source_field': 'component_sources.depth',
|
| 214 |
+
'definition': 'https://github.com/taeinkwon/h2oplayer/blob/main/utils.py',
|
| 215 |
+
'conversion': 'registered millimetre camera-Z to metres; no viewer range clipping'},
|
| 216 |
+
codec_threads=codec_threads, stream=getattr(args, 'stream_media', False))
|
| 217 |
+
else:
|
| 218 |
+
view.absent('depth', 'No source depth frames')
|
| 219 |
+
view.absent('segment', 'H2O provides no native segmentation; rendering deferred to v2.0')
|
| 220 |
+
view.absent('relations', 'No source contact/grasp annotation')
|
| 221 |
+
return view.finish()
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
def convert_archive(archive, args, out, splits, models, assets, asset_archive, view_pool=None, ram_budget=None):
|
| 225 |
+
selected_views = set(args.views.split(',')) if args.views else None
|
| 226 |
+
subjects = {'subject' + s.strip() for s in args.subjects.split(',')} if args.subjects else None
|
| 227 |
+
current, rows, intrinsics, done = None, {}, {}, 0
|
| 228 |
+
published_views = set()
|
| 229 |
+
camera_jobs, closed_cameras = {}, set()
|
| 230 |
+
last_camera = None
|
| 231 |
+
pipeline_active = False
|
| 232 |
+
ram_reserved = 0
|
| 233 |
+
try:
|
| 234 |
+
with tempfile.TemporaryDirectory(prefix='h2o-source-') as wd, \
|
| 235 |
+
tempfile.TemporaryDirectory(prefix='h2o-ram-', dir=args.ram_stage_dir) as rd:
|
| 236 |
+
work, ram_work = Path(wd), Path(rd)
|
| 237 |
+
def queue_camera(cam):
|
| 238 |
+
if cam in closed_cameras:
|
| 239 |
+
return
|
| 240 |
+
closed_cameras.add(cam)
|
| 241 |
+
if cam not in published_views and rows.get(cam):
|
| 242 |
+
camera_jobs[cam] = view_pool.submit(convert_view, work / '.converted' / cam,
|
| 243 |
+
args, '/'.join(current), cam, rows[cam], intrinsics.get(cam),
|
| 244 |
+
splits, models, assets, asset_archive)
|
| 245 |
+
def flush():
|
| 246 |
+
nonlocal done, ram_reserved
|
| 247 |
+
if not rows:
|
| 248 |
+
return
|
| 249 |
+
seq = '/'.join(current)
|
| 250 |
+
reports, pending = {}, {}
|
| 251 |
+
for cam, frames in sorted(rows.items()):
|
| 252 |
+
existing = out / 'data' / seq.replace('/', '_') / cam
|
| 253 |
+
if (existing / 'metainfo.json').is_file():
|
| 254 |
+
old_frames = [json.loads(line) for line in (existing / 'camera/frames.jsonl').read_text().splitlines()]
|
| 255 |
+
if [f['source_frame_id'] for f in old_frames] != list(range(min(frames), max(frames) + 1)):
|
| 256 |
+
raise ValueError('existing view has different sampling; choose a new release-id')
|
| 257 |
+
for frame in old_frames:
|
| 258 |
+
incoming = frames.get(frame['source_frame_id'], {})
|
| 259 |
+
previous = frame.get('component_sources', {})
|
| 260 |
+
if set(previous) != set(incoming) or any(previous[k].get('sha256') != v[1].get('sha256') for k, v in incoming.items()):
|
| 261 |
+
raise ValueError('duplicate H2O view differs from the published source; choose a new release-id')
|
| 262 |
+
else:
|
| 263 |
+
pending[cam] = frames
|
| 264 |
+
if pending:
|
| 265 |
+
if pipeline_active:
|
| 266 |
+
for cam in pending:
|
| 267 |
+
queue_camera(cam)
|
| 268 |
+
failure = None
|
| 269 |
+
for cam, job in camera_jobs.items():
|
| 270 |
+
try:
|
| 271 |
+
reports[cam] = job.result()
|
| 272 |
+
except Exception as exc:
|
| 273 |
+
failure = failure or exc
|
| 274 |
+
if failure is not None:
|
| 275 |
+
raise failure
|
| 276 |
+
with sequence_dir(out, seq.replace('/', '_')) as target:
|
| 277 |
+
if pipeline_active:
|
| 278 |
+
for cam in pending:
|
| 279 |
+
shutil.move(work / '.converted' / cam, target / cam)
|
| 280 |
+
elif view_pool is None:
|
| 281 |
+
for cam, frames in pending.items():
|
| 282 |
+
reports[cam] = convert_view(target / cam, args, seq, cam, frames,
|
| 283 |
+
intrinsics.get(cam), splits, models, assets, asset_archive)
|
| 284 |
+
else:
|
| 285 |
+
jobs = {cam: view_pool.submit(convert_view, target / cam, args, seq, cam,
|
| 286 |
+
frames, intrinsics.get(cam), splits, models, assets, asset_archive)
|
| 287 |
+
for cam, frames in pending.items()}
|
| 288 |
+
failure = None
|
| 289 |
+
# Every sibling must finish before sequence_dir can remove its inputs.
|
| 290 |
+
for cam, job in jobs.items():
|
| 291 |
+
try:
|
| 292 |
+
reports[cam] = job.result()
|
| 293 |
+
except Exception as exc:
|
| 294 |
+
failure = failure or exc
|
| 295 |
+
if failure is not None:
|
| 296 |
+
raise failure
|
| 297 |
+
build_record(out, seq.replace('/', '_'), reports)
|
| 298 |
+
for directory in (work, ram_work):
|
| 299 |
+
for staged in list(directory.iterdir()):
|
| 300 |
+
if staged.is_dir():
|
| 301 |
+
shutil.rmtree(staged)
|
| 302 |
+
else:
|
| 303 |
+
staged.unlink()
|
| 304 |
+
if ram_budget is not None:
|
| 305 |
+
lock, used, limit = ram_budget
|
| 306 |
+
with lock:
|
| 307 |
+
used[0] -= ram_reserved
|
| 308 |
+
ram_reserved = 0
|
| 309 |
+
done += 1
|
| 310 |
+
print(f'{"Converted" if pending else "Verified existing"} {seq}', flush=True)
|
| 311 |
+
# Uncompressed CASA supports seeking over large frames; gzip is single-pass.
|
| 312 |
+
mode = 'r:' if archive.suffix == '.tar' else 'r|gz'
|
| 313 |
+
try:
|
| 314 |
+
with tarfile.open(archive, mode) as tf:
|
| 315 |
+
for member in tf:
|
| 316 |
+
match = MEMBER.fullmatch(member.name)
|
| 317 |
+
if not member.isfile() or not match:
|
| 318 |
+
continue
|
| 319 |
+
subj, scene, seq, cam, tail = match.groups()
|
| 320 |
+
if subjects and subj not in subjects:
|
| 321 |
+
continue
|
| 322 |
+
key = (subj, scene, seq)
|
| 323 |
+
if key != current:
|
| 324 |
+
flush()
|
| 325 |
+
if args.limit and done >= args.limit:
|
| 326 |
+
break
|
| 327 |
+
current, rows, intrinsics = key, {}, {}
|
| 328 |
+
camera_jobs.clear()
|
| 329 |
+
closed_cameras.clear()
|
| 330 |
+
last_camera = None
|
| 331 |
+
pipeline_active = args.camera_pipeline
|
| 332 |
+
published_views = {view.name for view in
|
| 333 |
+
(out / 'data' / '_'.join(key)).glob('cam*')
|
| 334 |
+
if (view / 'metainfo.json').is_file()}
|
| 335 |
+
if selected_views and cam not in selected_views:
|
| 336 |
+
continue
|
| 337 |
+
if pipeline_active and cam != last_camera:
|
| 338 |
+
if last_camera is not None:
|
| 339 |
+
queue_camera(last_camera)
|
| 340 |
+
if cam in closed_cameras:
|
| 341 |
+
# Complete queued readers before accepting late fields for those cameras.
|
| 342 |
+
for job in camera_jobs.values():
|
| 343 |
+
try:
|
| 344 |
+
job.result()
|
| 345 |
+
except Exception:
|
| 346 |
+
pass
|
| 347 |
+
shutil.rmtree(work / '.converted', ignore_errors=True)
|
| 348 |
+
camera_jobs.clear()
|
| 349 |
+
closed_cameras.clear()
|
| 350 |
+
pipeline_active = False
|
| 351 |
+
print(f'Camera-order fallback: {"/".join(current)}', flush=True)
|
| 352 |
+
last_camera = cam
|
| 353 |
+
frame = FRAME.fullmatch(tail)
|
| 354 |
+
if tail != 'cam_intrinsics.txt' and not frame:
|
| 355 |
+
continue
|
| 356 |
+
if frame and args.max_frames and int(frame[2]) >= args.max_frames:
|
| 357 |
+
continue
|
| 358 |
+
data = tf.extractfile(member).read()
|
| 359 |
+
if tail.endswith('.txt'):
|
| 360 |
+
payload = data # Small source annotations stay in RAM, not thousands of HDD files.
|
| 361 |
+
else:
|
| 362 |
+
staging = work
|
| 363 |
+
if ram_budget is not None and cam not in published_views:
|
| 364 |
+
lock, used, limit = ram_budget
|
| 365 |
+
needed = (len(data) + 4095) // 4096 * 4096
|
| 366 |
+
with lock:
|
| 367 |
+
if used[0] + needed <= limit:
|
| 368 |
+
used[0] += needed
|
| 369 |
+
ram_reserved += needed
|
| 370 |
+
staging = ram_work
|
| 371 |
+
payload = safe_member(staging, member.name)
|
| 372 |
+
if cam not in published_views:
|
| 373 |
+
payload.parent.mkdir(parents=True, exist_ok=True)
|
| 374 |
+
payload.write_bytes(data)
|
| 375 |
+
# Published views still verify source bytes, but never read their staging paths.
|
| 376 |
+
item = (payload, locator(archive, member.name, data))
|
| 377 |
+
if tail == 'cam_intrinsics.txt':
|
| 378 |
+
intrinsics[cam] = item
|
| 379 |
+
else:
|
| 380 |
+
kind, f = frame[1], int(frame[2])
|
| 381 |
+
row = rows.setdefault(cam, {}).setdefault(f, {})
|
| 382 |
+
if kind in row:
|
| 383 |
+
raise ValueError('duplicate H2O frame')
|
| 384 |
+
row[kind] = item
|
| 385 |
+
else:
|
| 386 |
+
flush()
|
| 387 |
+
finally:
|
| 388 |
+
# Never delete staging while a closed-camera job can still read from it.
|
| 389 |
+
for job in camera_jobs.values():
|
| 390 |
+
try:
|
| 391 |
+
job.result()
|
| 392 |
+
except Exception:
|
| 393 |
+
pass
|
| 394 |
+
finally:
|
| 395 |
+
if ram_budget is not None:
|
| 396 |
+
lock, used, limit = ram_budget
|
| 397 |
+
with lock:
|
| 398 |
+
used[0] -= ram_reserved
|
| 399 |
+
return done
|
| 400 |
+
|
| 401 |
+
|
| 402 |
+
def main(argv=None):
|
| 403 |
+
p = parser('H2O', __doc__)
|
| 404 |
+
p.set_defaults(release_id='shared-v1.0')
|
| 405 |
+
p.add_argument('--workers', type=int, choices=range(1, 5), default=1,
|
| 406 |
+
help='Independent subject archives in parallel, 1..4; benchmark before using >2')
|
| 407 |
+
p.add_argument('--view-backend', choices=('threads', 'processes'), default='threads',
|
| 408 |
+
help='Use spawn processes to isolate Python camera processing')
|
| 409 |
+
p.add_argument('--camera-pipeline', action='store_true',
|
| 410 |
+
help='Overlap contiguous-camera extraction and conversion; reject interleaved input')
|
| 411 |
+
p.add_argument('--ffv1-slices', type=int, choices=(16,),
|
| 412 |
+
help='Optional FFV1 v3 slice parallelism; decoded frames must still match exactly')
|
| 413 |
+
p.add_argument('--view-workers', type=int, choices=range(1, 17), default=1,
|
| 414 |
+
help='Shared camera-view conversion pool, independent of archive readers')
|
| 415 |
+
p.add_argument('--ram-stage-dir', type=Path, help='Optional tmpfs staging; excess PNGs fall back to disk')
|
| 416 |
+
p.add_argument('--ram-stage-gib', type=int, choices=range(1, 65), default=32,
|
| 417 |
+
help='Shared PNG tmpfs quota across all archive readers, not per worker')
|
| 418 |
+
p.add_argument('--stream-media', action='store_true',
|
| 419 |
+
help='Pipe RGB/depth frames to FFmpeg instead of spooling huge RAW files')
|
| 420 |
+
p.add_argument('--codec-threads', type=int, choices=(1, 2, 4, 8, 10), default=4,
|
| 421 |
+
help='FFV1 slice threads per encode; default 4, use 10 for the current full run')
|
| 422 |
+
p.add_argument('--decode-threads', type=int, choices=(1, 2, 4, 8, 10), default=1,
|
| 423 |
+
help='FFmpeg threads for source RGB decoding and decoded-media checks')
|
| 424 |
+
p.add_argument('--depth-threads', type=int, choices=(1, 2, 4), default=1,
|
| 425 |
+
help='Bounded ordered source depth PNG loading per worker')
|
| 426 |
+
p.add_argument('--subjects')
|
| 427 |
+
p.add_argument('--include-casa', action='store_true')
|
| 428 |
+
p.add_argument('--archive', type=Path, help='Convert one explicit source archive')
|
| 429 |
+
args = p.parse_args(argv)
|
| 430 |
+
if args.camera_pipeline and args.view_workers < 2:
|
| 431 |
+
p.error('--camera-pipeline requires at least two --view-workers')
|
| 432 |
+
os.environ['HAND_WAREHOUSE_FFMPEG_THREADS'] = str(args.decode_threads)
|
| 433 |
+
if args.ffv1_slices is None:
|
| 434 |
+
os.environ.pop('HAND_WAREHOUSE_FFV1_SLICES', None)
|
| 435 |
+
else:
|
| 436 |
+
os.environ['HAND_WAREHOUSE_FFV1_SLICES'] = str(args.ffv1_slices)
|
| 437 |
+
if args.include_casa and args.workers != 1:
|
| 438 |
+
p.error('CASA can share sequence IDs with subject archives; convert it sequentially in a separate release')
|
| 439 |
+
archives = [args.archive.expanduser()] if args.archive else sorted(
|
| 440 |
+
{a for root in roots(args.root) for a in root.glob('subject*_v1_1.tar.gz')})
|
| 441 |
+
if args.subjects and not args.archive:
|
| 442 |
+
requested = {'subject' + s.strip() for s in args.subjects.split(',')}
|
| 443 |
+
archives = [arc for arc in archives if arc.name.split('_', 1)[0] in requested]
|
| 444 |
+
if args.include_casa:
|
| 445 |
+
casa = find_file(args.root, 'h2o_CASA.tar')
|
| 446 |
+
if casa:
|
| 447 |
+
archives.append(casa)
|
| 448 |
+
if not archives:
|
| 449 |
+
p.error('no H2O archives found')
|
| 450 |
+
out = release(args, 'H2O')
|
| 451 |
+
source_mapping = next(p for p in (Path(__file__).resolve().parents[1] / 'docs/h2o-RAW_TO_SHARED.md',
|
| 452 |
+
Path(__file__).resolve().parents[1] / 'doc/RAW_TO_SHARED.md',
|
| 453 |
+
out / 'doc/RAW_TO_SHARED.md') if p.is_file())
|
| 454 |
+
mapping = out / 'doc/RAW_TO_SHARED.md'
|
| 455 |
+
if mapping.exists() and mapping.read_bytes() != source_mapping.read_bytes():
|
| 456 |
+
raise ValueError('RAW_TO_SHARED.md changed; choose a new release-id')
|
| 457 |
+
if not mapping.exists():
|
| 458 |
+
shutil.copyfile(source_mapping, mapping)
|
| 459 |
+
os.environ.pop('HAND_WAREHOUSE_MEDIA_TMPDIR', None)
|
| 460 |
+
ram_budget = None
|
| 461 |
+
if args.ram_stage_dir is not None:
|
| 462 |
+
args.ram_stage_dir = args.ram_stage_dir.expanduser().resolve()
|
| 463 |
+
if not args.ram_stage_dir.is_relative_to(Path('/dev/shm').resolve()):
|
| 464 |
+
p.error('--ram-stage-dir must be on /dev/shm; it is temporary input, not an output dataset')
|
| 465 |
+
args.ram_stage_dir.mkdir(parents=True, exist_ok=True)
|
| 466 |
+
limit = args.ram_stage_gib * 1024**3
|
| 467 |
+
if shutil.disk_usage(args.ram_stage_dir).free < limit + 8 * 1024**3:
|
| 468 |
+
p.error('not enough tmpfs headroom for the requested shared staging quota')
|
| 469 |
+
ram_budget = (threading.Lock(), [0], limit)
|
| 470 |
+
if args.stream_media:
|
| 471 |
+
os.environ['HAND_WAREHOUSE_MEDIA_TMPDIR'] = str(args.ram_stage_dir)
|
| 472 |
+
torch.set_num_threads(1)
|
| 473 |
+
models, splits = mano_models(args.mano_dir), load_splits(args.root)
|
| 474 |
+
executor = ProcessPoolExecutor if args.view_backend == 'processes' else ThreadPoolExecutor
|
| 475 |
+
options = {'mp_context': multiprocessing.get_context('spawn')} if args.view_backend == 'processes' else {'thread_name_prefix': 'h2o-view'}
|
| 476 |
+
with tempfile.TemporaryDirectory(prefix='h2o-assets-') as wd, \
|
| 477 |
+
executor(max_workers=args.view_workers, **options) as views:
|
| 478 |
+
assets, asset_archive = load_assets(args.root, Path(wd))
|
| 479 |
+
def convert_one(archive):
|
| 480 |
+
return convert_archive(archive, args, out, splits, models, assets, asset_archive,
|
| 481 |
+
views if args.view_workers > 1 else None, ram_budget)
|
| 482 |
+
if args.workers == 1:
|
| 483 |
+
for archive in archives:
|
| 484 |
+
convert_one(archive)
|
| 485 |
+
else:
|
| 486 |
+
with ThreadPoolExecutor(max_workers=args.workers) as pool:
|
| 487 |
+
for archive, count in zip(archives, pool.map(convert_one, archives), strict=True):
|
| 488 |
+
print(f'Archive {archive.name}: {count} sequences', flush=True)
|
| 489 |
+
return 0
|
| 490 |
+
|
| 491 |
+
|
| 492 |
+
if __name__ == '__main__':
|
| 493 |
+
raise SystemExit(main())
|
| 494 |
+
|
| 495 |
+
# TODO(v2.0): 以下旧 MANO 网格和渲染分割代码仅保留备查;v1.0 不生成标注。
|
| 496 |
+
# def load_mano_model(path: Path):
|
| 497 |
+
# """MPI MANO pkl → numpy 字典。shapedirs 在 pkl 内为 chumpy Select(对 (778,3,20) 基
|
| 498 |
+
# 底 flat 选取前 10 个 shape 分量;idxs 已核实等价于 base[:,:,:10])。"""
|
| 499 |
+
# with open(path, "rb") as f:
|
| 500 |
+
# d = _ManoUnpickler(f, encoding="latin1").load()
|
| 501 |
+
# sd = d["shapedirs"]
|
| 502 |
+
# base = np.asarray(sd.a.x, np.float64) # (778, 3, 20)
|
| 503 |
+
# shapedirs = base.reshape(-1)[np.asarray(sd.idxs)].reshape(base.shape[0], 3, -1)
|
| 504 |
+
# jreg = d["J_regressor"]
|
| 505 |
+
# jreg = np.asarray(jreg.todense()) if hasattr(jreg, "todense") else np.asarray(jreg)
|
| 506 |
+
# return {"v_template": np.asarray(d["v_template"], np.float64),
|
| 507 |
+
# "shapedirs": shapedirs,
|
| 508 |
+
# "posedirs": np.asarray(d["posedirs"], np.float64),
|
| 509 |
+
# "weights": np.asarray(d["weights"], np.float64),
|
| 510 |
+
# "J_regressor": np.asarray(jreg, np.float64),
|
| 511 |
+
# "kintree": np.asarray(d["kintree_table"], np.int64),
|
| 512 |
+
# "faces": np.asarray(d["f"], np.int64)}
|
| 513 |
+
#
|
| 514 |
+
#
|
| 515 |
+
# def rodrigues(r):
|
| 516 |
+
# """axis-angle (N,3) → 旋转矩阵 (N,3,3)。公式 I + sinθ·K + (1−cosθ)·K²(已对 scipy 核验)。"""
|
| 517 |
+
# r = np.asarray(r, np.float64).reshape(-1, 3)
|
| 518 |
+
# th = np.linalg.norm(r, axis=1)
|
| 519 |
+
# R = np.zeros((len(r), 3, 3))
|
| 520 |
+
# nz = th > 1e-12
|
| 521 |
+
# R[~nz] = np.eye(3)
|
| 522 |
+
# k = r[nz] / th[nz, None]
|
| 523 |
+
# K = np.zeros((len(k), 3, 3))
|
| 524 |
+
# K[:, 0, 1], K[:, 0, 2], K[:, 1, 2] = -k[:, 2], k[:, 1], -k[:, 0]
|
| 525 |
+
# K[:, 1, 0], K[:, 2, 0], K[:, 2, 1] = k[:, 2], -k[:, 1], k[:, 0]
|
| 526 |
+
# s, c = np.sin(th[nz])[:, None, None], np.cos(th[nz])[:, None, None]
|
| 527 |
+
# R[nz] = np.eye(3) + s * K + (1 - c) * (K @ K)
|
| 528 |
+
# return R
|
| 529 |
+
#
|
| 530 |
+
#
|
| 531 |
+
# def _mano_chain(model, betas, pose):
|
| 532 |
+
# """返回 (v_shaped, J, Rs, G):G 为 16 个关节的全局变换(平移列 = 关节位置)。"""
|
| 533 |
+
# v = model["v_template"] + np.einsum("nkc,c->nk", model["shapedirs"], betas)
|
| 534 |
+
# J = model["J_regressor"] @ v
|
| 535 |
+
# Rs = rodrigues(np.asarray(pose, np.float64).reshape(16, 3))
|
| 536 |
+
# kt = model["kintree"]
|
| 537 |
+
# G = np.zeros((16, 4, 4))
|
| 538 |
+
# for j in range(16):
|
| 539 |
+
# p = kt[0, j] if j else -1
|
| 540 |
+
# loc = np.eye(4)
|
| 541 |
+
# loc[:3, :3] = Rs[j]
|
| 542 |
+
# loc[:3, 3] = J[j] - (J[p] if j else 0.0)
|
| 543 |
+
# G[j] = loc if not j else G[p] @ loc
|
| 544 |
+
# return v, J, Rs, G
|
| 545 |
+
#
|
| 546 |
+
#
|
| 547 |
+
# def mano_forward(model, betas, pose, transl):
|
| 548 |
+
# """MANO LBS 前向(经典蒙皮 M_j = G_j·G0_j⁻¹;对 hand_pose 21 关节实证 0.0 mm)。
|
| 549 |
+
# pose: 48 axis-angle([0:3] 全局);返回相机系米顶点 (778,3)。"""
|
| 550 |
+
# v, J, Rs, G = _mano_chain(model, betas, pose)
|
| 551 |
+
# lrot = (Rs[1:] - np.eye(3)).ravel()
|
| 552 |
+
# v_posed = v + np.einsum("nkc,c->nk", model["posedirs"], lrot)
|
| 553 |
+
# kt = model["kintree"]
|
| 554 |
+
# G0 = np.zeros((16, 4, 4))
|
| 555 |
+
# for j in range(16):
|
| 556 |
+
# p = kt[0, j] if j else -1
|
| 557 |
+
# loc = np.eye(4)
|
| 558 |
+
# loc[:3, 3] = J[j] - (J[p] if j else 0.0)
|
| 559 |
+
# G0[j] = loc if not j else G0[p] @ loc
|
| 560 |
+
# M = np.einsum("nj,jab->nab", model["weights"], G @ np.linalg.inv(G0))
|
| 561 |
+
# out = np.einsum("nab,nb->na", M[:, :3, :3], v_posed) + M[:, :3, 3]
|
| 562 |
+
# return out + np.asarray(transl, np.float64)
|
| 563 |
+
#
|
| 564 |
+
#
|
| 565 |
+
# def mano_chain_joints(model, betas, pose, transl):
|
| 566 |
+
# """16 个关节位置(相机系米)= 链平移列;自检用。"""
|
| 567 |
+
# _, _, _, G = _mano_chain(model, betas, pose)
|
| 568 |
+
# return G[:, :3, 3] + np.asarray(transl, np.float64)
|
| 569 |
+
#
|
| 570 |
+
#
|
| 571 |
+
# def rasterize(verts_cam, faces, labels, W, H, fx, fy, cx, cy):
|
| 572 |
+
# z = verts_cam[:, 2]
|
| 573 |
+
# P = faces
|
| 574 |
+
# ok = (z[P] > 0.02).all(1) # 任一顶点在相机后 → 丢弃该三角形
|
| 575 |
+
# P, labels = P[ok], labels[ok]
|
| 576 |
+
# if len(P) == 0:
|
| 577 |
+
# return np.zeros((H, W), np.uint16), np.zeros(0, np.int64)
|
| 578 |
+
# x = verts_cam[:, 0] / z * fx + cx
|
| 579 |
+
# y = verts_cam[:, 1] / z * fy + cy
|
| 580 |
+
# xa = np.maximum(0, np.minimum(np.floor(x[P[:, 0]]), np.minimum(
|
| 581 |
+
# np.floor(x[P[:, 1]]), np.floor(x[P[:, 2]]))).astype(np.int64))
|
| 582 |
+
# xb = np.minimum(W - 1, np.maximum(np.ceil(x[P[:, 0]]), np.maximum(
|
| 583 |
+
# np.ceil(x[P[:, 1]]), np.ceil(x[P[:, 2]]))).astype(np.int64))
|
| 584 |
+
# ya = np.maximum(0, np.minimum(np.floor(y[P[:, 0]]), np.minimum(
|
| 585 |
+
# np.floor(y[P[:, 1]]), np.floor(y[P[:, 2]]))).astype(np.int64))
|
| 586 |
+
# yb = np.minimum(H - 1, np.maximum(np.ceil(y[P[:, 0]]), np.maximum(
|
| 587 |
+
# np.ceil(y[P[:, 1]]), np.ceil(y[P[:, 2]]))).astype(np.int64))
|
| 588 |
+
# xa, ya = np.minimum(xa, xb), np.minimum(ya, yb) # 完全出画的三角形 → 空 bbox
|
| 589 |
+
# wdt, hgt = xb - xa + 1, yb - ya + 1
|
| 590 |
+
# cnt = wdt * hgt
|
| 591 |
+
# tot = int(cnt.sum())
|
| 592 |
+
# tri = np.repeat(np.arange(len(P)), cnt)
|
| 593 |
+
# k = np.arange(tot) - (np.cumsum(cnt) - cnt)[tri]
|
| 594 |
+
# px = xa[tri] + k % wdt[tri] + 0.5
|
| 595 |
+
# py = ya[tri] + k // wdt[tri] + 0.5
|
| 596 |
+
# ax, ay = x[P[tri, 0]], y[P[tri, 0]]
|
| 597 |
+
# bx, by = x[P[tri, 1]], y[P[tri, 1]]
|
| 598 |
+
# cx_, cy_ = x[P[tri, 2]], y[P[tri, 2]]
|
| 599 |
+
# area = ((x[P[:, 1]] - x[P[:, 0]]) * (y[P[:, 2]] - y[P[:, 0]])
|
| 600 |
+
# - (y[P[:, 1]] - y[P[:, 0]]) * (x[P[:, 2]] - x[P[:, 0]]))
|
| 601 |
+
# areat = area[tri]
|
| 602 |
+
# e0 = (bx - ax) * (py - ay) - (by - ay) * (px - ax)
|
| 603 |
+
# e1 = (cx_ - bx) * (py - by) - (cy_ - by) * (px - bx)
|
| 604 |
+
# e2 = (ax - cx_) * (py - cy_) - (ay - cy_) * (px - cx_)
|
| 605 |
+
# s = np.sign(areat)
|
| 606 |
+
# inside = (np.abs(areat) > 1e-9) & ((e0 * s >= 0) & (e1 * s >= 0) & (e2 * s >= 0))
|
| 607 |
+
# px, py, tri = px[inside], py[inside], tri[inside]
|
| 608 |
+
# at = areat[inside]
|
| 609 |
+
# w0, w1, w2 = e1[inside] / at, e2[inside] / at, e0[inside] / at
|
| 610 |
+
# zz = w0 * z[P[tri, 0]] + w1 * z[P[tri, 1]] + w2 * z[P[tri, 2]]
|
| 611 |
+
# pix = py.astype(np.int64) * W + px.astype(np.int64)
|
| 612 |
+
# order = np.lexsort((zz, pix)) # 同像素按深度升序 → 首条即最近
|
| 613 |
+
# pix, tri = pix[order], tri[order]
|
| 614 |
+
# first = np.unique(pix, return_index=True)[1]
|
| 615 |
+
# mask = np.zeros(H * W, np.uint16)
|
| 616 |
+
# win = tri[first]
|
| 617 |
+
# mask[pix[first]] = labels[win] + 1 # 临时标签 +1(0=背景)
|
| 618 |
+
# return mask.reshape(H, W), np.bincount(labels[win] + 1)
|
| 619 |
+
#
|
| 620 |
+
#
|
| 621 |
+
# # ============================================================================
|
| 622 |
+
# # ffmpeg 写出与核验(与 convert_dexycb.py 同构)
|
| 623 |
+
# # ============================================================================
|
| 624 |
+
# verts, faces_all, labels = [], [], []
|
| 625 |
+
# for ti, (tid, kind) in enumerate(tracks):
|
| 626 |
+
# if kind == "hand_left" and b["mano"][0] > 0.5:
|
| 627 |
+
# verts.append(mano_forward(mano_models["left"], b["mano"][52:62],
|
| 628 |
+
# b["mano"][4:52], b["mano"][1:4]))
|
| 629 |
+
# faces_all.append(mano_models["left"]["faces"])
|
| 630 |
+
# elif kind == "hand_right" and b["mano"][62] > 0.5:
|
| 631 |
+
# verts.append(mano_forward(mano_models["right"], b["mano"][114:124],
|
| 632 |
+
# b["mano"][66:114], b["mano"][63:66]))
|
| 633 |
+
# faces_all.append(mano_models["right"]["faces"])
|
| 634 |
+
# elif isinstance(kind, tuple) and int(b["objp"][0]) == kind[1]:
|
| 635 |
+
# M = np.asarray(b["objrt"][1:17], np.float64).reshape(4, 4)
|
| 636 |
+
# V0, F0 = meshes[kind[1]]
|
| 637 |
+
# verts.append(V0 @ M[:3, :3].T + M[:3, 3])
|
| 638 |
+
# faces_all.append(F0)
|
| 639 |
+
# else:
|
| 640 |
+
# continue
|
| 641 |
+
# labels.append(np.full(len(faces_all[-1]), ti))
|
| 642 |
+
# if verts:
|
| 643 |
+
# V = np.concatenate(verts)
|
| 644 |
+
# offs = np.cumsum([0] + [len(v) for v in verts[:-1]])
|
| 645 |
+
# F = np.concatenate([fa + o for fa, o in zip(faces_all, offs)])
|
| 646 |
+
# mask, counts = rasterize(V, F, np.concatenate(labels),
|
| 647 |
+
# IMG_W, IMG_H, fx, fy, cx, cy)
|
| 648 |
+
# else:
|
| 649 |
+
# mask, counts = np.zeros((IMG_H, IMG_W), np.uint16), np.zeros(0, np.int64)
|
| 650 |
+
# lut = np.zeros(n_tracks + 1, np.uint16)
|
| 651 |
+
# for ti in range(n_tracks):
|
| 652 |
+
# present = ti + 1 < len(counts) and counts[ti + 1] > 0
|
| 653 |
+
# if present:
|
| 654 |
+
# presence[tracks[ti][0]][f] = True
|
| 655 |
+
# if active_id[ti] is None:
|
| 656 |
+
# pid = next(i for i in range(1, 65535) if i not in used)
|
| 657 |
+
# used.add(pid)
|
| 658 |
+
# active_id[ti], seg_start[ti] = pid, f
|
| 659 |
+
# frame_maps[ti].append({"id": pid})
|
| 660 |
+
# lut[ti + 1] = active_id[ti]
|
| 661 |
+
# elif active_id[ti] is not None:
|
| 662 |
+
# frame_maps[ti][-1]["frames"] = [seg_start[ti], f - 1]
|
| 663 |
+
# segments[ti].append([seg_start[ti], f - 1])
|
| 664 |
+
# used.discard(active_id[ti])
|
| 665 |
+
# active_id[ti] = None
|
| 666 |
+
# mw.write(lut[mask])
|
| 667 |
+
|
| 668 |
+
|
| 669 |
+
# TODO(v2.0): 旧物体尺寸派生代码;v1.0 仅保留源物体关键点。
|
| 670 |
+
# pts = np.asarray(b["objp"][1:64], np.float64).reshape(21, 3)
|
| 671 |
+
# half = np.abs((pts[1:9] - pts[0]) @ M[:3, :3]).max(0)
|
| 672 |
+
# obj_recs.append({
|
| 673 |
+
# "track_id": f"o{classes.index(c)}", "frame": f,
|
| 674 |
+
# "mesh_ref": f"h2o/{OBJ_CLASSES[c]}.obj",
|
| 675 |
+
# "pose": {"quat": rotmat_to_quat_wxyz(M[:3, :3])[0].tolist(),
|
| 676 |
+
# "trans": M[:3, 3].tolist()},
|
| 677 |
+
# "bbox_center3d": pts[0].tolist(),
|
| 678 |
+
# "bbox_size": (2 * half).tolist()})
|
H2O/shared-v1.1/script/v1_0_snapshot/script/convert_hoi4d_v1.0.py
ADDED
|
@@ -0,0 +1,595 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""HOI4D native observations and annotations → CONTRACT.md v1.0."""
|
| 3 |
+
from collections import Counter
|
| 4 |
+
from concurrent.futures import ThreadPoolExecutor
|
| 5 |
+
from contextlib import ExitStack
|
| 6 |
+
from functools import lru_cache
|
| 7 |
+
import gzip
|
| 8 |
+
import io
|
| 9 |
+
import json
|
| 10 |
+
import os
|
| 11 |
+
from pathlib import Path
|
| 12 |
+
import pickle
|
| 13 |
+
import re
|
| 14 |
+
import shutil
|
| 15 |
+
import shlex
|
| 16 |
+
import posixpath
|
| 17 |
+
import subprocess
|
| 18 |
+
import tempfile
|
| 19 |
+
import tarfile
|
| 20 |
+
import threading
|
| 21 |
+
import zipfile
|
| 22 |
+
|
| 23 |
+
# Each worker owns one Python thread; prevent native libraries spawning CPU pools.
|
| 24 |
+
for key in ('OMP_NUM_THREADS', 'OPENBLAS_NUM_THREADS', 'MKL_NUM_THREADS', 'NUMEXPR_NUM_THREADS'):
|
| 25 |
+
os.environ[key] = '1'
|
| 26 |
+
|
| 27 |
+
import numpy as np
|
| 28 |
+
from PIL import Image
|
| 29 |
+
from scipy.spatial.transform import Rotation
|
| 30 |
+
|
| 31 |
+
import torch
|
| 32 |
+
|
| 33 |
+
from warehouse_v1_0 import (View, build_record, check_mesh, decode_args, find_file, json_write, locator,
|
| 34 |
+
mano_models, model_profile, parser, probe, release, run, safe_member, sequence_dir)
|
| 35 |
+
|
| 36 |
+
CATEGORIES = {
|
| 37 |
+
1: dict(cad="rigid/ToyCar", groups=[("main", [1], "Toy Car", 1)],
|
| 38 |
+
hands={2: "right"}, objmap={"Toycar": "main"}),
|
| 39 |
+
2: dict(cad="rigid/Mug", groups=[("a", [1], "Mug", 2), ("b", [3], "Mug", 2)],
|
| 40 |
+
hands={2: "right"}, objmap={"Watercup": "a"}),
|
| 41 |
+
3: dict(cad="articulated/Laptop", groups=[("main", [1, 3], "Laptop", 3)],
|
| 42 |
+
hands={2: "right"},
|
| 43 |
+
objmap={"Laptopdisplay": "main", "Laptopkeyboard": "main"}),
|
| 44 |
+
4: dict(cad="articulated/StorageFurniture",
|
| 45 |
+
groups=[("main", [1, 3, 4], "Storage Furniture", 4),
|
| 46 |
+
("bottle", [5], "Bottle", 5)],
|
| 47 |
+
hands={2: "right"},
|
| 48 |
+
objmap={"Lockerbody": "main", "Lockersldingdoor": "main",
|
| 49 |
+
"Lockerdrawer": "main", "Safebox": "main"}),
|
| 50 |
+
5: dict(cad="rigid/Bottle", groups=[("main", [1], "Bottle", 5),
|
| 51 |
+
("mug", [3], "Mug", 2)],
|
| 52 |
+
hands={2: "right"}, objmap={"bottleddrinks": "main"}),
|
| 53 |
+
6: dict(cad="articulated/Safe", groups=[("main", [1, 3], "Safe", 6),
|
| 54 |
+
("bottle", [4], "Bottle", 5)],
|
| 55 |
+
hands={2: "right"}, objmap={"Safebox": "main", "Safedoor": "main"}),
|
| 56 |
+
7: dict(cad="rigid/Bowl", groups=[("main", [1], "Bowl", 7),
|
| 57 |
+
("ball", [3], "Ball", None)],
|
| 58 |
+
hands={2: "right"}, objmap={"bowl": "main"}),
|
| 59 |
+
8: dict(cad="articulated/Bucket",
|
| 60 |
+
groups=[("a", [1, 3], "Bucket", 8), ("b", [4, 5], "Bucket", 8)],
|
| 61 |
+
hands={2: "right", 6: "left"},
|
| 62 |
+
objmap={"bucket": "a", "Buckethandle": "a"}),
|
| 63 |
+
9: dict(cad="articulated/Scissors", groups=[("main", [1, 3], "Scissors", 9)],
|
| 64 |
+
hands={2: "right"},
|
| 65 |
+
objmap={"scissors": "main", "scissors2": None}), # scissors2:场景道具,无掩码
|
| 66 |
+
11: dict(cad="articulated/Pliers", groups=[("main", [1, 3], "Pliers", 11)],
|
| 67 |
+
hands={2: "right"}, objmap={"Pliersleft": "main", "Pliersright": "main"}),
|
| 68 |
+
12: dict(cad="rigid/Kettle", groups=[("main", [1], "Kettle", 12),
|
| 69 |
+
("mug", [3], "Mug", 2)],
|
| 70 |
+
hands={2: "right"}, objmap={"kettle": "main"}),
|
| 71 |
+
13: dict(cad="rigid/Knife", groups=[("main", [1], "Knife", 13),
|
| 72 |
+
("apple", [3], "Apple", None)],
|
| 73 |
+
hands={2: "right"}, objmap={"knife": "main"}),
|
| 74 |
+
14: dict(cad="articulated/TrashCan",
|
| 75 |
+
groups=[("main", [1, 3], "Trash Can", 14), ("bottle", [4], "Bottle", 5)],
|
| 76 |
+
hands={2: "right"}, objmap={"Dustbinbase": "main", "Dustbincover": "main"}),
|
| 77 |
+
17: dict(cad="articulated/Lamp", groups=[("main", [1, 3, 4, 5], "Lamp", 17)],
|
| 78 |
+
hands={2: "right", 6: "left"},
|
| 79 |
+
objmap={"Lampbase": "main", "Tablelampfirstjoint": "main",
|
| 80 |
+
"Tablelampsecondjoint": "main", "Thirdjointoftablelamp": "main"}),
|
| 81 |
+
18: dict(cad="articulated/Stapler",
|
| 82 |
+
groups=[("main", [1, 3, 4], "Stapler", 18), ("paper", [5], "Paper", None)],
|
| 83 |
+
hands={2: "right", 6: "left"}, # 6=左手:官方 label.csv 缺列,实测修正
|
| 84 |
+
objmap={"Staplerbase": "main", "Staplercover": "main"}),
|
| 85 |
+
20: dict(cad="rigid/Chair", groups=[("main", [1], "Chair", 20)],
|
| 86 |
+
hands={2: "right", 3: "left"}, objmap={"chair": "main"}),
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
# Official HOI4D definitions/motion segmentation/label.csv; no spatial side inference.
|
| 91 |
+
REGION_NAMES = {1: {1: 'Toy Car', 2: 'Right Hand'}, 2: {1: 'Mug', 2: 'Right Hand', 3: 'Mug'}, 3: {1: 'Screen', 2: 'Right Hand', 3: 'Keyboard'}, 4: {1: 'Door', 2: 'Right Hand', 3: 'Body of the Cabinet', 4: 'Drawer', 5: 'Bottle'}, 5: {1: 'Bottle', 2: 'Right Hand', 3: 'Mug'}, 6: {1: 'Body of the Safe', 2: 'Right Hand', 3: 'Door', 4: 'Bottle'}, 7: {1: 'Bowl', 2: 'Right Hand', 3: 'Ball'}, 8: {1: 'Body of the Bucket', 2: 'Right Hand', 3: 'Handle', 4: 'Body of the Bucket', 5: 'Handle', 6: 'Left Hand'}, 9: {1: 'Left Part of the Scissors', 2: 'Right Hand', 3: 'Right Part of the Scissors'}, 11: {1: 'Left Part of the Pliers', 2: 'Right Hand', 3: 'Right Part of the Pliers'}, 12: {1: 'Kettle', 2: 'Right Hand', 3: 'Mug'}, 13: {1: 'Knife', 2: 'Right Hand', 3: 'Apple'}, 14: {1: 'Body of the Trash Can', 2: 'Right Hand', 3: 'Lid', 4: 'Bottle'}, 17: {1: 'Base', 2: 'Right Hand', 3: 'Tube', 4: 'Top Link', 5: 'Bottom Link', 6: 'Left Hand'}, 18: {1: 'Base', 2: 'Right Hand', 3: 'Slot', 4: 'Lid', 5: 'Paper'}, 20: {1: 'Chair', 2: 'Right Hand', 3: 'Left Hand'}}
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
class SplitFiles(io.RawIOBase):
|
| 95 |
+
"""Read concatenated source gzip parts without concatenating 119 GB on disk."""
|
| 96 |
+
def __init__(self, paths):
|
| 97 |
+
self.paths = iter(paths)
|
| 98 |
+
self.current = None
|
| 99 |
+
|
| 100 |
+
def readable(self):
|
| 101 |
+
return True
|
| 102 |
+
|
| 103 |
+
def readinto(self, buffer):
|
| 104 |
+
while True:
|
| 105 |
+
if self.current is None:
|
| 106 |
+
path = next(self.paths, None)
|
| 107 |
+
if path is None:
|
| 108 |
+
return 0
|
| 109 |
+
self.current = path.open('rb')
|
| 110 |
+
n = self.current.readinto(buffer)
|
| 111 |
+
if n:
|
| 112 |
+
return n
|
| 113 |
+
self.current.close()
|
| 114 |
+
self.current = None
|
| 115 |
+
|
| 116 |
+
def close(self):
|
| 117 |
+
if self.current is not None:
|
| 118 |
+
self.current.close()
|
| 119 |
+
super().close()
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
def extract_depths(root, sequences, work):
|
| 123 |
+
directory = find_file(root, 'DEPTH')
|
| 124 |
+
if directory is None:
|
| 125 |
+
return {}, []
|
| 126 |
+
parts = sorted(directory.glob('HOI4D_depth_video.tar.gz*'), key=lambda p: int(p.name.split('.gz')[1] or 0))
|
| 127 |
+
if not parts:
|
| 128 |
+
return {}, []
|
| 129 |
+
wanted = {f'HOI4D_depth_video/{seq}/align_depth/depth_video.avi': seq for seq in sequences}
|
| 130 |
+
found = {}
|
| 131 |
+
with SplitFiles(parts) as joined, io.BufferedReader(joined) as inp, gzip.GzipFile(fileobj=inp) as gz:
|
| 132 |
+
with tarfile.open(fileobj=gz, mode='r|') as tf:
|
| 133 |
+
for member in tf:
|
| 134 |
+
if member.isfile() and member.name in wanted:
|
| 135 |
+
seq = wanted[member.name]
|
| 136 |
+
dest = work / (seq.replace('/', '_') + '.avi')
|
| 137 |
+
with tf.extractfile(member) as src, dest.open('wb') as dst:
|
| 138 |
+
shutil.copyfileobj(src, dst)
|
| 139 |
+
found[seq] = (dest, {'files': [str(p.resolve()) for p in parts], 'member': member.name})
|
| 140 |
+
if len(found) == len(wanted):
|
| 141 |
+
break
|
| 142 |
+
return found, parts
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
def palette_mask(data):
|
| 146 |
+
with Image.open(io.BytesIO(data)) as im:
|
| 147 |
+
arr = np.asarray(im)
|
| 148 |
+
if arr.ndim == 2:
|
| 149 |
+
return arr.astype(np.uint16)
|
| 150 |
+
if arr.shape[-1] != 3:
|
| 151 |
+
raise ValueError('unsupported HOI4D mask representation')
|
| 152 |
+
# VOC's 256-color palette interleaves eight label bits into the high RGB bits.
|
| 153 |
+
# Invert it directly instead of sorting every pixel with np.unique.
|
| 154 |
+
if np.any(arr & np.array([31, 31, 63], dtype=np.uint8)):
|
| 155 |
+
raise ValueError('source mask has colors outside official VOC palette')
|
| 156 |
+
mask = np.zeros(arr.shape[:2], dtype=np.uint16)
|
| 157 |
+
for bit in range(8):
|
| 158 |
+
mask |= ((arr[..., bit % 3] >> (7 - bit // 3)) & 1).astype(np.uint16) << bit
|
| 159 |
+
return mask
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
# Four workers each reuse annotation and hand indices instead of rebuilding the ZIP directory.
|
| 163 |
+
@lru_cache(maxsize=8)
|
| 164 |
+
def index_frames(z):
|
| 165 |
+
index = {}
|
| 166 |
+
for name in z.namelist():
|
| 167 |
+
parent, _, filename = name.rpartition('/')
|
| 168 |
+
stem, dot, suffix = filename.rpartition('.')
|
| 169 |
+
if not dot or not stem.isdigit() or suffix not in ('png', 'json', 'pickle'):
|
| 170 |
+
continue
|
| 171 |
+
entries = index.setdefault((parent + '/', '.' + suffix), {})
|
| 172 |
+
f = int(stem)
|
| 173 |
+
if f in entries:
|
| 174 |
+
raise ValueError(f'duplicate frame number under {parent}')
|
| 175 |
+
entries[f] = name
|
| 176 |
+
return index
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
def frame_members(z, prefix, suffix):
|
| 180 |
+
return index_frames(z).get((prefix, suffix), {})
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
def convert_sequence(seq, args, target, rgbz, annz, hpz, calz, cadz, paths, models, depth):
|
| 184 |
+
# ponytail: cache only one sequence's encoded annotation bytes; no decoded masks or CAD cache.
|
| 185 |
+
@lru_cache(maxsize=None)
|
| 186 |
+
def read_annotation(archive, name):
|
| 187 |
+
return archive.read(name)
|
| 188 |
+
|
| 189 |
+
category = int(re.search(r'/C(\d+)/', seq)[1])
|
| 190 |
+
definition = CATEGORIES.get(category)
|
| 191 |
+
if definition is None:
|
| 192 |
+
raise ValueError(f'category mapping unavailable: {category}')
|
| 193 |
+
prefix = f'HOI4D_annotations/{seq}'
|
| 194 |
+
mask_members = frame_members(annz, prefix + '/2Dseg/mask/', '.png')
|
| 195 |
+
shifted = frame_members(annz, prefix + '/2Dseg/shift_mask/', '.png')
|
| 196 |
+
if not mask_members:
|
| 197 |
+
mask_members = shifted
|
| 198 |
+
pose_members = frame_members(annz, prefix + '/objpose/', '.json')
|
| 199 |
+
hand_members = {side: frame_members(hpz, f'Hand_pose/handpose_{side}_hand/{seq}/', '.pickle')
|
| 200 |
+
for side in ('left', 'right')} if hpz else {'left': {}, 'right': {}}
|
| 201 |
+
with tempfile.TemporaryDirectory(prefix='hoi4d-source-') as wd:
|
| 202 |
+
work = Path(wd)
|
| 203 |
+
member = f'HOI4D_release/{seq}/align_rgb/image.mp4'
|
| 204 |
+
video = work / 'rgb.mp4'
|
| 205 |
+
with rgbz.open(member) as src, video.open('wb') as dst:
|
| 206 |
+
shutil.copyfileobj(src, dst)
|
| 207 |
+
info = probe(video)
|
| 208 |
+
if 'nb_frames' not in info:
|
| 209 |
+
info['nb_frames'] = json.loads(run(['ffprobe', '-v', 'error', '-count_frames', '-select_streams', 'v:0',
|
| 210 |
+
'-show_entries', 'stream=nb_read_frames', '-of', 'json', str(video)], stdout=subprocess.PIPE).stdout)['streams'][0]['nb_read_frames']
|
| 211 |
+
n = int(info['nb_frames'])
|
| 212 |
+
if args.max_frames:
|
| 213 |
+
n = min(n, args.max_frames)
|
| 214 |
+
if shifted and mask_members != shifted and any(f not in mask_members and f in shifted for f in range(n)):
|
| 215 |
+
raise ValueError('shift_mask has frames absent from mask; correspondence unverified')
|
| 216 |
+
frames = []
|
| 217 |
+
for f in range(n):
|
| 218 |
+
sources = {}
|
| 219 |
+
if f in mask_members:
|
| 220 |
+
sources['segment'] = locator(paths['annotations'], mask_members[f], read_annotation(annz, mask_members[f]))
|
| 221 |
+
if f in pose_members:
|
| 222 |
+
sources['object'] = locator(paths['annotations'], pose_members[f], read_annotation(annz, pose_members[f]))
|
| 223 |
+
for side in ('left', 'right'):
|
| 224 |
+
if f in hand_members[side]:
|
| 225 |
+
sources['hand_' + side] = locator(paths['hand'], hand_members[side][f], read_annotation(hpz, hand_members[side][f]))
|
| 226 |
+
frames.append(dict(source_frame_id=f, source_locator=locator(paths['release'], member, frame=f),
|
| 227 |
+
component_sources=sources, annotation_matches={k: dict(source_frame_id=f, source_timestamp_ns=None,
|
| 228 |
+
clock_domain=None, match_method='index_map', delta_ns=None) for k in sources}))
|
| 229 |
+
view = View(target, 'HOI4D', args.release_id, seq.replace('/', '_'), 'ego', frames)
|
| 230 |
+
view.valid_rules = {
|
| 231 |
+
'mano': 'Matched side pickle contains poseCoeff, beta, trans and corresponding model available; zero angles are not missing',
|
| 232 |
+
'keypoints': 'Matched side pickle contains kps2D; independently provided source points, no visibility gate',
|
| 233 |
+
'pose': 'Matched source object record contains rotation and center; record identity retained',
|
| 234 |
+
'dimensions': 'Matched source object record contains dimensions; size/mesh relation remains source_unspecified',
|
| 235 |
+
'segment': 'Source mask or shift_mask present with verified palette codes and entity/part mapping',
|
| 236 |
+
}
|
| 237 |
+
view.full_jpeg = getattr(args, 'jpeg_full_check', False)
|
| 238 |
+
view.meta['view_type'] = 'ego'
|
| 239 |
+
view.meta['sampling']['selection'] = {'max_frames': args.max_frames, 'source_sequence': seq}
|
| 240 |
+
view.rgb([], locator(paths['release'], member), video=video, count=n)
|
| 241 |
+
intr_name = f'camera_params/{seq.split("/")[0]}/intrin.npy'
|
| 242 |
+
if calz and intr_name in calz.namelist():
|
| 243 |
+
view.camera(np.load(io.BytesIO(calz.read(intr_name))), locator(paths['camera'], intr_name))
|
| 244 |
+
extr_name = prefix + '/3Dseg/output.log'
|
| 245 |
+
if extr_name in annz.NameToInfo:
|
| 246 |
+
lines = [line for line in annz.read(extr_name).decode().splitlines() if line.strip()]
|
| 247 |
+
if len(lines) % 5:
|
| 248 |
+
raise ValueError('invalid Open3D camera trajectory')
|
| 249 |
+
extr, valid = np.full((n, 4, 4), np.nan, np.float32), np.zeros(n, bool)
|
| 250 |
+
for i in range(0, len(lines), 5):
|
| 251 |
+
idx = int(lines[i].split()[0])
|
| 252 |
+
if idx < n:
|
| 253 |
+
if valid[idx]:
|
| 254 |
+
raise ValueError('duplicate trajectory index')
|
| 255 |
+
extr[idx] = np.linalg.inv(np.loadtxt(io.StringIO('\n'.join(lines[i + 1:i + 5]))))
|
| 256 |
+
valid[idx] = True
|
| 257 |
+
view.tensor('extrinsic', 'transform/se3/v1', 'camera/extrinsic.pt', extr, valid,
|
| 258 |
+
['T', 'row', 'column'], locator(paths['annotations'], extr_name),
|
| 259 |
+
convention='T_camera_from_world', source_convention='Open3D LOG camera-to-world; inverted')
|
| 260 |
+
loc = {'frames_ref': 'camera/frames.jsonl', 'source_field': 'component_sources'}
|
| 261 |
+
motion, mv = np.full((n, 2, 61), np.nan, np.float32), np.zeros((n, 2), bool)
|
| 262 |
+
points, pv = np.full((n, 2, 21, 2), np.nan, np.float32), np.zeros((n, 2, 21), bool)
|
| 263 |
+
for slot, side in enumerate(('left', 'right')):
|
| 264 |
+
for f, name in hand_members[side].items():
|
| 265 |
+
if f >= n:
|
| 266 |
+
continue
|
| 267 |
+
data = pickle.loads(read_annotation(hpz, name), encoding='latin1')
|
| 268 |
+
if all(k in data for k in ('poseCoeff', 'beta', 'trans')):
|
| 269 |
+
motion[f, slot] = np.r_[np.asarray(data['poseCoeff']).reshape(48),
|
| 270 |
+
np.asarray(data['beta']).reshape(10), np.asarray(data['trans']).reshape(3)]
|
| 271 |
+
mv[f, slot] = True # Zero angles are a valid pose, not a missing sentinel.
|
| 272 |
+
if 'kps2D' in data:
|
| 273 |
+
points[f, slot] = np.asarray(data['kps2D']).reshape(21, 2)
|
| 274 |
+
pv[f, slot] = True
|
| 275 |
+
if mv.any():
|
| 276 |
+
if all(side in models for slot, side in enumerate(('left', 'right')) if mv[:, slot].any()):
|
| 277 |
+
view.tensor('mano', 'mano/axis_angle61/v1', 'annotation/mano/motion.pt', motion, mv,
|
| 278 |
+
['T', 'hand', 'parameter'], loc, model_profile=model_profile(models))
|
| 279 |
+
else:
|
| 280 |
+
view.absent('mano', 'Source MANO exists; provide --mano-dir to fix model identity', 'dependency_missing')
|
| 281 |
+
if pv.any():
|
| 282 |
+
view.tensor('keypoints_uv', 'keypoints/uv/v1', 'annotation/keypoints/uv.pt', points, pv,
|
| 283 |
+
['T', 'hand', 'keypoint', 'coordinate'], loc, keypoint_schema='mano21/v1', unit='pixel',
|
| 284 |
+
source_method='Upstream fitted MANO projection already present in kps2D')
|
| 285 |
+
objects = {}
|
| 286 |
+
groups = {key: (vals, name, cls) for key, vals, name, cls in definition['groups']}
|
| 287 |
+
def ensure_object(key, source_loc, category_id=None, frame=None, source_id=None):
|
| 288 |
+
if key not in objects:
|
| 289 |
+
view.object(key, source_loc, scope='frame' if frame is not None else 'sequence',
|
| 290 |
+
scope_id=f'{seq}:{frame}' if frame is not None else None,
|
| 291 |
+
category_id=category_id, source_object_id=source_id)
|
| 292 |
+
objects[key] = {}
|
| 293 |
+
mappings = []
|
| 294 |
+
mask_valid = [f in mask_members for f in range(n)]
|
| 295 |
+
if any(mask_valid):
|
| 296 |
+
width, height = view.meta['camera']['image_size']
|
| 297 |
+
def masks():
|
| 298 |
+
for f in range(n):
|
| 299 |
+
labels = []
|
| 300 |
+
if f in mask_members:
|
| 301 |
+
mask = palette_mask(read_annotation(annz, mask_members[f]))
|
| 302 |
+
for value in np.unique(mask):
|
| 303 |
+
value = int(value)
|
| 304 |
+
if value in (0, 255):
|
| 305 |
+
if value == 255:
|
| 306 |
+
raise ValueError('HOI4D 255 region semantics unverified')
|
| 307 |
+
continue
|
| 308 |
+
if REGION_NAMES[category].get(value) in ('Left Hand', 'Right Hand'):
|
| 309 |
+
entity, part, cls = 'hand_' + REGION_NAMES[category][value].split()[0].lower(), None, 'hand'
|
| 310 |
+
else:
|
| 311 |
+
group = next((k for k, (vals, _, _) in groups.items() if value in vals), None)
|
| 312 |
+
entity = group or f'unknown_region_{value}'
|
| 313 |
+
cls = groups[group][2] if group else None
|
| 314 |
+
part = f'region_{value}' if group and len(groups[group][0]) > 1 else None
|
| 315 |
+
ensure_object(entity, frames[f]['component_sources']['segment'], cls)
|
| 316 |
+
if part:
|
| 317 |
+
objects[entity].setdefault('parts', {})[part] = {'part_id': part, 'parent_id': None,
|
| 318 |
+
'has_model': False, 'mesh_ref': None, 'source_region_code': value, 'name': REGION_NAMES[category].get(value)}
|
| 319 |
+
labels.append(dict(mask_value=value, category_id=cls, entity_id=entity,
|
| 320 |
+
part_id=part, source_instance_id=value,
|
| 321 |
+
source_attributes={'region_name': REGION_NAMES[category].get(value)}))
|
| 322 |
+
else:
|
| 323 |
+
mask = np.zeros((height, width), np.uint16)
|
| 324 |
+
mappings.append(dict(frame_index=f, labels=labels))
|
| 325 |
+
yield mask
|
| 326 |
+
view.raster('segment', masks(), mask_valid, loc, mappings)
|
| 327 |
+
view.meta['components']['segment']['coverage'] = {'kind': 'unknown'}
|
| 328 |
+
if any(label['part_id'] for row in mappings for label in row['labels']):
|
| 329 |
+
view.meta['components']['segment']['segmentation_type'] = 'part'
|
| 330 |
+
else:
|
| 331 |
+
view.absent('segment', 'No native segmentation for this source sequence')
|
| 332 |
+
records = {}
|
| 333 |
+
for f, name in pose_members.items():
|
| 334 |
+
if f >= n:
|
| 335 |
+
continue
|
| 336 |
+
data = json.loads(read_annotation(annz, name))
|
| 337 |
+
# isEffective is not used to erase existing numerical annotations.
|
| 338 |
+
source_records = data.get('dataList', data.get('objects'))
|
| 339 |
+
if source_records is None:
|
| 340 |
+
raise ValueError('unrecognized source object annotation structure')
|
| 341 |
+
if category == 2 and source_records and (len(source_records) != 1 or
|
| 342 |
+
source_records[0].get('id') != 1 or source_records[0].get('label') != 'Watercup'):
|
| 343 |
+
raise ValueError('C2 native pose differs from the verified one-object target; cannot map to mask region 1')
|
| 344 |
+
label_counts = Counter(record['label'] for record in source_records)
|
| 345 |
+
per_frame = set()
|
| 346 |
+
for record_index, record in enumerate(source_records):
|
| 347 |
+
label = record['label']
|
| 348 |
+
group = definition['objmap'].get(label)
|
| 349 |
+
# Pinned official ObjTracking reads dataList[0] with segmentation label 1.
|
| 350 |
+
source_primary = category == 2 and record_index == 0 and record.get('id') == 1 and group == 'a'
|
| 351 |
+
ambiguous = group is not None and sum(g[2] == groups[group][2] for g in groups.values()) > 1 and not source_primary
|
| 352 |
+
ambiguous = ambiguous or (label_counts[label] > 1 and not source_primary) or group is None
|
| 353 |
+
entity = f'pose_frame_{f}_{record_index}' if ambiguous else group
|
| 354 |
+
ensure_object(entity, locator(paths['annotations'], name, record=record_index),
|
| 355 |
+
groups[group][2] if group else None, frame=f if ambiguous else None, source_id=record.get('id'))
|
| 356 |
+
if ambiguous:
|
| 357 |
+
view.build['unresolved'].append({'component': entity, 'status': 'source_semantics_unverified',
|
| 358 |
+
'reason': 'Source pose retained with frame identity; no guessed association to same-class mask instances'})
|
| 359 |
+
label_key = (entity, label)
|
| 360 |
+
if label_key in per_frame:
|
| 361 |
+
raise ValueError(f'ambiguous repeated object label {label}; source identity must be resolved')
|
| 362 |
+
per_frame.add(label_key)
|
| 363 |
+
records.setdefault(label_key, {})[f] = (record, locator(paths['annotations'], name, record=record.get('id')))
|
| 364 |
+
if category == 2 and any(entity == 'a' for entity, _ in records):
|
| 365 |
+
view.build['validation'].append({'component': 'C2_source_pose_mask_identity',
|
| 366 |
+
'rule': 'Official ObjTracking process_data.py reads dataList[0] with semantic mask label 1',
|
| 367 |
+
'source_revision': 'afa7bf37b02b7e33cf245acd08b98c207ccc175c',
|
| 368 |
+
'source_pose_id': 1, 'mask_value': 1, 'matched_frames': sum(len(by_frame) for (entity, _), by_frame in records.items() if entity == 'a')})
|
| 369 |
+
for (entity, label), by_frame in records.items():
|
| 370 |
+
part_labels = [k[1] for k in records if k[0] == entity]
|
| 371 |
+
articulated = definition['cad'].startswith('articulated/') and entity == definition['groups'][0][0]
|
| 372 |
+
part = 'pose_' + re.sub(r'[^a-zA-Z0-9_]', '_', label) if articulated or len(part_labels) > 1 else None
|
| 373 |
+
base = f'annotation/object/{entity}'
|
| 374 |
+
if part:
|
| 375 |
+
base += '/parts/' + part
|
| 376 |
+
objects[entity].setdefault('parts', {})[part] = dict(part_id=part, parent_id=None,
|
| 377 |
+
has_model=False, mesh_ref=None, source_label=label)
|
| 378 |
+
poses, valid = np.full((n, 4, 4), np.nan, np.float32), np.zeros(n, bool)
|
| 379 |
+
dimensions = np.full((n, 3), np.nan, np.float32)
|
| 380 |
+
dv = np.zeros(n, bool)
|
| 381 |
+
for f, (record, _) in by_frame.items():
|
| 382 |
+
if all(k in record for k in ('rotation', 'center')):
|
| 383 |
+
poses[f] = np.eye(4)
|
| 384 |
+
poses[f, :3, :3] = Rotation.from_euler('XYZ', [record['rotation'][k] for k in ('x', 'y', 'z')]).as_matrix()
|
| 385 |
+
poses[f, :3, 3] = [record['center'][k] for k in ('x', 'y', 'z')]
|
| 386 |
+
valid[f] = True
|
| 387 |
+
if 'dimensions' in record:
|
| 388 |
+
dimensions[f] = [record['dimensions'][k] for k in ('length', 'width', 'height')]
|
| 389 |
+
dv[f] = True
|
| 390 |
+
key = entity + ('_' + part if part else '')
|
| 391 |
+
view.tensor('pose_' + key, 'transform/se3/v1' if part else 'object/rigid/v1', base + '/pose.pt', poses, valid,
|
| 392 |
+
['T', 'row', 'column'], loc, convention='T_camera_from_part' if part else 'T_camera_from_object',
|
| 393 |
+
unit='m', source_label=label, source_euler_order='XYZ',
|
| 394 |
+
definition='https://github.com/hoi4d/ObjTracking/blob/main/process_data.py')
|
| 395 |
+
if dv.any():
|
| 396 |
+
view.tensor('dimensions_' + key, 'object/dimensions/v1', base + '/dimensions.pt', dimensions, dv,
|
| 397 |
+
['T', 'dimension'], loc, dimensions_semantics='source_unspecified', unit='m', scale_applied_to_mesh=False)
|
| 398 |
+
if cadz:
|
| 399 |
+
primary = definition['groups'][0][0]
|
| 400 |
+
if category != 2 and sum(g[2] == category for g in groups.values()) > 1:
|
| 401 |
+
primary = 'source_cad_instance'
|
| 402 |
+
instance = int(re.search(r'/N(\d+)/', seq)[1])
|
| 403 |
+
mesh_prefix = f'HOI4D_CAD_Model_for_release/{definition["cad"]}/{instance:03d}'
|
| 404 |
+
candidates = [name for name in cadz.namelist() if not name.endswith('/') and
|
| 405 |
+
(name == mesh_prefix + '.obj' or name.startswith(mesh_prefix + '/'))]
|
| 406 |
+
if candidates:
|
| 407 |
+
# Retain OBJ material/texture dependencies beside their original names.
|
| 408 |
+
queue = list(candidates)
|
| 409 |
+
for name in queue:
|
| 410 |
+
if Path(name).suffix.lower() not in ('.obj', '.mtl'):
|
| 411 |
+
continue
|
| 412 |
+
for line in cadz.read(name).decode().splitlines():
|
| 413 |
+
fields = shlex.split(line, comments=True)
|
| 414 |
+
if not fields:
|
| 415 |
+
continue
|
| 416 |
+
refs = fields[1:] if fields[0] == 'mtllib' else ([fields[-1]] if
|
| 417 |
+
fields[0].startswith('map_') or fields[0] in ('bump', 'norm', 'disp', 'decal') else [])
|
| 418 |
+
for ref in refs:
|
| 419 |
+
dependency = posixpath.normpath(posixpath.join(posixpath.dirname(name), ref))
|
| 420 |
+
if dependency not in cadz.NameToInfo:
|
| 421 |
+
raise ValueError(f'missing CAD dependency: {dependency}')
|
| 422 |
+
if dependency not in candidates:
|
| 423 |
+
candidates.append(dependency)
|
| 424 |
+
queue.append(dependency)
|
| 425 |
+
ensure_object(primary, locator(paths['cad'], mesh_prefix), category)
|
| 426 |
+
asset_dir = view.path / f'annotation/object/{primary}/assets'
|
| 427 |
+
asset_refs = []
|
| 428 |
+
for name in candidates:
|
| 429 |
+
relative = posixpath.relpath(name, mesh_prefix if definition['cad'].startswith('articulated/') else posixpath.dirname(mesh_prefix))
|
| 430 |
+
dest = safe_member(asset_dir, relative)
|
| 431 |
+
dest.parent.mkdir(parents=True, exist_ok=True)
|
| 432 |
+
dest.write_bytes(cadz.read(name))
|
| 433 |
+
ref = dest.relative_to(view.path).as_posix()
|
| 434 |
+
if dest.suffix.lower() == '.obj':
|
| 435 |
+
asset_key = re.sub(r'[^a-zA-Z0-9_]', '_', relative)
|
| 436 |
+
view.component('mesh_' + primary + '_' + asset_key, 'mesh/obj/v1', ref, ['vertex'],
|
| 437 |
+
locator(paths['cad'], name), unit='m', valid=True,
|
| 438 |
+
scale_applied_to_mesh=False, dimensions_semantics='source_unspecified')
|
| 439 |
+
asset_refs.append(ref)
|
| 440 |
+
if definition['cad'].startswith('articulated/'):
|
| 441 |
+
part_id = 'asset_' + asset_key
|
| 442 |
+
objects[primary].setdefault('parts', {})[part_id] = dict(part_id=part_id,
|
| 443 |
+
parent_id=None, has_model=True, mesh_ref=ref, source_asset=relative,
|
| 444 |
+
note='Source asset; correspondence to motion part labels remains unverified')
|
| 445 |
+
for asset_ref in asset_refs:
|
| 446 |
+
mesh_check = check_mesh(view.path / asset_ref, asset_dir)
|
| 447 |
+
view.build['validation'].append({'component': asset_ref, **mesh_check,
|
| 448 |
+
'unit_basis': 'official ObjTracking loads source canonical CAD without scaling in metre camera coordinates',
|
| 449 |
+
'geometric_acceptance': 'physical dimensions-to-mesh relation remains source_unspecified'})
|
| 450 |
+
metadata_path = view.path / f'annotation/object/{primary}/metainfo.json'
|
| 451 |
+
metadata = json.loads(metadata_path.read_text())
|
| 452 |
+
metadata.update(has_model=bool(asset_refs), asset_refs=asset_refs)
|
| 453 |
+
if definition['cad'].startswith('rigid/') and len(asset_refs) == 1:
|
| 454 |
+
metadata['mesh_ref'] = asset_refs[0]
|
| 455 |
+
json_write(metadata_path, metadata)
|
| 456 |
+
if definition['cad'].startswith('articulated/'):
|
| 457 |
+
view.build['unresolved'].append({'component': 'object_part_asset_association',
|
| 458 |
+
'status': 'source_semantics_unverified',
|
| 459 |
+
'reason': 'All source assets and motion labels retained, but no guessed correspondence or joint_state'})
|
| 460 |
+
for entity, info in objects.items():
|
| 461 |
+
if 'parts' in info:
|
| 462 |
+
ref = f'annotation/object/{entity}/articulation.json'
|
| 463 |
+
json_write(view.path / ref, {'parts': list(info['parts'].values()), 'joints': [],
|
| 464 |
+
'hierarchy_semantics': 'semantic_containment',
|
| 465 |
+
'note': 'Unassociated source region, motion and asset nodes; original CAD trees retained in assets'})
|
| 466 |
+
view.component('articulation_' + entity, 'object/articulated/v1', ref, [], loc)
|
| 467 |
+
meta_path = view.path / f'annotation/object/{entity}/metainfo.json'
|
| 468 |
+
metadata = json.loads(meta_path.read_text())
|
| 469 |
+
metadata['articulation_ref'] = ref
|
| 470 |
+
json_write(meta_path, metadata)
|
| 471 |
+
if depth is not None:
|
| 472 |
+
dpath, dloc = depth
|
| 473 |
+
dmeta = probe(dpath)
|
| 474 |
+
if [dmeta['width'], dmeta['height']] != view.meta['camera']['image_size']:
|
| 475 |
+
raise ValueError('HOI4D depth grid differs from RGB')
|
| 476 |
+
if dmeta['pix_fmt'] != 'gray16le':
|
| 477 |
+
raise ValueError('unexpected HOI4D depth pixel format')
|
| 478 |
+
width, height = view.meta['camera']['image_size']
|
| 479 |
+
raw = work / 'depth.raw'
|
| 480 |
+
limits = ['-frames:v', str(n)] if args.max_frames else []
|
| 481 |
+
run(decode_args(dpath, 'gray16le') + limits + ['-y', str(raw)])
|
| 482 |
+
if raw.stat().st_size != n * width * height * 2:
|
| 483 |
+
raise ValueError('depth/RGB frame count or grid mismatch')
|
| 484 |
+
def depths():
|
| 485 |
+
with raw.open('rb') as inp:
|
| 486 |
+
for _ in range(n):
|
| 487 |
+
yield np.frombuffer(inp.read(width * height * 2), '<u2').reshape(height, width).astype(np.float32) / 1000
|
| 488 |
+
view.raster('depth', depths(), None, dloc | {'conversion': 'registered millimetre camera-Z to metres'})
|
| 489 |
+
else:
|
| 490 |
+
if find_file(args.root, 'DEPTH'):
|
| 491 |
+
raise ValueError('DEPTH source exists, but no matching depth video was found')
|
| 492 |
+
view.absent('depth', 'Depth source not downloaded', 'not_downloaded')
|
| 493 |
+
return view.finish()
|
| 494 |
+
|
| 495 |
+
|
| 496 |
+
def main(argv=None):
|
| 497 |
+
p = parser('HOI4D', __doc__)
|
| 498 |
+
p.set_defaults(release_id='shared-v1.0')
|
| 499 |
+
# Four workers reached 21 observed OS threads including timing; stay below the 24-thread budget.
|
| 500 |
+
p.add_argument('--workers', type=int, choices=range(1, 5), default=1,
|
| 501 |
+
help='Independent views in parallel, 1..4; codec/BLAS threads fixed at 1')
|
| 502 |
+
p.add_argument('--tasks', help='Comma-separated substrings of source sequence paths')
|
| 503 |
+
p.add_argument('--sessions', help='Comma-separated sessions')
|
| 504 |
+
p.add_argument('--categories', help='Comma-separated category numbers')
|
| 505 |
+
args = p.parse_args(argv)
|
| 506 |
+
if args.views and args.views != 'ego':
|
| 507 |
+
p.error('HOI4D source camera ID is ego')
|
| 508 |
+
paths = {key: find_file(args.root, name) for key, name in {
|
| 509 |
+
'release': 'HOI4D_release.zip', 'annotations': 'HOI4D_annotations.zip', 'hand': 'HOI4D_Hand_pose.zip',
|
| 510 |
+
'camera': 'camera_params.zip', 'cad': 'HOI4D_CAD_Model_for_release.zip'}.items()}
|
| 511 |
+
if not paths['release'] or not paths['annotations']:
|
| 512 |
+
p.error('HOI4D release and annotation ZIPs are required')
|
| 513 |
+
out = release(args, 'HOI4D')
|
| 514 |
+
mapping = Path(__file__).resolve().parent.parent / 'docs/hoi4d-RAW_TO_SHARED.md'
|
| 515 |
+
published_mapping = out / 'doc/RAW_TO_SHARED.md'
|
| 516 |
+
if published_mapping.exists() and published_mapping.read_bytes() != mapping.read_bytes():
|
| 517 |
+
raise ValueError('RAW_TO_SHARED.md changed; choose a new release-id')
|
| 518 |
+
if not published_mapping.exists():
|
| 519 |
+
shutil.copyfile(mapping, published_mapping)
|
| 520 |
+
torch.set_num_threads(1)
|
| 521 |
+
models = mano_models(args.mano_dir)
|
| 522 |
+
with ExitStack() as stack, tempfile.TemporaryDirectory(prefix='hoi4d-depth-') as wd:
|
| 523 |
+
archives = {key: stack.enter_context(zipfile.ZipFile(path)) if path else None for key, path in paths.items()}
|
| 524 |
+
sequences = sorted(name.removeprefix('HOI4D_release/').removesuffix('/align_rgb/image.mp4')
|
| 525 |
+
for name in archives['release'].namelist() if name.endswith('/align_rgb/image.mp4'))
|
| 526 |
+
if args.tasks:
|
| 527 |
+
sequences = [s for s in sequences if any(token in s for token in args.tasks.split(','))]
|
| 528 |
+
if args.sessions:
|
| 529 |
+
sequences = [s for s in sequences if s.split('/')[0] in args.sessions.split(',')]
|
| 530 |
+
if args.categories:
|
| 531 |
+
sequences = [s for s in sequences if re.search(r'/C(\d+)/', s)[1] in args.categories.split(',')]
|
| 532 |
+
if args.limit:
|
| 533 |
+
sequences = sequences[:args.limit]
|
| 534 |
+
if not sequences:
|
| 535 |
+
p.error('no matching source sequences')
|
| 536 |
+
depths, _ = extract_depths(args.root, sequences, Path(wd))
|
| 537 |
+
worker = threading.local()
|
| 538 |
+
worker_stacks = []
|
| 539 |
+
def init_worker():
|
| 540 |
+
owned = ExitStack()
|
| 541 |
+
try:
|
| 542 |
+
# ZipFile.read mutates a shared seek position: never share a handle across workers.
|
| 543 |
+
worker.archives = {key: owned.enter_context(zipfile.ZipFile(path)) if path else None
|
| 544 |
+
for key, path in paths.items()}
|
| 545 |
+
index_frames(worker.archives['annotations'])
|
| 546 |
+
if worker.archives['hand']:
|
| 547 |
+
index_frames(worker.archives['hand'])
|
| 548 |
+
except BaseException:
|
| 549 |
+
owned.close()
|
| 550 |
+
raise
|
| 551 |
+
worker_stacks.append(owned)
|
| 552 |
+
def convert_one(seq):
|
| 553 |
+
source = archives if args.workers == 1 else worker.archives
|
| 554 |
+
name = seq.replace('/', '_')
|
| 555 |
+
with sequence_dir(out, name) as target:
|
| 556 |
+
report = convert_sequence(seq, args, target / 'ego', source['release'], source['annotations'],
|
| 557 |
+
source['hand'], source['camera'], source['cad'], paths, models, depths.get(seq))
|
| 558 |
+
build_record(out, name, {'ego': report})
|
| 559 |
+
return seq
|
| 560 |
+
if args.workers == 1:
|
| 561 |
+
for seq in map(convert_one, sequences):
|
| 562 |
+
print(f'Converted {seq}', flush=True)
|
| 563 |
+
else:
|
| 564 |
+
try:
|
| 565 |
+
with ThreadPoolExecutor(max_workers=args.workers, initializer=init_worker) as pool:
|
| 566 |
+
for seq in pool.map(convert_one, sequences):
|
| 567 |
+
print(f'Converted {seq}', flush=True)
|
| 568 |
+
finally:
|
| 569 |
+
for owned in worker_stacks:
|
| 570 |
+
owned.close()
|
| 571 |
+
return 0
|
| 572 |
+
|
| 573 |
+
|
| 574 |
+
if __name__ == '__main__':
|
| 575 |
+
raise SystemExit(main())
|
| 576 |
+
|
| 577 |
+
# TODO(v2.0): 旧 bbox IoU 实例重分配属于推断,注释保留,不在 v1.0 执行。
|
| 578 |
+
# # 同类多实例(C8 双桶 / C2 双杯):2dBox 可用时按 IoU 复核归属
|
| 579 |
+
# cls = next(x[3] for x in cat["groups"] if x[0] == gk)
|
| 580 |
+
# sibs = [g for g in cat["groups"]
|
| 581 |
+
# if g[0] != gk and cls is not None and g[3] == cls]
|
| 582 |
+
# box = (d.get("2dBox") or {}).get("camera1")
|
| 583 |
+
# box = (box[0][0], box[0][1], box[1][0], box[1][1]) \
|
| 584 |
+
# if box and len(box) == 2 else None
|
| 585 |
+
# if box is not None and sibs:
|
| 586 |
+
# gvals = next(x[1] for x in cat["groups"] if x[0] == gk)
|
| 587 |
+
# best, best_iou = gk, box_iou(box, bbox_of(mask, gvals))
|
| 588 |
+
# for s in sibs:
|
| 589 |
+
# if ("obj", s[0]) not in tid_of_group:
|
| 590 |
+
# continue
|
| 591 |
+
# i = box_iou(box, bbox_of(mask, s[1]))
|
| 592 |
+
# if i > best_iou + 0.1 and i > 0.15:
|
| 593 |
+
# best, best_iou = s[0], i
|
| 594 |
+
# if best != gk:
|
| 595 |
+
# gk, iou_fixups = best, iou_fixups + 1
|
H2O/shared-v1.1/script/v1_0_snapshot/script/convert_visor_v1.0.py
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""VISOR source polygons and contact → CONTRACT.md v1.0, without rasterization or side inference."""
|
| 3 |
+
from collections import Counter
|
| 4 |
+
import hashlib
|
| 5 |
+
import json
|
| 6 |
+
import re
|
| 7 |
+
import shutil
|
| 8 |
+
import tempfile
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
import zipfile
|
| 11 |
+
|
| 12 |
+
import numpy as np
|
| 13 |
+
import torch
|
| 14 |
+
|
| 15 |
+
from warehouse_v1_0 import (View, build_record, find_file, jsonl_write, locator, parser,
|
| 16 |
+
release, roots, sequence_dir, source)
|
| 17 |
+
|
| 18 |
+
FRAME = re.compile(r'frame_(\d+)')
|
| 19 |
+
HAND = {300: 'left', 301: 'right'}
|
| 20 |
+
GLOVE = {303: 'left', 304: 'right'}
|
| 21 |
+
STATES = {'hand-not-in-contact': 'negative', 'glove-not-in-contact': 'negative',
|
| 22 |
+
'none-of-the-above': 'target_unannotated', 'inconclusive': 'unknown'}
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def hand_side(ann):
|
| 26 |
+
if ann['class_id'] in HAND:
|
| 27 |
+
return HAND[ann['class_id']]
|
| 28 |
+
if ann['class_id'] not in (60, 303, 304):
|
| 29 |
+
return None
|
| 30 |
+
raw = ann.get('on_which_hand')
|
| 31 |
+
raw = raw if isinstance(raw, list) else [raw]
|
| 32 |
+
sides = set()
|
| 33 |
+
for item in raw:
|
| 34 |
+
if item == 'left hand':
|
| 35 |
+
sides.add('left')
|
| 36 |
+
if item in ('right hand', 'rigth hand'):
|
| 37 |
+
sides.add('right')
|
| 38 |
+
if len(sides) == 1:
|
| 39 |
+
return next(iter(sides))
|
| 40 |
+
if not sides and ann['class_id'] in GLOVE:
|
| 41 |
+
return GLOVE[ann['class_id']]
|
| 42 |
+
return None
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def convert_video(video, split, annotation, ann_loc, rgb_zip, rgb_loc, mapping, args, target):
|
| 46 |
+
indexed = sorted(enumerate(annotation['video_annotations']), key=lambda row: int(FRAME.search(row[1]['image']['name'])[1]))
|
| 47 |
+
if args.max_frames:
|
| 48 |
+
indexed = indexed[:args.max_frames]
|
| 49 |
+
if len({row['image']['name'] for _, row in indexed}) != len(indexed):
|
| 50 |
+
raise ValueError('duplicate VISOR frame')
|
| 51 |
+
keys = lambda row, ann: (row['image']['subsequence'], ann['class_id'], ann['name'])
|
| 52 |
+
collisions = set()
|
| 53 |
+
for _, row in indexed:
|
| 54 |
+
collisions.update(key for key, number in Counter(keys(row, a) for a in row['annotations']).items() if number > 1)
|
| 55 |
+
frames, paths = [], []
|
| 56 |
+
with tempfile.TemporaryDirectory(prefix='visor-rgb-') as wd, zipfile.ZipFile(rgb_zip) as z:
|
| 57 |
+
work = Path(wd)
|
| 58 |
+
for original_index, row in indexed:
|
| 59 |
+
name = row['image']['name']
|
| 60 |
+
data = z.read(name)
|
| 61 |
+
path = work / Path(name).name
|
| 62 |
+
path.write_bytes(data)
|
| 63 |
+
paths.append(path)
|
| 64 |
+
loc = rgb_loc | {'nested_member': name, 'sha256': hashlib.sha256(data).hexdigest()}
|
| 65 |
+
frames.append(dict(source_frame_id=int(FRAME.search(name)[1]), source_locator=loc,
|
| 66 |
+
source_image=row['image'], original_frame_name=mapping.get(name),
|
| 67 |
+
annotation_matches={'segment': dict(source_frame_id=name, source_timestamp_ns=None,
|
| 68 |
+
clock_domain=None, match_method='index_map', delta_ns=None,
|
| 69 |
+
source_locator=ann_loc | {'record': f'video_annotations[{original_index}]'})}))
|
| 70 |
+
view = View(target, 'EPIC-KITCHENS-VISOR', args.release_id, video, 'ego', frames, sampling='sparse', split=split)
|
| 71 |
+
view.valid_rules = {
|
| 72 |
+
'segment': 'Selected sparse annotation frame present; all source polygons finite with at least three vertices and entity mapping valid',
|
| 73 |
+
'relations': 'At least one source in_contact_object value present; positive targets resolve in the same frame; unknown is an explicit usable status',
|
| 74 |
+
}
|
| 75 |
+
view.full_jpeg = getattr(args, 'jpeg_full_check', False)
|
| 76 |
+
view.meta.update(view_type='ego', split_scheme='VISOR_GroundTruth_SparseAnnotations', split_source_locator=ann_loc)
|
| 77 |
+
view.meta['sampling']['selection'] = {'representation': 'official sparse annotations', 'max_frames': args.max_frames}
|
| 78 |
+
view.rgb(paths, rgb_loc)
|
| 79 |
+
entities = {}
|
| 80 |
+
polygons, mappings, relations, relation_valid = [], [], [], []
|
| 81 |
+
for f, (original_index, row) in enumerate(indexed):
|
| 82 |
+
frame_loc = ann_loc | {'record': f'video_annotations[{original_index}]'}
|
| 83 |
+
id_map, labels, polys = {}, [], []
|
| 84 |
+
for code, ann in enumerate(row['annotations'], 1):
|
| 85 |
+
if code >= 65535:
|
| 86 |
+
raise ValueError('too many source instances')
|
| 87 |
+
sid = ann['id']
|
| 88 |
+
if sid in id_map:
|
| 89 |
+
raise ValueError('duplicate source instance ID within a frame')
|
| 90 |
+
side = hand_side(ann)
|
| 91 |
+
if side is not None:
|
| 92 |
+
entity = 'hand_' + side
|
| 93 |
+
else:
|
| 94 |
+
key = keys(row, ann)
|
| 95 |
+
identity = key + (sid, row['image']['name']) if key in collisions else key
|
| 96 |
+
entity = 'object_' + hashlib.sha256(json.dumps(identity).encode()).hexdigest()[:20]
|
| 97 |
+
if entity not in entities:
|
| 98 |
+
scope = 'frame' if key in collisions else 'subsequence'
|
| 99 |
+
scope_id = f'{video}:{row["image"]["name"]}' if scope == 'frame' else f'{video}:{key[0]}'
|
| 100 |
+
view.object(entity, frame_loc | {'source_instance_id': sid}, scope, scope_id,
|
| 101 |
+
category_id=ann['class_id'], name=ann['name'],
|
| 102 |
+
association_basis='source_frame_instance' if scope == 'frame' else 'official_subsequence_entity_name')
|
| 103 |
+
entities[entity] = True
|
| 104 |
+
id_map[sid] = entity
|
| 105 |
+
for polygon in ann.get('segments', []):
|
| 106 |
+
p = np.asarray(polygon)
|
| 107 |
+
if p.ndim != 2 or p.shape[1] != 2 or len(p) < 3 or not np.isfinite(p).all():
|
| 108 |
+
raise ValueError(f'invalid source polygon {sid}')
|
| 109 |
+
polys.append(dict(mask_value=code, polygons=ann.get('segments', [])))
|
| 110 |
+
labels.append(dict(mask_value=code, category_id=ann['class_id'], entity_id=entity,
|
| 111 |
+
part_id=None, source_instance_id=sid,
|
| 112 |
+
source_attributes={k: v for k, v in ann.items() if k != 'segments'}))
|
| 113 |
+
rr = []
|
| 114 |
+
provided = False
|
| 115 |
+
for ann in row['annotations']:
|
| 116 |
+
raw = ann.get('in_contact_object')
|
| 117 |
+
values = raw if isinstance(raw, list) else [raw]
|
| 118 |
+
for value in values:
|
| 119 |
+
if value is None:
|
| 120 |
+
continue
|
| 121 |
+
provided = True
|
| 122 |
+
status = STATES.get(value)
|
| 123 |
+
obj = None
|
| 124 |
+
if status is None:
|
| 125 |
+
if value not in id_map:
|
| 126 |
+
raise ValueError(f'unresolved source contact target {value} in {video} frame {f}')
|
| 127 |
+
status, obj = 'positive', id_map[value]
|
| 128 |
+
rr.append(dict(relation_type='contact', subject_id=id_map[ann['id']], object_id=obj,
|
| 129 |
+
status=status, source_value=value, source_locator=frame_loc | {'source_instance_id': ann['id']},
|
| 130 |
+
provenance=source('Resolve source contact ID against instances in this frame')))
|
| 131 |
+
polygons.append(dict(frame_index=f, instances=polys))
|
| 132 |
+
mappings.append(dict(frame_index=f, labels=labels))
|
| 133 |
+
relations.append(dict(frame_index=f, relations=rr))
|
| 134 |
+
relation_valid.append(provided)
|
| 135 |
+
jsonl_write(view.path / 'annotation/segment/polygons.jsonl', polygons)
|
| 136 |
+
jsonl_write(view.path / 'annotation/segment/instances.jsonl', mappings)
|
| 137 |
+
torch.save(torch.ones(len(frames), dtype=torch.bool, device='cpu'), view.path / 'annotation/segment/mask_valid.pt')
|
| 138 |
+
view.component('segment', 'segment/instance_polygons/v1', 'annotation/segment/polygons.jsonl', ['T'], ann_loc,
|
| 139 |
+
valid_ref='annotation/segment/mask_valid.pt', valid_axes=['T'], segmentation_type='instance',
|
| 140 |
+
mapping_ref='annotation/segment/instances.jsonl', coverage={'kind': 'unknown', 'exhaustive_ref': 'annotation/segment/instances.jsonl'})
|
| 141 |
+
view.relations(relations, relation_valid, ann_loc)
|
| 142 |
+
for component in ('depth', 'mano', 'keypoints_uv', 'keypoints_xyz', 'intrinsic', 'extrinsic'):
|
| 143 |
+
view.absent(component, 'Not provided by VISOR sparse source annotations')
|
| 144 |
+
return view.finish()
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
def main(argv=None):
|
| 148 |
+
p = parser('EPIC-KITCHENS-VISOR', __doc__)
|
| 149 |
+
p.add_argument('--videos', help='Comma-separated video names')
|
| 150 |
+
p.add_argument('--splits', default='train,val')
|
| 151 |
+
args = p.parse_args(argv)
|
| 152 |
+
wanted = set(args.videos.split(',')) if args.videos else None
|
| 153 |
+
splits = set(args.splits.split(','))
|
| 154 |
+
if not splits <= {'train', 'val'}:
|
| 155 |
+
p.error('only annotated train/val splits are available')
|
| 156 |
+
out = release(args, 'EPIC-KITCHENS-VISOR')
|
| 157 |
+
archive = find_file(args.root, 'EPIC-KITCHENS VISOR.zip')
|
| 158 |
+
with tempfile.TemporaryDirectory(prefix='visor-source-') as wd:
|
| 159 |
+
work = Path(wd)
|
| 160 |
+
if archive:
|
| 161 |
+
with zipfile.ZipFile(archive) as z:
|
| 162 |
+
suffix = 'GroundTruth-SparseAnnotations/annotations/'
|
| 163 |
+
members = [n for n in z.namelist() if suffix in n and n.endswith('.json')]
|
| 164 |
+
prefix = members[0].split(suffix)[0]
|
| 165 |
+
fm = json.loads(z.read(prefix + 'frame_mapping.json'))
|
| 166 |
+
done = 0
|
| 167 |
+
for member in sorted(members):
|
| 168 |
+
split, filename = member.split(suffix)[1].split('/')
|
| 169 |
+
video = Path(filename).stem
|
| 170 |
+
if split not in splits or wanted and video not in wanted:
|
| 171 |
+
continue
|
| 172 |
+
data = z.read(member)
|
| 173 |
+
rgb_member = prefix + f'GroundTruth-SparseAnnotations/rgb_frames/{split}/{video.split("_")[0]}/{video}.zip'
|
| 174 |
+
rgb_zip = work / (video + '.zip')
|
| 175 |
+
with z.open(rgb_member) as inp, rgb_zip.open('wb') as dest:
|
| 176 |
+
shutil.copyfileobj(inp, dest)
|
| 177 |
+
with sequence_dir(out, video) as dest:
|
| 178 |
+
report = convert_video(video, split, json.loads(data), locator(archive, member, data),
|
| 179 |
+
rgb_zip, locator(archive, rgb_member), fm.get(video, {}), args, dest / 'ego')
|
| 180 |
+
build_record(out, video, {'ego': report})
|
| 181 |
+
rgb_zip.unlink()
|
| 182 |
+
done += 1
|
| 183 |
+
print(f'Converted {video}', flush=True)
|
| 184 |
+
if args.limit and done >= args.limit:
|
| 185 |
+
break
|
| 186 |
+
else:
|
| 187 |
+
root = next((r for r in roots(args.root) if (r / 'GroundTruth-SparseAnnotations').is_dir()), None)
|
| 188 |
+
if root is None:
|
| 189 |
+
p.error('VISOR outer ZIP or extracted source directory not found')
|
| 190 |
+
fm = json.loads((root / 'frame_mapping.json').read_text()) if (root / 'frame_mapping.json').exists() else {}
|
| 191 |
+
done = 0
|
| 192 |
+
for split in sorted(splits):
|
| 193 |
+
for ann in sorted((root / 'GroundTruth-SparseAnnotations/annotations' / split).glob('*.json')):
|
| 194 |
+
video = ann.stem
|
| 195 |
+
if wanted and video not in wanted:
|
| 196 |
+
continue
|
| 197 |
+
rgb = root / f'GroundTruth-SparseAnnotations/rgb_frames/{split}/{video.split("_")[0]}/{video}.zip'
|
| 198 |
+
with sequence_dir(out, video) as dest:
|
| 199 |
+
report = convert_video(video, split, json.loads(ann.read_text()), locator(ann), rgb,
|
| 200 |
+
locator(rgb), fm.get(video, {}), args, dest / 'ego')
|
| 201 |
+
build_record(out, video, {'ego': report})
|
| 202 |
+
done += 1
|
| 203 |
+
if args.limit and done >= args.limit:
|
| 204 |
+
return 0
|
| 205 |
+
if not done:
|
| 206 |
+
p.error('no matching annotated videos found')
|
| 207 |
+
return 0
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
if __name__ == '__main__':
|
| 211 |
+
raise SystemExit(main())
|
| 212 |
+
|
| 213 |
+
# TODO(v2.0): 旧距离猜侧和单层掩码生成仅注释保留;v1.0 不执行。
|
| 214 |
+
# if side is None and len(frame_hands) == 1:
|
| 215 |
+
# # 空间门槛:脱下放在远处的手套不并入(实测双峰 0..25px / ≥44px)
|
| 216 |
+
# hb = frame_hands[0][1]
|
| 217 |
+
# gb = _bbox_of(polys)
|
| 218 |
+
# if hb and gb and _bbox_dist(gb, hb) <= GLOVE60_MERGE_BBOX_DIST:
|
| 219 |
+
# side = frame_hands[0][0]
|
| 220 |
+
# stats["glove60_merged_into_sole_hand"] += 1
|
| 221 |
+
# if side is None:
|
| 222 |
+
# stats["dropped_glove60_unresolved"] += 1
|
| 223 |
+
# id_disp[mid] = ("dropped", "glove60")
|
| 224 |
+
# continue
|
| 225 |
+
# def rasterize_and_encode(vdir, frames, frame_draw, zip_path, n, stats):
|
| 226 |
+
# """流式读 zip 内 jpg + 光栅化多边形 → rgb.mkv / mask.mkv;返回 (w, h)。"""
|
| 227 |
+
# from PIL import Image, ImageDraw
|
| 228 |
+
#
|
| 229 |
+
# with zipfile.ZipFile(zip_path) as zf:
|
| 230 |
+
# member_of = {}
|
| 231 |
+
# for nm in zf.namelist():
|
| 232 |
+
# member_of[os.path.basename(nm)] = nm
|
| 233 |
+
# names = [im["name"] for im in frames]
|
| 234 |
+
# missing = [nm for nm in names if nm not in member_of]
|
| 235 |
+
# if missing:
|
| 236 |
+
# raise RuntimeError(f"{len(missing)} annotated frames missing in zip, "
|
| 237 |
+
# f"e.g. {missing[:3]}")
|
| 238 |
+
# stats["zip_extra_members"] = len(member_of) - len(names)
|
| 239 |
+
#
|
| 240 |
+
# # 首帧定分辨率(官方 1920×1080,实测每帧校验)
|
| 241 |
+
# img0 = Image.open(io.BytesIO(zf.read(member_of[names[0]]))).convert("RGB")
|
| 242 |
+
# w, h = img0.size
|
| 243 |
+
#
|
| 244 |
+
# bin_img = Image.new("L", (w, h), 0)
|
| 245 |
+
# bin_draw = ImageDraw.Draw(bin_img)
|
| 246 |
+
# canvas = np.zeros((h, w), np.uint16)
|
| 247 |
+
# with VideoPipe(vdir / "mask.mkv", w, h, FPS, "mask") as mw, \
|
| 248 |
+
# VideoPipe(vdir / "rgb.mkv", w, h, FPS, "rgb") as rw:
|
| 249 |
+
# for f in range(n):
|
| 250 |
+
# canvas[:] = 0
|
| 251 |
+
# for pid, polys in frame_draw[f]:
|
| 252 |
+
# bin_draw.rectangle((0, 0, w, h), fill=0)
|
| 253 |
+
# for poly in polys:
|
| 254 |
+
# bin_draw.polygon([(float(x), float(y)) for x, y in poly], fill=255)
|
| 255 |
+
# arr = np.asarray(bin_img)
|
| 256 |
+
# canvas[arr > 0] = pid # 后画覆盖先画:物体→手(modal)
|
| 257 |
+
# mw.write(canvas)
|
| 258 |
+
# img = img0 if f == 0 else Image.open(
|
| 259 |
+
# io.BytesIO(zf.read(member_of[names[f]]))).convert("RGB")
|
| 260 |
+
# if img.size != (w, h):
|
| 261 |
+
# raise RuntimeError(f"frame {names[f]}: size {img.size} != {(w, h)}")
|
| 262 |
+
# rw.write(np.asarray(img))
|
| 263 |
+
# n_mask, n_rgb = mw.n, rw.n
|
| 264 |
+
# if (n_rgb, n_mask) != (n, n):
|
| 265 |
+
# raise RuntimeError(f"wrote rgb={n_rgb} mask={n_mask} != {n}")
|
| 266 |
+
# got = (count_frames(vdir / "rgb.mkv"), count_frames(vdir / "mask.mkv"))
|
| 267 |
+
# if got != (n, n):
|
| 268 |
+
# raise RuntimeError(f"encoded rgb={got[0]} mask={got[1]} != {n} (decode verify)")
|
| 269 |
+
# return w, h
|
| 270 |
+
#
|
| 271 |
+
#
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/operations/h2o-check-fallback.py
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Full coverage/numeric audit, plus representative persisted-media QC and offline HTML."""
|
| 2 |
+
import os
|
| 3 |
+
for key in ('OMP_NUM_THREADS','OPENBLAS_NUM_THREADS','MKL_NUM_THREADS','NUMEXPR_NUM_THREADS'):
|
| 4 |
+
os.environ[key]='1'
|
| 5 |
+
os.environ['HAND_WAREHOUSE_FFMPEG_THREADS']='4'
|
| 6 |
+
os.environ.pop('HAND_WAREHOUSE_FFV1_SLICES',None)
|
| 7 |
+
os.environ.pop('HAND_WAREHOUSE_MEDIA_TMPDIR',None)
|
| 8 |
+
import collections,datetime,hashlib,html,json,re,sys,time,zipfile
|
| 9 |
+
from concurrent.futures import ThreadPoolExecutor,as_completed
|
| 10 |
+
from pathlib import Path
|
| 11 |
+
from zoneinfo import ZoneInfo
|
| 12 |
+
import numpy as np
|
| 13 |
+
import torch
|
| 14 |
+
root=Path('/data/xuzhefeng/Datasets/uni-hoi-h2o-full-20260930-process16-pipe')
|
| 15 |
+
release=root/'H2O/shared-v1.0'
|
| 16 |
+
sys.path.insert(0,str(root/'frozen-code/scripts'))
|
| 17 |
+
from warehouse_v1_0 import SCHEMA,check_transform,check_valid_policy,check_view_type,safe_member,sha256
|
| 18 |
+
from render_h2o_validation import render
|
| 19 |
+
out=release/'doc/validation/final-quick-check'
|
| 20 |
+
out.mkdir(exist_ok=True)
|
| 21 |
+
torch.set_num_threads(1)
|
| 22 |
+
started=time.monotonic()
|
| 23 |
+
expected={}
|
| 24 |
+
with zipfile.ZipFile('/data/xuzhefeng/Datasets/Hand-Datasets-Raw/H2O/raw/data/label_split.zip') as z:
|
| 25 |
+
for name in z.namelist():
|
| 26 |
+
if '/action_' not in name:continue
|
| 27 |
+
for line in z.read(name).decode().splitlines():
|
| 28 |
+
fields=line.split()
|
| 29 |
+
if len(fields)>1 and fields[1]!='path':
|
| 30 |
+
seq=fields[1].replace('/','_')
|
| 31 |
+
expected[seq]=max(expected.get(seq,0),int(fields[-1])+1)
|
| 32 |
+
folders={p.name:p for p in (release/'data').iterdir() if p.is_dir()}
|
| 33 |
+
assert set(folders)==set(expected),(sorted(set(expected)-set(folders)),sorted(set(folders)-set(expected)))
|
| 34 |
+
assert len(expected)==184 and sum(expected.values())==114329
|
| 35 |
+
receipts={p.name.removesuffix('.build.json'):p for p in (release/'doc').glob('*.build.json')}
|
| 36 |
+
assert set(receipts)==set(expected)
|
| 37 |
+
assert 'EXIT=0' in (root/'full.status').read_text()
|
| 38 |
+
failures=[]
|
| 39 |
+
rows=[]
|
| 40 |
+
def require(ok,message):
|
| 41 |
+
if not ok:raise ValueError(message)
|
| 42 |
+
def load(path):
|
| 43 |
+
def cpu(storage,location):
|
| 44 |
+
require(location=='cpu',f'non-CPU storage: {path}')
|
| 45 |
+
return storage
|
| 46 |
+
obj=torch.load(path,map_location=cpu,weights_only=True)
|
| 47 |
+
require(type(obj) is torch.Tensor,f'non-tensor: {path}')
|
| 48 |
+
return obj.numpy()
|
| 49 |
+
def check_sequence(seq):
|
| 50 |
+
folder=folders[seq];n=expected[seq]
|
| 51 |
+
require({p.name for p in folder.iterdir() if p.is_dir()}=={f'cam{i}' for i in range(5)},'five-camera coverage')
|
| 52 |
+
receipt=json.loads(receipts[seq].read_text())
|
| 53 |
+
require(receipt['sequence_id']==seq and set(receipt['views'])=={f'cam{i}' for i in range(5)},'build receipt')
|
| 54 |
+
result=[]
|
| 55 |
+
for i in range(5):
|
| 56 |
+
cam=f'cam{i}';view=folder/cam
|
| 57 |
+
meta=json.loads((view/'metainfo.json').read_text())
|
| 58 |
+
require((meta['dataset_id'],meta['sequence_id'],meta['camera_id'],meta['num_frames'])==('H2O',seq,cam,n),'header/timeline')
|
| 59 |
+
require(meta['view_type']==('ego' if i==4 else 'exo'),'view role')
|
| 60 |
+
require(meta['sampling']['selection']=={'max_frames':None,'views':None},'unexpected subsampling')
|
| 61 |
+
check_view_type(meta)
|
| 62 |
+
components=meta['components']
|
| 63 |
+
require(all(components[k].get('available') for k in ('rgb','depth','mano','keypoints_xyz','intrinsic','extrinsic')),'required modality absent')
|
| 64 |
+
require(not components['segment']['available'] and not components['relations']['available'],'unexpected synthesized component')
|
| 65 |
+
rgb_sources=[];depth_sources=[];rgb_count=depth_count=0
|
| 66 |
+
with (view/'camera/frames.jsonl').open() as inp:
|
| 67 |
+
count=0
|
| 68 |
+
for index,line in enumerate(inp):
|
| 69 |
+
f=json.loads(line)
|
| 70 |
+
require(f['frame_index']==index and f['source_frame_id']==index,'source frame index')
|
| 71 |
+
require(f['sync_id']==f'{seq.replace("_","/")}:{index}','synchronization ID')
|
| 72 |
+
sources=f['component_sources']
|
| 73 |
+
for kind,loc in sources.items():
|
| 74 |
+
require(re.fullmatch('[0-9a-f]{64}',loc.get('sha256','')) is not None,f'source SHA256: {kind}')
|
| 75 |
+
require(f'/{cam}/' in loc.get('member',''),'wrong source camera')
|
| 76 |
+
rgb_sources.append('rgb' in sources);depth_sources.append('depth' in sources)
|
| 77 |
+
rgb_count+=rgb_sources[-1];depth_count+=depth_sources[-1];count+=1
|
| 78 |
+
require(count==n,'frames.jsonl length')
|
| 79 |
+
numeric=0
|
| 80 |
+
object_names=[]
|
| 81 |
+
for key,c in components.items():
|
| 82 |
+
if not c['available']:continue
|
| 83 |
+
for field in ('data_ref','valid_ref','mapping_ref'):
|
| 84 |
+
if c.get(field):
|
| 85 |
+
path=safe_member(view,c[field])
|
| 86 |
+
require(path.is_file() and path.stat().st_size>0,f'missing/empty {c[field]}')
|
| 87 |
+
schema=SCHEMA['components'][c['schema_id']]
|
| 88 |
+
if c.get('valid_policy'):check_valid_policy(c,n)
|
| 89 |
+
valid=load(view/c['valid_ref']) if c.get('valid_ref','').endswith('.pt') else None
|
| 90 |
+
if valid is not None:
|
| 91 |
+
shape=schema.get('valid_shape')
|
| 92 |
+
require(valid.dtype==np.bool_ and valid.shape[0]==n,f'{key}: validity dtype/timeline')
|
| 93 |
+
if shape:require(len(shape)==valid.ndim and all(not isinstance(s,int) or valid.shape[j]==s for j,s in enumerate(shape)),f'{key}: validity shape')
|
| 94 |
+
if key=='rgb':require(np.array_equal(valid,np.asarray(rgb_sources)), 'RGB existence validity mismatch')
|
| 95 |
+
if c['data_ref'].endswith('.pt'):
|
| 96 |
+
arr=load(view/c['data_ref']);numeric+=1
|
| 97 |
+
require(arr.dtype==np.float32 and arr.shape[0]==n,f'{key}: dtype/timeline')
|
| 98 |
+
shape=schema.get('shape')
|
| 99 |
+
if shape:require(len(shape)==arr.ndim and all(not isinstance(s,int) or arr.shape[j]==s for j,s in enumerate(shape)),f'{key}: tensor shape')
|
| 100 |
+
if valid is not None:
|
| 101 |
+
require(arr.shape[:valid.ndim]==valid.shape and np.isfinite(arr[valid]).all() and np.isnan(arr[~valid]).all(),f'{key}: finite/NaN validity semantics')
|
| 102 |
+
if c['schema_id'] in ('transform/se3/v1','object/rigid/v1'):check_transform(arr[valid])
|
| 103 |
+
if key=='intrinsic':require(np.allclose(arr[:,2],[0,0,1]) and (arr[:,0,0]>0).all() and (arr[:,1,1]>0).all(),'camera intrinsics')
|
| 104 |
+
if key.startswith('mesh_'):object_names.append(key.removeprefix('mesh_'))
|
| 105 |
+
proof=receipt['views'][cam]
|
| 106 |
+
require(not proof['unresolved'],'unresolved QC components')
|
| 107 |
+
media={}
|
| 108 |
+
for p in proof['validation']:
|
| 109 |
+
if p.get('profile')==components['rgb']['storage']['profile'] and p.get('all_frames_exact') is True:media['rgb']=p
|
| 110 |
+
elif p.get('component') in ('depth','depth_valid'):media[p['component']]=p
|
| 111 |
+
require(set(media)=={'rgb','depth','depth_valid'},'media roundtrip proof missing')
|
| 112 |
+
for key,p in media.items():
|
| 113 |
+
require(p.get('all_frames_exact') is True and re.fullmatch('[0-9a-f]{64}',p.get('decoded_sha256','')) is not None,f'{key}: failed original roundtrip proof')
|
| 114 |
+
require((view/'observation'/f'{key}.mkv').stat().st_size==p['bytes'],f'{key}: encoded file size changed since conversion')
|
| 115 |
+
result.append({'sequence_id':seq,'camera':cam,'frames':n,'numeric_components':numeric,
|
| 116 |
+
'rgb_source_frames':rgb_count,'depth_source_frames':depth_count,'objects':sorted(object_names)})
|
| 117 |
+
return result
|
| 118 |
+
|
| 119 |
+
result=check_sequence('subject1_k2_6')
|
| 120 |
+
from warehouse_v1_0 import decoded_digest
|
| 121 |
+
receipt=json.loads(receipts['subject1_k2_6'].read_text())
|
| 122 |
+
view=folders['subject1_k2_6']/'cam0'
|
| 123 |
+
meta=json.loads((view/'metainfo.json').read_text())
|
| 124 |
+
proofs=receipt['views']['cam0']['validation']
|
| 125 |
+
verified=[]
|
| 126 |
+
for name,pix in (('rgb','rgb24'),('depth','gray16le'),('depth_valid','gray')):
|
| 127 |
+
p=next(x for x in proofs if (x.get('profile')==meta['components']['rgb']['storage']['profile'] if name=='rgb' else x.get('component')==name))
|
| 128 |
+
digest,size,seconds=decoded_digest(view/'observation'/f'{name}.mkv',pix)
|
| 129 |
+
assert digest==p['decoded_sha256'],(name,digest,p['decoded_sha256'])
|
| 130 |
+
expected_bytes=expected['subject1_k2_6']*1280*720*({'rgb':3,'depth':4,'depth_valid':1}[name])
|
| 131 |
+
assert size==expected_bytes,(name,size,expected_bytes)
|
| 132 |
+
verified.append({'component':name,'decoded_sha256':digest,'decoded_bytes':size,'seconds':seconds})
|
| 133 |
+
page=render(view,out/'subject1_k2_6_cam0_fallback')
|
| 134 |
+
json_result={'passed':True,'views':result,'full_decode_comparison':verified,'html':str(page.relative_to(out)),
|
| 135 |
+
'note':'Registered lossless H.264 fallback; all current decoded media digests equal original conversion receipts'}
|
| 136 |
+
(out/'H264_FALLBACK_CHECK.json').write_text(json.dumps(json_result,indent=2)+'\n')
|
| 137 |
+
print('FALLBACK_PASS',json.dumps(json_result),flush=True)
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/operations/h2o-finalize-quick-validation.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import datetime,html,json,shutil
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
from zoneinfo import ZoneInfo
|
| 4 |
+
release=Path('/data/xuzhefeng/Datasets/uni-hoi-h2o-full-20260930-process16-pipe/H2O/shared-v1.0')
|
| 5 |
+
out=release/'doc/validation/final-quick-check'
|
| 6 |
+
report=json.loads((out/'QUICK_VALIDATION.json').read_text())
|
| 7 |
+
assert report['failures']==[{'sequence':'subject1_k2_6','error':"ValueError('rgb: failed original roundtrip proof')"}]
|
| 8 |
+
fallback=json.loads((out/'H264_FALLBACK_CHECK.json').read_text());assert fallback['passed']
|
| 9 |
+
shutil.copy2(out/'QUICK_VALIDATION.json',out/'INITIAL_CHECKER_ALERT.json')
|
| 10 |
+
rows=fallback['views']
|
| 11 |
+
report['checked_sequences']+=1;report['checked_views']+=len(rows)
|
| 12 |
+
report['checked_view_frames']+=sum(r['frames'] for r in rows)
|
| 13 |
+
report['rgb_source_frames']+=sum(r['rgb_source_frames'] for r in rows)
|
| 14 |
+
report['depth_source_frames']+=sum(r['depth_source_frames'] for r in rows)
|
| 15 |
+
report['numeric_components']+=sum(r['numeric_components'] for r in rows)
|
| 16 |
+
report['samples'].append({'sequence_id':'subject1_k2_6','camera':'cam0','object':'espresso',
|
| 17 |
+
'frames':678,'passed':True,'html':fallback['html'],
|
| 18 |
+
'extra_check':'Full RGB/depth/valid current decoded digests equal original receipts'})
|
| 19 |
+
report['resolved_alerts']=[{'view':'subject1_k2_6/cam0','classification':'Registered lossless H.264 fallback, not missing data or corruption',
|
| 20 |
+
'original_checker_limitation':'First pass selected only FFV1 proofs; fixed to select the profile actually declared by metainfo',
|
| 21 |
+
'followup':'All five cameras rechecked; problematic view RGB, depth and validity fully decoded and matched original SHA256/byte length'}]
|
| 22 |
+
report['failures']=[];report['passed']=True
|
| 23 |
+
report['time']=datetime.datetime.now(ZoneInfo('Asia/Shanghai')).isoformat()
|
| 24 |
+
report['sample_views']=len(report['samples'])
|
| 25 |
+
assert report['checked_sequences']==184 and report['checked_views']==920
|
| 26 |
+
assert report['checked_view_frames']==report['rgb_source_frames']==report['depth_source_frames']==571645
|
| 27 |
+
report['rgb_profiles']={}
|
| 28 |
+
for meta in (release/'data').glob('*/cam*/metainfo.json'):
|
| 29 |
+
name=json.loads(meta.read_text())['components']['rgb']['storage']['profile']
|
| 30 |
+
report['rgb_profiles'][name]=report['rgb_profiles'].get(name,0)+1
|
| 31 |
+
(out/'QUICK_VALIDATION.json').write_text(json.dumps(report,ensure_ascii=False,indent=2)+'\n')
|
| 32 |
+
summary={k:v for k,v in report.items() if k!='samples'}
|
| 33 |
+
(out/'index.html').write_text('<!doctype html><html lang="zh"><meta charset="utf-8"><title>H2O 全量后抽样验收</title><h1>H2O 全量后抽样验收</h1><p>自动检查通过不等于原始几何标注准确。覆盖四个 subject、八类物体、ego/exo;青色为源手部关节点投影,粉色为源物体点投影,仅用于预览。</p><ul>'+''.join('<li><a href="'+html.escape(x['html'],quote=True)+'">'+html.escape(x['sequence_id']+' '+x['camera']+' '+x['object'])+'</a></li>' for x in sorted(report['samples'],key=lambda x:(x['object'],x['sequence_id'],x['camera'])))+'</ul><pre>'+html.escape(json.dumps(summary,ensure_ascii=False,indent=2))+'</pre></html>')
|
| 34 |
+
operations=release/'script/provenance/operations'
|
| 35 |
+
for src in ('h2o-quick-validation.py','h2o-check-fallback.py','h2o-finalize-quick-validation.py'):
|
| 36 |
+
shutil.copy2(Path('/tmp')/src,operations/src)
|
| 37 |
+
shutil.copy2('/tmp/h2o-quick-validation.log',out/'INITIAL_RUN.log')
|
| 38 |
+
shutil.copy2('/tmp/h2o-fallback-check.log',out/'FALLBACK_RUN.log')
|
| 39 |
+
print(json.dumps(summary,ensure_ascii=False,indent=2),flush=True)
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/operations/h2o-pipeline-bench-job.sh
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -u
|
| 3 |
+
cd /home/xuzhefeng/Projects/uni-hoi-dataset || exit 1
|
| 4 |
+
case "$1" in
|
| 5 |
+
old) code=/data/xuzhefeng/Datasets/uni-hoi-h2o-full-20260930-w4-c10-d10/frozen-code/scripts/convert_h2o_v1.0.py; extra=();;
|
| 6 |
+
v8) code=/tmp/h2o-stream-v8-recovery/scripts/convert_h2o_v1.0.py; extra=(--view-workers 8 --stream-media);;
|
| 7 |
+
v8ram) code=/tmp/h2o-stream-v8ram-recovery/scripts/convert_h2o_v1.0.py; extra=(--view-workers 8 --stream-media --ram-stage-dir /dev/shm/xuzhefeng-h2o-pipeline-v8ram-20260930 --ram-stage-gib 32);;
|
| 8 |
+
s16) code=/tmp/h2o-stream-s16-recovery/scripts/convert_h2o_v1.0.py; extra=(--view-workers 16 --stream-media --ffv1-slices 16 --ram-stage-dir /dev/shm/xuzhefeng-h2o-pipeline-s16-20260930 --ram-stage-gib 32);;
|
| 9 |
+
pipeline) code=/tmp/h2o-stream-pipeline-recovery/scripts/convert_h2o_v1.0.py; extra=(--view-workers 16 --camera-pipeline --stream-media --ffv1-slices 16 --ram-stage-dir /dev/shm/xuzhefeng-h2o-pipeline-overlap-20260930 --ram-stage-gib 32);;
|
| 10 |
+
process) code=/tmp/h2o-process-pipeline-recovery/scripts/convert_h2o_v1.0.py; extra=(--view-workers 16 --view-backend processes --camera-pipeline --stream-media --ffv1-slices 16 --ram-stage-dir /dev/shm/xuzhefeng-h2o-pipeline-process-20260930 --ram-stage-gib 32);;
|
| 11 |
+
v16) code=/tmp/h2o-stream-v8-recovery/scripts/convert_h2o_v1.0.py; extra=(--view-workers 16 --stream-media);;
|
| 12 |
+
*) exit 2;;
|
| 13 |
+
esac
|
| 14 |
+
root=/data/xuzhefeng/Datasets/uni-hoi-h2o-pipeline-bench-20260930
|
| 15 |
+
caseout="$root/$1"
|
| 16 |
+
mkdir -p "$caseout/scratch"
|
| 17 |
+
export TMPDIR="$caseout/scratch" PYTHONUNBUFFERED=1
|
| 18 |
+
cg=$(awk -F: '$1=="0" {print $3}' /proc/self/cgroup)
|
| 19 |
+
cat "/sys/fs/cgroup$cg/cpu.stat" > "$caseout/cpu.start"
|
| 20 |
+
date -Is > "$caseout/start"
|
| 21 |
+
.venv/bin/python "$code" --root "$root/raw" --out "$caseout" --workers 4 --codec-threads 10 --decode-threads 10 --depth-threads 4 --max-frames 200 --mano-dir /home/xuzhefeng/Projects/WiLoR/mano_data "${extra[@]}" > "$caseout/convert.log" 2>&1
|
| 22 |
+
code=$?
|
| 23 |
+
cat "/sys/fs/cgroup$cg/cpu.stat" > "$caseout/cpu.end"
|
| 24 |
+
printf '%s\n' "$code" > "$caseout/exit"
|
| 25 |
+
exit "$code"
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/operations/h2o-pipeline-benchmark.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import datetime,json,os,subprocess,time
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
root=Path('/data/xuzhefeng/Datasets/uni-hoi-h2o-pipeline-bench-20260930')
|
| 4 |
+
cpus=os.cpu_count()
|
| 5 |
+
records=[]
|
| 6 |
+
for mode in ('old','v8'):
|
| 7 |
+
unit=f'h2o-pipeline-{mode}-20260930.scope'
|
| 8 |
+
begin=time.monotonic()
|
| 9 |
+
proc=subprocess.Popen(['systemd-run','--user','--scope','--unit='+unit,'-p','CPUAccounting=yes',
|
| 10 |
+
'/bin/bash','/tmp/h2o-pipeline-bench-job.sh',mode])
|
| 11 |
+
path=Path(f'/sys/fs/cgroup/user.slice/user-{os.getuid()}.slice/user@{os.getuid()}.service/app.slice/{unit}')
|
| 12 |
+
samples=[]
|
| 13 |
+
while proc.poll() is None:
|
| 14 |
+
try:
|
| 15 |
+
stat=dict(line.split() for line in (path/'cpu.stat').read_text().splitlines())
|
| 16 |
+
samples.append((time.monotonic()-begin,int(stat['usage_usec'])))
|
| 17 |
+
except (FileNotFoundError,PermissionError):pass
|
| 18 |
+
time.sleep(0.5)
|
| 19 |
+
elapsed=time.monotonic()-begin
|
| 20 |
+
assert proc.returncode==0,(mode,(root/mode/'convert.log').read_text()[-3000:])
|
| 21 |
+
def usage(name):return int(dict(line.split() for line in (root/mode/name).read_text().splitlines())['usage_usec'])
|
| 22 |
+
total=usage('cpu.end')-usage('cpu.start')
|
| 23 |
+
peak=max(((b[1]-a[1])/(b[0]-a[0])/1e6/cpus*100 for a,b in zip(samples,samples[10:])),default=0)
|
| 24 |
+
row=dict(mode=mode,seconds=elapsed,cpu_seconds=total/1e6,cpu_percent_machine=total/elapsed/1e6/cpus*100,
|
| 25 |
+
peak_5s_cpu_percent_machine=peak,samples=samples)
|
| 26 |
+
records.append(row)
|
| 27 |
+
(root/'performance.json').write_text(json.dumps(records,indent=2)+'\n')
|
| 28 |
+
print(json.dumps({k:v for k,v in row.items() if k!='samples'}),flush=True)
|
| 29 |
+
# Prove actual media and every numeric tensor match, not just wall-clock speed.
|
| 30 |
+
os.environ['HAND_WAREHOUSE_FFMPEG_THREADS'] = '10'
|
| 31 |
+
import sys
|
| 32 |
+
sys.path.insert(0,'/tmp/h2o-stream-v8-recovery/scripts')
|
| 33 |
+
from warehouse_v1_0 import decoded_digest,validate_view
|
| 34 |
+
import torch
|
| 35 |
+
for view in sorted((root/'old/H2O/shared-v1.0/data').glob('*/cam*')):
|
| 36 |
+
rel=view.relative_to(root/'old/H2O/shared-v1.0/data')
|
| 37 |
+
candidate=root/'v8/H2O/shared-v1.0/data'/rel
|
| 38 |
+
assert validate_view(candidate)['validated']
|
| 39 |
+
for name,pix in (('rgb','rgb24'),('depth','gray16le'),('depth_valid','gray')):
|
| 40 |
+
aa=decoded_digest(view/'observation'/f'{name}.mkv',pix)[:2]
|
| 41 |
+
bb=decoded_digest(candidate/'observation'/f'{name}.mkv',pix)[:2]
|
| 42 |
+
assert aa==bb,(rel,name)
|
| 43 |
+
for pt in view.rglob('*.pt'):
|
| 44 |
+
aa=torch.load(pt,weights_only=True)
|
| 45 |
+
bb=torch.load(candidate/pt.relative_to(view),weights_only=True)
|
| 46 |
+
assert aa.shape==bb.shape and aa.dtype==bb.dtype and aa.numpy().tobytes()==bb.numpy().tobytes(),(rel,pt)
|
| 47 |
+
print('PASS all 10 real views: full RGB/depth/valid decoded digests and every numeric tensor match',flush=True)
|
| 48 |
+
(root/'validation.exit').write_text('0\n')
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/operations/h2o-pipeline-process-benchmark.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import datetime,json,os,subprocess,time
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
root=Path('/data/xuzhefeng/Datasets/uni-hoi-h2o-pipeline-bench-20260930')
|
| 4 |
+
cpus=os.cpu_count()
|
| 5 |
+
records=[]
|
| 6 |
+
for mode in ('process',):
|
| 7 |
+
unit=f'h2o-pipeline-{mode}-20260930.scope'
|
| 8 |
+
begin=time.monotonic()
|
| 9 |
+
proc=subprocess.Popen(['systemd-run','--user','--scope','--unit='+unit,'-p','CPUAccounting=yes',
|
| 10 |
+
'/bin/bash','/tmp/h2o-pipeline-bench-job.sh',mode])
|
| 11 |
+
path=Path(f'/sys/fs/cgroup/user.slice/user-{os.getuid()}.slice/user@{os.getuid()}.service/app.slice/{unit}')
|
| 12 |
+
samples=[]
|
| 13 |
+
while proc.poll() is None:
|
| 14 |
+
try:
|
| 15 |
+
stat=dict(line.split() for line in (path/'cpu.stat').read_text().splitlines())
|
| 16 |
+
samples.append((time.monotonic()-begin,int(stat['usage_usec'])))
|
| 17 |
+
except (FileNotFoundError,PermissionError):pass
|
| 18 |
+
time.sleep(0.5)
|
| 19 |
+
elapsed=time.monotonic()-begin
|
| 20 |
+
assert proc.returncode==0,(mode,(root/mode/'convert.log').read_text()[-3000:])
|
| 21 |
+
def usage(name):return int(dict(line.split() for line in (root/mode/name).read_text().splitlines())['usage_usec'])
|
| 22 |
+
total=usage('cpu.end')-usage('cpu.start')
|
| 23 |
+
peak=max(((b[1]-a[1])/(b[0]-a[0])/1e6/cpus*100 for a,b in zip(samples,samples[10:])),default=0)
|
| 24 |
+
row=dict(mode=mode,seconds=elapsed,cpu_seconds=total/1e6,cpu_percent_machine=total/elapsed/1e6/cpus*100,
|
| 25 |
+
peak_5s_cpu_percent_machine=peak,samples=samples)
|
| 26 |
+
records.append(row)
|
| 27 |
+
(root/'performance-process.json').write_text(json.dumps(records,indent=2)+'\n')
|
| 28 |
+
print(json.dumps({k:v for k,v in row.items() if k!='samples'}),flush=True)
|
| 29 |
+
# Prove actual media and every numeric tensor match, not just wall-clock speed.
|
| 30 |
+
os.environ['HAND_WAREHOUSE_FFMPEG_THREADS'] = '10'
|
| 31 |
+
import sys
|
| 32 |
+
sys.path.insert(0,'/tmp/h2o-process-pipeline-recovery/scripts')
|
| 33 |
+
from warehouse_v1_0 import decoded_digest,validate_view
|
| 34 |
+
import torch
|
| 35 |
+
for view in sorted((root/'old/H2O/shared-v1.0/data').glob('*/cam*')):
|
| 36 |
+
rel=view.relative_to(root/'old/H2O/shared-v1.0/data')
|
| 37 |
+
candidate=root/'process/H2O/shared-v1.0/data'/rel
|
| 38 |
+
assert validate_view(candidate)['validated']
|
| 39 |
+
for name,pix in (('rgb','rgb24'),('depth','gray16le'),('depth_valid','gray')):
|
| 40 |
+
aa=decoded_digest(view/'observation'/f'{name}.mkv',pix)[:2]
|
| 41 |
+
bb=decoded_digest(candidate/'observation'/f'{name}.mkv',pix)[:2]
|
| 42 |
+
assert aa==bb,(rel,name)
|
| 43 |
+
for pt in view.rglob('*.pt'):
|
| 44 |
+
aa=torch.load(pt,weights_only=True)
|
| 45 |
+
bb=torch.load(candidate/pt.relative_to(view),weights_only=True)
|
| 46 |
+
assert aa.shape==bb.shape and aa.dtype==bb.dtype and aa.numpy().tobytes()==bb.numpy().tobytes(),(rel,pt)
|
| 47 |
+
print('PASS all 10 real views: full RGB/depth/valid decoded digests and every numeric tensor match',flush=True)
|
| 48 |
+
(root/'validation-process.exit').write_text('0\n')
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/operations/h2o-prepare-pipeline-bench.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json,os,tarfile,shutil
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
root=Path('/data/xuzhefeng/Datasets/uni-hoi-h2o-pipeline-bench-20260930')
|
| 4 |
+
root.mkdir(exist_ok=True)
|
| 5 |
+
raw=root/'raw'; raw.mkdir(exist_ok=True)
|
| 6 |
+
old=Path('/data/xuzhefeng/Datasets/uni-hoi-h2o-full-20260930-w4-c10-d10')
|
| 7 |
+
records=[]
|
| 8 |
+
for subj in ('subject3','subject4'):
|
| 9 |
+
subject=next((old/'scratch').glob('h2o-source-*/'+subj))
|
| 10 |
+
sequences=[p for p in subject.glob('*/*') if all((p/f'cam{i}/rgb/000199.png').is_file() for i in range(5))]
|
| 11 |
+
assert sequences, (subj,subject)
|
| 12 |
+
seq=sequences[0]
|
| 13 |
+
snapshot=root/'input-snapshot'/subj/seq.relative_to(subject)
|
| 14 |
+
for src in seq.glob('cam*/*/*'):
|
| 15 |
+
if src.is_file() and src.parent.name in ('rgb','depth','cam_pose','hand_pose','hand_pose_mano','obj_pose','obj_pose_rt') and int(src.stem)<200:
|
| 16 |
+
dest=snapshot/src.relative_to(seq);dest.parent.mkdir(parents=True,exist_ok=True)
|
| 17 |
+
os.link(src,dest)
|
| 18 |
+
for src in seq.glob('cam*/cam_intrinsics.txt'):
|
| 19 |
+
dest=snapshot/src.relative_to(seq);dest.parent.mkdir(parents=True,exist_ok=True);os.link(src,dest)
|
| 20 |
+
archive=raw/f'{subj}_v1_1.tar.gz'
|
| 21 |
+
with tarfile.open(archive,'w:gz',compresslevel=0) as tf:
|
| 22 |
+
tf.add(snapshot,arcname=str(snapshot.relative_to(root/'input-snapshot')))
|
| 23 |
+
records.append({'sequence':str(snapshot.relative_to(root/'input-snapshot')),'frames':200,'views':5,'archive':str(archive),
|
| 24 |
+
'origin':str(seq),'gzip_compression_level':0})
|
| 25 |
+
for name in ('object.zip','label_split.zip'):
|
| 26 |
+
os.link(Path('/data/xuzhefeng/Datasets/Hand-Datasets-Raw/H2O/raw/data')/name,raw/name)
|
| 27 |
+
(root/'input-manifest.json').write_text(json.dumps(records,indent=2)+'\n')
|
| 28 |
+
print('PREPARED',records,flush=True)
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/operations/h2o-prepare-process-full.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Preserve complete persistent views; frozen process pipeline only changes execution/storage work."""
|
| 2 |
+
import datetime,json,os,shutil
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
old=Path('/data/xuzhefeng/Datasets/uni-hoi-h2o-full-20260930-w4-c10-d10')
|
| 5 |
+
new=Path('/data/xuzhefeng/Datasets/uni-hoi-h2o-full-20260930-process16-pipe')
|
| 6 |
+
new.mkdir()
|
| 7 |
+
shutil.copytree('/tmp/h2o-process-pipeline-recovery',new/'frozen-code')
|
| 8 |
+
release=new/'H2O/shared-v1.0'
|
| 9 |
+
for directory in ('data','doc/validation','script/provenance/previous-run','script/provenance/operations'):
|
| 10 |
+
(release/directory).mkdir(parents=True,exist_ok=True)
|
| 11 |
+
history=release/'script/provenance/previous-run'
|
| 12 |
+
shutil.copytree(old/'H2O/shared-v1.0/script',history/'script')
|
| 13 |
+
shutil.copytree(old/'frozen-code/docs',history/'docs')
|
| 14 |
+
for name in ('full.log','full.status','run-full.sh'):
|
| 15 |
+
shutil.copy2(old/name,history/name)
|
| 16 |
+
records=[]
|
| 17 |
+
for record in sorted((old/'H2O/shared-v1.0/doc').glob('*.build.json')):
|
| 18 |
+
build=json.loads(record.read_text());seq=build['sequence_id']
|
| 19 |
+
assert Path(seq).name==seq and seq not in ('.','..')
|
| 20 |
+
assert set(build['views'])=={f'cam{i}' for i in range(5)}
|
| 21 |
+
folder=old/'H2O/shared-v1.0/data'/seq
|
| 22 |
+
for cam in build['views']:assert (folder/cam/'metainfo.json').is_file()
|
| 23 |
+
shutil.copytree(folder,release/'data'/seq,copy_function=os.link)
|
| 24 |
+
shutil.copy2(record,release/'doc'/record.name)
|
| 25 |
+
records.append({'sequence_id':seq,'original_script_sha256':build['scripts']})
|
| 26 |
+
manifest={'time':datetime.datetime.now().astimezone().isoformat(),'source_run':str(old),'destination_run':str(new),
|
| 27 |
+
'reason':'Native bytes unchanged; process/view pipeline, streaming RAW and bounded RAM staging',
|
| 28 |
+
'target_cpu_percent_machine':80,'cpu_limit':None,'reused_sequences':records,
|
| 29 |
+
'reuse':'Read-only hardlinks; original build records retained; source frame/component SHA256 checked on resume',
|
| 30 |
+
'previous_run_provenance':'script/provenance/previous-run'}
|
| 31 |
+
(release/'doc/RESTART_PROVENANCE.json').write_text(json.dumps(manifest,indent=2)+'\n')
|
| 32 |
+
operations=release/'script/provenance/operations'
|
| 33 |
+
for name in ('h2o-prepare-process-full.py','h2o-switch-process-full.sh','h2o-pipeline-benchmark.py',
|
| 34 |
+
'h2o-pipeline-process-benchmark.py','h2o-pipeline-bench-job.sh','h2o-prepare-pipeline-bench.py',
|
| 35 |
+
'h2o-process-final-tests.log','h2o-shared-final-tests.log'):
|
| 36 |
+
shutil.copy2(Path('/tmp')/name,operations/name)
|
| 37 |
+
bench=Path('/data/xuzhefeng/Datasets/uni-hoi-h2o-pipeline-bench-20260930')
|
| 38 |
+
for p in bench.glob('performance*.json'):shutil.copy2(p,release/'doc/validation'/p.name)
|
| 39 |
+
shutil.copy2(bench/'input-manifest.json',release/'doc/validation/PIPELINE_BENCH_INPUTS.json')
|
| 40 |
+
shutil.copy2('/tmp/h2o-pipeline-process-benchmark.log',release/'doc/validation/PIPELINE_BENCHMARK.log')
|
| 41 |
+
shutil.copy2('/tmp/h2o-runtime-profile.log',release/'doc/validation/BEFORE_RUNTIME_PROFILE.log')
|
| 42 |
+
shutil.copy2('/tmp/h2o-current-iostat.log',release/'doc/validation/BEFORE_IOSTAT.log')
|
| 43 |
+
for destination in (new/'run-full.sh',release/'script/run-full.sh'):
|
| 44 |
+
shutil.copy2('/tmp/h2o-run-process-full.sh',destination)
|
| 45 |
+
print('REUSED_SEQUENCES',len(records),'REUSED_VIEWS',5*len(records),flush=True)
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/operations/h2o-process-final-tests.log
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Converted subject1/h1/0
|
| 2 |
+
Converted subject2/h1/0
|
| 3 |
+
Converted subject3/h1/0
|
| 4 |
+
Converted subject4/h1/0
|
| 5 |
+
Converted subject1/h1/0
|
| 6 |
+
Archive subject1_v1_1.tar.gz: 1 sequences
|
| 7 |
+
Converted subject2/h1/0
|
| 8 |
+
Archive subject2_v1_1.tar.gz: 1 sequences
|
| 9 |
+
Converted subject3/h1/0
|
| 10 |
+
Archive subject3_v1_1.tar.gz: 1 sequences
|
| 11 |
+
Converted subject4/h1/0
|
| 12 |
+
Archive subject4_v1_1.tar.gz: 1 sequences
|
| 13 |
+
Converted subject2/h1/0
|
| 14 |
+
Converted subject3/h1/0
|
| 15 |
+
Converted subject1/h1/0
|
| 16 |
+
Archive subject1_v1_1.tar.gz: 1 sequences
|
| 17 |
+
Archive subject2_v1_1.tar.gz: 1 sequences
|
| 18 |
+
Archive subject3_v1_1.tar.gz: 1 sequences
|
| 19 |
+
Converted subject4/h1/0
|
| 20 |
+
Archive subject4_v1_1.tar.gz: 1 sequences
|
| 21 |
+
Verified existing subject1/h1/0
|
| 22 |
+
Verified existing subject3/h1/0
|
| 23 |
+
Archive subject1_v1_1.tar.gz: 1 sequences
|
| 24 |
+
Verified existing subject2/h1/0
|
| 25 |
+
Verified existing subject4/h1/0
|
| 26 |
+
Archive subject2_v1_1.tar.gz: 1 sequences
|
| 27 |
+
Archive subject3_v1_1.tar.gz: 1 sequences
|
| 28 |
+
Archive subject4_v1_1.tar.gz: 1 sequences
|
| 29 |
+
Camera-order fallback: subject1/h1/0
|
| 30 |
+
Converted subject1/h1/0
|
| 31 |
+
Converted subject2/h1/0
|
| 32 |
+
Converted subject1/h1/0
|
| 33 |
+
Archive subject1_v1_1.tar.gz: 1 sequences
|
| 34 |
+
Archive subject2_v1_1.tar.gz: 1 sequences
|
| 35 |
+
Converted subject3/h1/0
|
| 36 |
+
Archive subject3_v1_1.tar.gz: 1 sequences
|
| 37 |
+
Converted subject4/h1/0
|
| 38 |
+
Archive subject4_v1_1.tar.gz: 1 sequences
|
| 39 |
+
PASS H2O pipe RGB/depth, RAM annotations, shared view pool 1/4/8, four archive workers, codec/decode 1/4/10, ordered depth 1/2/4 and missing-depth preservation, no resume PNG writes, RGB FFV1-only, depth and persistent QC
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/operations/h2o-quick-validation.py
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Full coverage/numeric audit, plus representative persisted-media QC and offline HTML."""
|
| 2 |
+
import os
|
| 3 |
+
for key in ('OMP_NUM_THREADS','OPENBLAS_NUM_THREADS','MKL_NUM_THREADS','NUMEXPR_NUM_THREADS'):
|
| 4 |
+
os.environ[key]='1'
|
| 5 |
+
os.environ['HAND_WAREHOUSE_FFMPEG_THREADS']='4'
|
| 6 |
+
os.environ.pop('HAND_WAREHOUSE_FFV1_SLICES',None)
|
| 7 |
+
os.environ.pop('HAND_WAREHOUSE_MEDIA_TMPDIR',None)
|
| 8 |
+
import collections,datetime,hashlib,html,json,re,sys,time,zipfile
|
| 9 |
+
from concurrent.futures import ThreadPoolExecutor,as_completed
|
| 10 |
+
from pathlib import Path
|
| 11 |
+
from zoneinfo import ZoneInfo
|
| 12 |
+
import numpy as np
|
| 13 |
+
import torch
|
| 14 |
+
root=Path('/data/xuzhefeng/Datasets/uni-hoi-h2o-full-20260930-process16-pipe')
|
| 15 |
+
release=root/'H2O/shared-v1.0'
|
| 16 |
+
sys.path.insert(0,str(root/'frozen-code/scripts'))
|
| 17 |
+
from warehouse_v1_0 import SCHEMA,check_transform,check_valid_policy,check_view_type,safe_member,sha256
|
| 18 |
+
from render_h2o_validation import render
|
| 19 |
+
out=release/'doc/validation/final-quick-check'
|
| 20 |
+
out.mkdir(exist_ok=True)
|
| 21 |
+
torch.set_num_threads(1)
|
| 22 |
+
started=time.monotonic()
|
| 23 |
+
expected={}
|
| 24 |
+
with zipfile.ZipFile('/data/xuzhefeng/Datasets/Hand-Datasets-Raw/H2O/raw/data/label_split.zip') as z:
|
| 25 |
+
for name in z.namelist():
|
| 26 |
+
if '/action_' not in name:continue
|
| 27 |
+
for line in z.read(name).decode().splitlines():
|
| 28 |
+
fields=line.split()
|
| 29 |
+
if len(fields)>1 and fields[1]!='path':
|
| 30 |
+
seq=fields[1].replace('/','_')
|
| 31 |
+
expected[seq]=max(expected.get(seq,0),int(fields[-1])+1)
|
| 32 |
+
folders={p.name:p for p in (release/'data').iterdir() if p.is_dir()}
|
| 33 |
+
assert set(folders)==set(expected),(sorted(set(expected)-set(folders)),sorted(set(folders)-set(expected)))
|
| 34 |
+
assert len(expected)==184 and sum(expected.values())==114329
|
| 35 |
+
receipts={p.name.removesuffix('.build.json'):p for p in (release/'doc').glob('*.build.json')}
|
| 36 |
+
assert set(receipts)==set(expected)
|
| 37 |
+
assert 'EXIT=0' in (root/'full.status').read_text()
|
| 38 |
+
failures=[]
|
| 39 |
+
rows=[]
|
| 40 |
+
def require(ok,message):
|
| 41 |
+
if not ok:raise ValueError(message)
|
| 42 |
+
def load(path):
|
| 43 |
+
def cpu(storage,location):
|
| 44 |
+
require(location=='cpu',f'non-CPU storage: {path}')
|
| 45 |
+
return storage
|
| 46 |
+
obj=torch.load(path,map_location=cpu,weights_only=True)
|
| 47 |
+
require(type(obj) is torch.Tensor,f'non-tensor: {path}')
|
| 48 |
+
return obj.numpy()
|
| 49 |
+
def check_sequence(seq):
|
| 50 |
+
folder=folders[seq];n=expected[seq]
|
| 51 |
+
require({p.name for p in folder.iterdir() if p.is_dir()}=={f'cam{i}' for i in range(5)},'five-camera coverage')
|
| 52 |
+
receipt=json.loads(receipts[seq].read_text())
|
| 53 |
+
require(receipt['sequence_id']==seq and set(receipt['views'])=={f'cam{i}' for i in range(5)},'build receipt')
|
| 54 |
+
result=[]
|
| 55 |
+
for i in range(5):
|
| 56 |
+
cam=f'cam{i}';view=folder/cam
|
| 57 |
+
meta=json.loads((view/'metainfo.json').read_text())
|
| 58 |
+
require((meta['dataset_id'],meta['sequence_id'],meta['camera_id'],meta['num_frames'])==('H2O',seq,cam,n),'header/timeline')
|
| 59 |
+
require(meta['view_type']==('ego' if i==4 else 'exo'),'view role')
|
| 60 |
+
require(meta['sampling']['selection']=={'max_frames':None,'views':None},'unexpected subsampling')
|
| 61 |
+
check_view_type(meta)
|
| 62 |
+
components=meta['components']
|
| 63 |
+
require(all(components[k].get('available') for k in ('rgb','depth','mano','keypoints_xyz','intrinsic','extrinsic')),'required modality absent')
|
| 64 |
+
require(not components['segment']['available'] and not components['relations']['available'],'unexpected synthesized component')
|
| 65 |
+
rgb_sources=[];depth_sources=[];rgb_count=depth_count=0
|
| 66 |
+
with (view/'camera/frames.jsonl').open() as inp:
|
| 67 |
+
count=0
|
| 68 |
+
for index,line in enumerate(inp):
|
| 69 |
+
f=json.loads(line)
|
| 70 |
+
require(f['frame_index']==index and f['source_frame_id']==index,'source frame index')
|
| 71 |
+
require(f['sync_id']==f'{seq.replace("_","/")}:{index}','synchronization ID')
|
| 72 |
+
sources=f['component_sources']
|
| 73 |
+
for kind,loc in sources.items():
|
| 74 |
+
require(re.fullmatch('[0-9a-f]{64}',loc.get('sha256','')) is not None,f'source SHA256: {kind}')
|
| 75 |
+
require(f'/{cam}/' in loc.get('member',''),'wrong source camera')
|
| 76 |
+
rgb_sources.append('rgb' in sources);depth_sources.append('depth' in sources)
|
| 77 |
+
rgb_count+=rgb_sources[-1];depth_count+=depth_sources[-1];count+=1
|
| 78 |
+
require(count==n,'frames.jsonl length')
|
| 79 |
+
numeric=0
|
| 80 |
+
object_names=[]
|
| 81 |
+
for key,c in components.items():
|
| 82 |
+
if not c['available']:continue
|
| 83 |
+
for field in ('data_ref','valid_ref','mapping_ref'):
|
| 84 |
+
if c.get(field):
|
| 85 |
+
path=safe_member(view,c[field])
|
| 86 |
+
require(path.is_file() and path.stat().st_size>0,f'missing/empty {c[field]}')
|
| 87 |
+
schema=SCHEMA['components'][c['schema_id']]
|
| 88 |
+
if c.get('valid_policy'):check_valid_policy(c,n)
|
| 89 |
+
valid=load(view/c['valid_ref']) if c.get('valid_ref','').endswith('.pt') else None
|
| 90 |
+
if valid is not None:
|
| 91 |
+
shape=schema.get('valid_shape')
|
| 92 |
+
require(valid.dtype==np.bool_ and valid.shape[0]==n,f'{key}: validity dtype/timeline')
|
| 93 |
+
if shape:require(len(shape)==valid.ndim and all(not isinstance(s,int) or valid.shape[j]==s for j,s in enumerate(shape)),f'{key}: validity shape')
|
| 94 |
+
if key=='rgb':require(np.array_equal(valid,np.asarray(rgb_sources)), 'RGB existence validity mismatch')
|
| 95 |
+
if c['data_ref'].endswith('.pt'):
|
| 96 |
+
arr=load(view/c['data_ref']);numeric+=1
|
| 97 |
+
require(arr.dtype==np.float32 and arr.shape[0]==n,f'{key}: dtype/timeline')
|
| 98 |
+
shape=schema.get('shape')
|
| 99 |
+
if shape:require(len(shape)==arr.ndim and all(not isinstance(s,int) or arr.shape[j]==s for j,s in enumerate(shape)),f'{key}: tensor shape')
|
| 100 |
+
if valid is not None:
|
| 101 |
+
require(arr.shape[:valid.ndim]==valid.shape and np.isfinite(arr[valid]).all() and np.isnan(arr[~valid]).all(),f'{key}: finite/NaN validity semantics')
|
| 102 |
+
if c['schema_id'] in ('transform/se3/v1','object/rigid/v1'):check_transform(arr[valid])
|
| 103 |
+
if key=='intrinsic':require(np.allclose(arr[:,2],[0,0,1]) and (arr[:,0,0]>0).all() and (arr[:,1,1]>0).all(),'camera intrinsics')
|
| 104 |
+
if key.startswith('mesh_'):object_names.append(key.removeprefix('mesh_'))
|
| 105 |
+
proof=receipt['views'][cam]
|
| 106 |
+
require(not proof['unresolved'],'unresolved QC components')
|
| 107 |
+
media={}
|
| 108 |
+
for p in proof['validation']:
|
| 109 |
+
if p.get('profile')==components['rgb']['storage']['profile'] and p.get('all_frames_exact') is True:media['rgb']=p
|
| 110 |
+
elif p.get('component') in ('depth','depth_valid'):media[p['component']]=p
|
| 111 |
+
require(set(media)=={'rgb','depth','depth_valid'},'media roundtrip proof missing')
|
| 112 |
+
for key,p in media.items():
|
| 113 |
+
require(p.get('all_frames_exact') is True and re.fullmatch('[0-9a-f]{64}',p.get('decoded_sha256','')) is not None,f'{key}: failed original roundtrip proof')
|
| 114 |
+
require((view/'observation'/f'{key}.mkv').stat().st_size==p['bytes'],f'{key}: encoded file size changed since conversion')
|
| 115 |
+
result.append({'sequence_id':seq,'camera':cam,'frames':n,'numeric_components':numeric,
|
| 116 |
+
'rgb_source_frames':rgb_count,'depth_source_frames':depth_count,'objects':sorted(object_names)})
|
| 117 |
+
return result
|
| 118 |
+
with ThreadPoolExecutor(max_workers=4) as pool:
|
| 119 |
+
jobs={pool.submit(check_sequence,seq):seq for seq in sorted(expected)}
|
| 120 |
+
for job in as_completed(jobs):
|
| 121 |
+
seq=jobs[job]
|
| 122 |
+
try:rows.extend(job.result())
|
| 123 |
+
except Exception as exc:failures.append({'sequence':seq,'error':repr(exc)})
|
| 124 |
+
if len(rows)%100==0:print('STRUCTURAL_VIEWS',len(rows),'FAILURES',len(failures),flush=True)
|
| 125 |
+
print('STRUCTURAL_COMPLETE',len(rows),'FAILURES',failures,flush=True)
|
| 126 |
+
# Balance subjects while covering all eight source object classes; include matching exo views.
|
| 127 |
+
objects=('book','espresso','lotion','spray','milk','cocoa','chips','cappuccino')
|
| 128 |
+
selected=[]
|
| 129 |
+
for j,name in enumerate(objects):
|
| 130 |
+
subject=f'subject{j%4+1}_'
|
| 131 |
+
candidates=[r for r in rows if r['camera']=='cam4' and name in r['objects']]
|
| 132 |
+
require(candidates,f'no output for object {name}')
|
| 133 |
+
own=[r for r in candidates if r['sequence_id'].startswith(subject)]
|
| 134 |
+
r=min(own or candidates,key=lambda x:(x['frames'],x['sequence_id']))
|
| 135 |
+
selected.append((r['sequence_id'],'cam4',name))
|
| 136 |
+
selected.append((r['sequence_id'],'cam0',name))
|
| 137 |
+
samples=[]
|
| 138 |
+
def full_sample(item):
|
| 139 |
+
seq,cam,name=item
|
| 140 |
+
view=folders[seq]/cam
|
| 141 |
+
destination=out/f'{seq}_{cam}'
|
| 142 |
+
page=render(view,destination) # Reuse persisted contract QC, depth semantics, frame snapshots, native mesh preview.
|
| 143 |
+
return {'sequence_id':seq,'camera':cam,'object':name,'frames':expected[seq],
|
| 144 |
+
'passed':True,'html':str(page.relative_to(out))}
|
| 145 |
+
with ThreadPoolExecutor(max_workers=4) as pool:
|
| 146 |
+
jobs={pool.submit(full_sample,item):item for item in selected}
|
| 147 |
+
for job in as_completed(jobs):
|
| 148 |
+
item=jobs[job]
|
| 149 |
+
try:samples.append(job.result());print('SAMPLE_PASS',item,flush=True)
|
| 150 |
+
except Exception as exc:failures.append({'sample':item,'error':repr(exc)});print('SAMPLE_FAIL',item,repr(exc),flush=True)
|
| 151 |
+
report={'time':datetime.datetime.now(ZoneInfo('Asia/Shanghai')).isoformat(),'elapsed_seconds':time.monotonic()-started,
|
| 152 |
+
'release':str(release),'passed':not failures,'scope':'All sequence/camera coverage, frame/source manifests, all numeric tensors and original media receipts; 16 representative full persisted-view QC checks and offline previews. Not a new all-video source-pixel comparison.',
|
| 153 |
+
'expected_sequences':len(expected),'expected_sync_frames':sum(expected.values()),
|
| 154 |
+
'checked_sequences':len(rows)//5,'checked_views':len(rows),'checked_view_frames':sum(r['frames'] for r in rows),
|
| 155 |
+
'rgb_source_frames':sum(r['rgb_source_frames'] for r in rows),'depth_source_frames':sum(r['depth_source_frames'] for r in rows),
|
| 156 |
+
'numeric_components':sum(r['numeric_components'] for r in rows),'samples':samples,'failures':failures,
|
| 157 |
+
'next_step':'Human inspection of representative offline HTML; automatic QC is not proof of source geometric accuracy.'}
|
| 158 |
+
(out/'QUICK_VALIDATION.json').write_text(json.dumps(report,ensure_ascii=False,indent=2)+'\n')
|
| 159 |
+
(out/'index.html').write_text('<!doctype html><html lang="zh"><meta charset="utf-8"><title>H2O 全量后抽样验收</title><h1>H2O 全量后抽样验收</h1><p>自动检查通过不等于源几何标注正确;以下为四个 subject、八类物体、ego/exo 的源数据预览。</p><ul>'+''.join('<li><a href="'+html.escape(x['html'],quote=True)+'">'+html.escape(x['sequence_id']+' '+x['camera']+' '+x['object'])+'</a></li>' for x in sorted(samples,key=lambda x:(x['object'],x['camera'])))+'</ul><pre>'+html.escape(json.dumps({k:v for k,v in report.items() if k not in ('samples',)},ensure_ascii=False,indent=2))+'</pre></html>')
|
| 160 |
+
print('FINAL_REPORT',json.dumps({k:v for k,v in report.items() if k!='samples'},ensure_ascii=False),flush=True)
|
| 161 |
+
raise SystemExit(0 if report['passed'] else 1)
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/operations/h2o-shared-final-tests.log
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
PASS: RGB full/prefix hashes, source depth frames, depth/valid/segment bits and missing-frame rejection
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/operations/h2o-switch-process-full.sh
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -euo pipefail
|
| 3 |
+
cd /home/xuzhefeng/Projects/uni-hoi-dataset
|
| 4 |
+
test "$(cat /tmp/h2o-process-final-tests.exit)" = 0
|
| 5 |
+
test "$(cat /tmp/h2o-shared-final-tests.exit)" = 0
|
| 6 |
+
test "$(cat /tmp/h2o-pipeline-process-benchmark.exit)" = 0
|
| 7 |
+
test ! -e /data/xuzhefeng/Datasets/uni-hoi-h2o-full-20260930-process16-pipe
|
| 8 |
+
old=/data/xuzhefeng/Datasets/uni-hoi-h2o-full-20260930-w4-c10-d10
|
| 9 |
+
printf '\nRECONFIGURE=%s REASON=process16_camera_pipeline_ram32_streaming\n' "$(date -Is)" >> "$old/full.status"
|
| 10 |
+
systemctl --user stop h2o-full-d10-20260930.scope
|
| 11 |
+
.venv/bin/python /tmp/h2o-prepare-process-full.py
|
| 12 |
+
systemd-run --user --scope --unit=h2o-full-process16-20260930 -p CPUAccounting=yes /bin/bash /data/xuzhefeng/Datasets/uni-hoi-h2o-full-20260930-process16-pipe/run-full.sh
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/operations/watch-steady-cpu.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Measure the whole process tree only after conversion FFmpeg is active; no CPU-fill work."""
|
| 2 |
+
import datetime,json,os,time
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
unit='h2o-full-process16-20260930.scope'
|
| 5 |
+
cg=Path(f'/sys/fs/cgroup/user.slice/user-{os.getuid()}.slice/user@{os.getuid()}.service/app.slice/{unit}')
|
| 6 |
+
root=Path('/data/xuzhefeng/Datasets/uni-hoi-h2o-full-20260930-process16-pipe')
|
| 7 |
+
report=root/'H2O/shared-v1.0/doc/validation/STEADY_CPU_5MIN.json'
|
| 8 |
+
start_wait=time.monotonic()
|
| 9 |
+
while time.monotonic()-start_wait<7200:
|
| 10 |
+
if not (cg/'cgroup.procs').exists():
|
| 11 |
+
print('Scope exited before a steady conversion sample',flush=True);raise SystemExit(1)
|
| 12 |
+
ffmpeg=False
|
| 13 |
+
for pid in (cg/'cgroup.procs').read_text().split():
|
| 14 |
+
try:ffmpeg |= Path('/proc',pid,'comm').read_text().strip()=='ffmpeg'
|
| 15 |
+
except FileNotFoundError:pass
|
| 16 |
+
if ffmpeg:break
|
| 17 |
+
time.sleep(5)
|
| 18 |
+
else:
|
| 19 |
+
print('No conversion FFmpeg within two hours; no steady CPU claim made',flush=True);raise SystemExit(2)
|
| 20 |
+
def sample():
|
| 21 |
+
values=dict(line.split() for line in (cg/'cpu.stat').read_text().splitlines())
|
| 22 |
+
return time.monotonic(),int(values['usage_usec'])
|
| 23 |
+
begin=datetime.datetime.now().astimezone().isoformat()
|
| 24 |
+
samples=[sample()]
|
| 25 |
+
for _ in range(60):
|
| 26 |
+
time.sleep(5)
|
| 27 |
+
try:samples.append(sample())
|
| 28 |
+
except FileNotFoundError:
|
| 29 |
+
print('Scope exited during sample; inspect full.status',flush=True);raise SystemExit(1)
|
| 30 |
+
cpus=os.cpu_count()
|
| 31 |
+
intervals=[(b[1]-a[1])/(b[0]-a[0])/1e6/cpus*100 for a,b in zip(samples,samples[1:])]
|
| 32 |
+
result={'start':begin,'end':datetime.datetime.now().astimezone().isoformat(),'logical_cpus':cpus,
|
| 33 |
+
'whole_scope_cpu_percent_machine':(samples[-1][1]-samples[0][1])/(samples[-1][0]-samples[0][0])/1e6/cpus*100,
|
| 34 |
+
'highest_5sec_cpu_percent_machine':max(intervals),'lowest_5sec_cpu_percent_machine':min(intervals),
|
| 35 |
+
'target_percent':80,'intervals_percent_machine':intervals,'samples':samples,
|
| 36 |
+
'scope':unit,'includes':'All scope threads and child processes, including children already exited'}
|
| 37 |
+
report.write_text(json.dumps(result,indent=2)+'\n')
|
| 38 |
+
print(json.dumps({k:v for k,v in result.items() if k not in ('samples','intervals_percent_machine')}),flush=True)
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/docs/CONTRACT.md
ADDED
|
@@ -0,0 +1,457 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 手物数据仓库统一约定 v1.0
|
| 2 |
+
|
| 3 |
+
格式版本:`hand-warehouse/1.0`。存储约定:`lossless-video-2026-09-18`。
|
| 4 |
+
|
| 5 |
+
范围限于手物交互重建。按本任务纳入的源模态转换,不要求每个数据集填满所有组件。缺失模态、尚未下载、语义未核实分别报告,不能互相替代。
|
| 6 |
+
|
| 7 |
+
本文定义各字段的含义与使用规则,机器可读注册表见 [schema.json](schema.json)。两者互相补充;如有冲突,应先核实并统一定义。
|
| 8 |
+
|
| 9 |
+
## 1. 目录
|
| 10 |
+
|
| 11 |
+
```text
|
| 12 |
+
hand-datasets/
|
| 13 |
+
<dataset_name>/
|
| 14 |
+
raw/
|
| 15 |
+
doc/ # 官方说明、来源与校验记录
|
| 16 |
+
script/ # 官方下载脚本、必要包装脚本
|
| 17 |
+
data/ # 保留原始包,不原地解压或改写
|
| 18 |
+
<dataset_version>/
|
| 19 |
+
doc/ # 发布说明、schema、来源清单
|
| 20 |
+
script/ # 转换、校验脚本及运行配置
|
| 21 |
+
data/
|
| 22 |
+
<sequence_id>/
|
| 23 |
+
<camera_id>/
|
| 24 |
+
metainfo.json
|
| 25 |
+
observation/
|
| 26 |
+
rgb.mkv
|
| 27 |
+
rgb_valid.pt
|
| 28 |
+
depth.mkv # float32 深度的可逆视频编码
|
| 29 |
+
depth_valid.mkv # 逐像素 bool 的无损视频编码
|
| 30 |
+
camera/
|
| 31 |
+
frames.jsonl
|
| 32 |
+
intrinsic.pt
|
| 33 |
+
intrinsic_valid.pt
|
| 34 |
+
extrinsic.pt
|
| 35 |
+
extrinsic_valid.pt
|
| 36 |
+
annotation/
|
| 37 |
+
mano/
|
| 38 |
+
motion.pt
|
| 39 |
+
motion_valid.pt
|
| 40 |
+
visibility.pt
|
| 41 |
+
keypoints/
|
| 42 |
+
uv.pt
|
| 43 |
+
uv_valid.pt
|
| 44 |
+
xyz.pt
|
| 45 |
+
xyz_valid.pt
|
| 46 |
+
visibility.pt # 源数据有时提供
|
| 47 |
+
object/
|
| 48 |
+
<object_id>/
|
| 49 |
+
assets/ # 该物体的网格、材质、纹理及部件资产
|
| 50 |
+
<mesh_id>.obj
|
| 51 |
+
pose.pt
|
| 52 |
+
pose_valid.pt
|
| 53 |
+
visibility.pt
|
| 54 |
+
metainfo.json # 物体身份、类别、mesh、尺寸与部件引用
|
| 55 |
+
articulation.json
|
| 56 |
+
keypoints/
|
| 57 |
+
vertex_part_ids.pt
|
| 58 |
+
joint_state.pt
|
| 59 |
+
joint_state_valid.pt
|
| 60 |
+
parts/<part_id>/pose.pt
|
| 61 |
+
parts/<part_id>/pose_valid.pt
|
| 62 |
+
segment/
|
| 63 |
+
mask.mkv
|
| 64 |
+
mask_valid.pt
|
| 65 |
+
instances.jsonl
|
| 66 |
+
contact/
|
| 67 |
+
relations.jsonl
|
| 68 |
+
<subject_id>__<object_id>/ # 对应实体间的距离/接触区域
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
目录展示可能存在的组件,不要求填满。具体文件、字段和缺省规则分别见后续对应小节。原始包的解压发生在临时工作区,raw 内原始包保持不变。
|
| 72 |
+
|
| 73 |
+
## 2. 相机视图的 metainfo.json
|
| 74 |
+
|
| 75 |
+
### 2.1 顶层字段与发布信息
|
| 76 |
+
|
| 77 |
+
每个相机视图必须有 `metainfo.json`。以下字段除另行说明外均为必填:
|
| 78 |
+
|
| 79 |
+
| 字段 | 填写内容 |
|
| 80 |
+
|---|---|
|
| 81 |
+
| schema_version | 结构版本,本版为 `hand-warehouse/1.0` |
|
| 82 |
+
| dataset_id | 数据集的逻辑标识 |
|
| 83 |
+
| release_id | 本次数据发布版本,对应目录中的 dataset_version |
|
| 84 |
+
| sequence_id | 所属序列或独立图片样本的标识 |
|
| 85 |
+
| camera_id | 当前相机视图标识 |
|
| 86 |
+
| sample_type | `image` 或 `video`,规则见 2.2 |
|
| 87 |
+
| num_frames | 当前视图帧数 T,所有随帧组件按同一时间轴组织 |
|
| 88 |
+
| hand_slots | 固定为 `["left", "right"]`;解剖学左右的使用规则见 5.1 |
|
| 89 |
+
| sampling | 采样类型、源 FPS、帧索引引用及选择策略,见 2.2 |
|
| 90 |
+
| camera | 当前相机模型与图像尺寸,见 2.3 |
|
| 91 |
+
| components | 实际提供的组件及其文件、schema、有效性和来源,见 2.5 |
|
| 92 |
+
| split | `train/val/test/unknown`,划分协议见 2.4 |
|
| 93 |
+
| view_type | 可选,`ego/exo/unknown` |
|
| 94 |
+
|
| 95 |
+
`dataset_version` 是数据发布版本;`schema_version` 是结构版本,两者独立。原始包校验摘要、官方来源和转换配置应记录在发布清单中。解压发生在临时工作区,原始包保持不变。
|
| 96 |
+
|
| 97 |
+
### 2.2 图片、视频与 sampling
|
| 98 |
+
|
| 99 |
+
`sample_type=image`:允许单图 T=1、`sampling.type=single`,也允许将独立图片批量装入一个视频容器,T>1 时 `sampling.type=independent`、`source_fps=null`。分片大小按数据集选择;FreiHAND 默认每片最多 4096 张,训练与评估分开,尾片不补帧。该数量不是其他数据集的强制要求;同批分辨率、相机模型类型及划分协议一致。每行 frames 必须有稳定且唯一的 `sample_id`、原始文件定位;内参、手形状等仍逐帧保留,不能因打包而共享错误的标定或身份。`sequence_id` 在这里仅是批次标识,不代表真实序列;不得按相邻帧推断跟踪、同步或接触延续。源 camera_id、image_variant、split 等随样本变化时放在 frames 的对应字段中。真实采集时间未知则 timestamp_ns=null。合成背景变体不视为真实多相机。
|
| 100 |
+
|
| 101 |
+
`sample_type=video`:`sampling.type=dense/sparse`;`source_fps` 是真实采集 FPS,未知为 null。非连续取样必须保留源帧号和已知源时间,不可用采样后索引除以 FPS 冒充源时间。可另记采样策略与步长。
|
| 102 |
+
|
| 103 |
+
shared 可以仅存所选 RGB 帧对应的数据。OakInk2 图像/动捕不同采样率时用 annotation_matches 明确映射;不要求将未采样动捕点硬塞进 T。多视角身份和源同步关系要保留;选择了哪些帧/相机及原因写在 sampling 中。
|
| 104 |
+
|
| 105 |
+
`sampling.frames_ref` 指向 `camera/frames.jsonl`。帧号、逐帧时间、同步与标注匹配记录的结构见 4.1;MKV 封装时间的约定见 3.1。
|
| 106 |
+
|
| 107 |
+
### 2.3 camera 模型声明
|
| 108 |
+
|
| 109 |
+
`camera` 至少包含 `model`、`schema_id`、`image_size:[W,H]`。模型未知使用 `unknown` 和 `null`,不猜成针孔。实际内参、畸变及外参数组放在 `camera/`,各模型的固定结构见第 4 节。
|
| 110 |
+
|
| 111 |
+
### 2.4 split 与划分协议
|
| 112 |
+
|
| 113 |
+
保留上游划分,不将同一采集序列的相邻帧随意拆到不同集合。
|
| 114 |
+
|
| 115 |
+
有官方划分时必填 split_scheme 和 split_source_locator,split_scheme 区分如 Dex-YCB s0/s1、ARCTIC P1/P2 等选定协议;不知道时 split=unknown 并给理由,不凭空分配。每发布可选择一种协议;存在逐帧差异时 frames 中的 split 覆盖视图默认值,并登记其来源。
|
| 116 |
+
|
| 117 |
+
### 2.5 components 组件登记
|
| 118 |
+
|
| 119 |
+
组件表的键是本发布内唯一名称,例如 `rgb`、`depth`、`mano`、`keypoints_uv`。每个已提供组件声明以下信息;模态特有参数在第 3–5 节对应小节中定义。
|
| 120 |
+
|
| 121 |
+
| 字段 | 约定 |
|
| 122 |
+
|---|---|
|
| 123 |
+
| available | 本发布是否提供该组件;缺省也表示未提供 |
|
| 124 |
+
| schema_id | 已登记的具体存储与语义类型,不得临时创造未登记名称 |
|
| 125 |
+
| data_ref | 数据文件路径,相对当前相机视图根目录,使用 POSIX 路径 |
|
| 126 |
+
| axes | 数组各维度的含义 |
|
| 127 |
+
| valid_ref / valid_axes | 有效性文件及其维度;语义由所属组件规定 |
|
| 128 |
+
| storage / valid_storage | 视频数据/视频有效性的存储配置;包含已登记 profile、实际 codec、pixel_format、encoded_size,见 3.1;非视频组件按原数组规则 |
|
| 129 |
+
| provenance | source / format_conversion / derived,以及转换或生成方法 |
|
| 130 |
+
| source_locator | 原文件、压缩包成员和记录/帧的定位信息 |
|
| 131 |
+
|
| 132 |
+
不存在的组件允许缺省或写作 `{ "available": false, "reason": "..." }`,不用引用不存在的文件。静态网格可声明标量有效性;具体见 5.4。观测的 valid 见第 3 节,标注的 valid 与 visibility 区分见 5.1。
|
| 133 |
+
|
| 134 |
+
`provenance.kind` 使用 source/format_conversion/derived,`method` 说明转换或生成方法;发布清单补充脚本版本、参数、输入摘要。`source_locator` 定位到原始文件/压缩包成员和记录、帧号;允许引用有完整溯源清单的前一发布,但链条最终应能回到 raw。不得仅写一个无法定位记录的数据集名字。
|
| 135 |
+
|
| 136 |
+
`.pt` 仅保存 CPU Tensor,不保存 Python 自定义对象;浮点默认 float32,有效性为 bool,浮点无效位置填 NaN。所有随帧数组保留首维 T,单帧也不 squeeze;静态资产按其 schema 单独声明。单位、坐标及固定形状见各组件小节。
|
| 137 |
+
|
| 138 |
+
机器注册表 `schema.json` 中,`components` 固定解码后的数据类型、形状、单位和语义;`storage_profiles` 固定视频内的编码/还原方式。不得临时创造未登记的 schema_id 或 storage.profile。同一语义允许选择其登记的不同无损存储 profile。
|
| 139 |
+
|
| 140 |
+
## 3. observation 观测数据
|
| 141 |
+
|
| 142 |
+
### 3.1 rgb.mkv 与 rgb_valid.pt
|
| 143 |
+
|
| 144 |
+
RGB、深度和栅格 mask 在 shared 中统一使用 MKV 视频容器,不展开为逐帧图片或图像 tar。MANO、关键点、位姿等数值标注仍用数组;分割的重叠多边形仍用 JSONL,不为了视频化而有损栅格化。单图可为一帧视频,独立图批量封装规则见 2.2。
|
| 145 |
+
|
| 146 |
+
**无损指共享层不增加信息损失。** 源 JPEG/H.264 等本身可能已是有损编码,原样保留并不恢复已丢失信息;不得重新以有损 JPEG、H.264、H.265、AV1 参数编码。源视频/图片的色彩、位深、分辨率和几何关系不得被静默改变。RGB schema `rgb/uint8/v1` 的统一读取结果是 `[T,H,W,3] uint8`、RGB 通道,有效性仍为 `rgb_valid.pt [T] bool`。超出该 schema 的高位深或 HDR 源必须报告并扩展定义,不能降到 8 位冒充无损。
|
| 147 |
+
|
| 148 |
+
#### 3.1.1 允许的 RGB 存储 profile
|
| 149 |
+
|
| 150 |
+
| storage.profile | 编码方式 | 适用规则 |
|
| 151 |
+
|---|---|---|
|
| 152 |
+
| mkv/mjpeg_copy/v1 | 源 JPEG 压缩帧直接封装成 MJPEG/MKV | 不解码重编码;保持每张 JPEG 码流字节;普通 8 位 JPEG 且 MKV/解码器支持时使用 |
|
| 153 |
+
| mkv/source_copy/v1 | 已有视频的 RGB 对应码流直接封装为 MKV | 仅源编码能被 MKV 和选定解码器支持时使用,不伪造帧;需维持正确的呈现顺序与依赖帧 |
|
| 154 |
+
| mkv/h264_rgb_lossless/v1 | libx264rgb 的真正无损模式 | 必须 RGB 路径、CRF=0,并通过全帧 RGB 字节比较;不能替换成默认 libx264 YUV420 路径 |
|
| 155 |
+
| mkv/ffv1_rgb/v1 | FFV1 的 RGB 可逆编码路径 | 作为通用候选;解码回 RGB 后必须逐字节相同,不做色度降采样 |
|
| 156 |
+
|
| 157 |
+
优先尝试源码流直接封装;不能封装或需要选择稀疏帧时,比较 FFV1 与无损 RGB H.264。对完整待发布片段,只在通过无损验收的候选中选择文件较小者,不假设某个编码器总最小;编码时间和随机读取代价记入构建记录。中间候选不作为 shared 多份常驻。H.264 跨帧压缩允许较长 GOP,必须记录 GOP/关键帧间隔,随机取帧需从前一关键帧正确解码,不能把 seek 返回的近似帧当目标帧。
|
| 158 |
+
|
| 159 |
+
普通源视频可以保留它已有的有损码流,但不允许新增有损重编码。源是 VRS 等记录容器时,先查明图像流实际编码:已有兼容 JPEG/视频包可直接提取封装,否则解码后使用真正无损编码;不把整个 VRS 改后缀当 MKV。PNG 不要求直接塞进 MKV,可选上表两种无损重编码方式。
|
| 160 |
+
|
| 161 |
+
#### 3.1.2 视频配置与校验
|
| 162 |
+
|
| 163 |
+
每个视频组件在 metainfo 中登记 `storage`,至少包含:
|
| 164 |
+
|
| 165 |
+
| 字段 | 内容 |
|
| 166 |
+
|---|---|
|
| 167 |
+
| profile | 上述登记的存储 profile;语义仍由组件 schema_id 指定 |
|
| 168 |
+
| codec | 文件中实际 codec,例如 mjpeg、h264、ffv1;source_copy 必须写实际 codec |
|
| 169 |
+
| pixel_format | 实际编码像素格式;不得仅凭编码器参数猜测 |
|
| 170 |
+
| encoded_size | 视频物理像素尺寸 `[width,height]`;深度可能不同于逻辑尺寸,见 3.2 |
|
| 171 |
+
| decoder | 解码器名称、版本,以及颜色矩阵/范围/旋转处理等实际像素解释配置;未知的源色彩声明 unknown,不擅自称为 sRGB |
|
| 172 |
+
| encoder_parameters | 重编码时的编码器、版本、无损模式和 GOP 等参数;直接封装时记录 stream_copy |
|
| 173 |
+
| source_lossy | 源是否已有损:true / false / unknown;不是共享层再有损编码的许可 |
|
| 174 |
+
|
| 175 |
+
无损重新编码的 RGB 必须使用同一固定解码配置,比较**全部帧**的统一 RGB 字节、数量及顺序。MJPEG-copy 不重新编码,生产校验采用 `jpeg-packets-all-rgb-sample16/v1`:从 MKV 逐包取回,对全部源 JPEG 的 SHA256、数量、顺序和图像尺寸进行精确核对;每视图另用同一固定解码配置比较最多 16 帧的源与目标 RGB 字节(含首尾与四分位位置,其余由固定种子抽取)。记录策略、实际索引、种子与结果;不足 16 帧时全查。试点与最终完整序列随机抽查,对选中视图的全部帧复核解码 RGB。历史已做全帧像素检查的证明继续保留。
|
| 176 |
+
|
| 177 |
+
逐包一致与像素抽查的范围必须分别声明,不能将抽查写成全量像素检查。不能用 PSNR 高、视觉相似、编码器参数称为 lossless 等替代精确检查。同时保留源编码的色彩标记和必要元数据;原图有 EXIF/色彩/方向等元数据时保留 raw 和必要来源信息;不能静默自动旋转图像而不更新像素对应与标定。以上加速策略仅适用于原 JPEG 码流直接封装,不适用于深度、标签或重新编码的 RGB。
|
| 178 |
+
|
| 179 |
+
所有共享视频的呈现帧顺序与统一 frame_index 一一对应,每个栅格组件恰好 T 帧。MKV 的 `storage_fps` 只服务封装,声明 `timebase_role=index_only`;source_copy 可以保留源 PTS 以避免改坏码流,但真实时间与标注对齐仍以 frames 为准。未知真实时间保留 null。缺失某帧组件时保留索引位置并使用该组件的无效占位/valid 标识,不删帧;不能以重复相邻图像冒充已知观测。
|
| 180 |
+
|
| 181 |
+
### 3.2 depth.mkv 与 depth_valid.mkv
|
| 182 |
+
|
| 183 |
+
深度语义仍是 `depth/z_float32/v1`:统一读取结果 `[T,H,W] float32`,米制相机 Z 分量,`depth_type=z`。有效深度有限且大于 0,无效位置为 NaN。`depth_origin=measured/rendered/unknown` 必填,来源不明时 unknown。默认与 RGB 共用像素网格及相机参考系,不处理未注册 RGB-D。射线距离必须依据源定义转换成 z,不能只改声明。
|
| 184 |
+
|
| 185 |
+
#### 3.2.1 float32 的可逆视频编码
|
| 186 |
+
|
| 187 |
+
采用 `mkv/depth_float32_bits/v1`:**不是把深度量化成 uint16**,而是将规范化后每个 IEEE-754 float32 的完整 32 位拆成两个 uint16,使用 FFV1 gray16le 保存。视频物理尺寸为 `[2W,H]`:每行前 W 列存原 float32 位串的低 16 位,后 W 列存高 16 位。读取时先合并为 uint32 位串,再按 float32 重新解释,不能数值 cast 成 float32。
|
| 188 |
+
|
| 189 |
+
```text
|
| 190 |
+
u = reinterpret_uint32(depth_float32)
|
| 191 |
+
encoded[:, :, :W] = uint16(u & 65535)
|
| 192 |
+
encoded[:, :, W:] = uint16(u >> 16)
|
| 193 |
+
u_restored = uint32(low) | (uint32(high) << 16)
|
| 194 |
+
depth_float32 = reinterpret_float32(u_restored)
|
| 195 |
+
```
|
| 196 |
+
|
| 197 |
+
统一采用 little-endian 原始字节接口。`camera.image_size` 始终是逻辑 RGB 尺寸 `[W,H]`,不能改成编���视频的 2W;`storage.encoded_size=[2W,H]`。包括 NaN 在内的 float32 位串必须全帧完全恢复,不允许改成 float16、整数毫米、归一化灰度或 RGB 伪彩色。这里的无损验收基准是完成既定米制/坐标转换后的标准 float32 数组,不声称消除 float64→float32 等原约定转换本身的舍入。
|
| 198 |
+
|
| 199 |
+
#### 3.2.2 逐像素有效性
|
| 200 |
+
|
| 201 |
+
`depth_valid.mkv` 使用 `mkv/bool_ffv1/v1`,FFV1 gray8(FFmpeg pixel_format=`gray`),物理尺寸 `[W,H]`。像素只能为 0 或 1,统一解码为 `[T,H,W] bool`,逐像素含义不变。这样不再把庞大的 bool 数组保存为未压缩 `.pt`;标注的帧级/手级 valid 仍保留原有小数组。
|
| 202 |
+
|
| 203 |
+
登记示例(W、H 以下取 640、480;decoder/encoder_parameters 的实际版本由转换器填写):
|
| 204 |
+
|
| 205 |
+
```json
|
| 206 |
+
{
|
| 207 |
+
"available": true,
|
| 208 |
+
"schema_id": "depth/z_float32/v1",
|
| 209 |
+
"data_ref": "observation/depth.mkv",
|
| 210 |
+
"axes": ["T", "height", "width"],
|
| 211 |
+
"valid_ref": "observation/depth_valid.mkv",
|
| 212 |
+
"valid_axes": ["T", "height", "width"],
|
| 213 |
+
"unit": "m",
|
| 214 |
+
"depth_type": "z",
|
| 215 |
+
"depth_origin": "measured",
|
| 216 |
+
"invalid_value": "NaN",
|
| 217 |
+
"storage": {
|
| 218 |
+
"profile": "mkv/depth_float32_bits/v1",
|
| 219 |
+
"codec": "ffv1",
|
| 220 |
+
"pixel_format": "gray16le",
|
| 221 |
+
"encoded_size": [1280, 480],
|
| 222 |
+
"source_lossy": false,
|
| 223 |
+
"decoder": {"name": "ffmpeg", "version": "填写实际版本"},
|
| 224 |
+
"encoder_parameters": {"name": "ffv1", "level": 3, "version": "填写实际版本"}
|
| 225 |
+
},
|
| 226 |
+
"valid_storage": {
|
| 227 |
+
"profile": "mkv/bool_ffv1/v1",
|
| 228 |
+
"codec": "ffv1",
|
| 229 |
+
"pixel_format": "gray",
|
| 230 |
+
"encoded_size": [640, 480],
|
| 231 |
+
"source_lossy": false,
|
| 232 |
+
"decoder": {"name": "ffmpeg", "version": "填写实际版本"},
|
| 233 |
+
"encoder_parameters": {"name": "ffv1", "version": "填写实际版本"}
|
| 234 |
+
},
|
| 235 |
+
"provenance": {"kind": "format_conversion", "method": "源深度转米制 z float32;逐位打包为 FFV1"},
|
| 236 |
+
"source_locator": {"file": "raw/data/depth.zip", "member": "depth/0001.png"}
|
| 237 |
+
}
|
| 238 |
+
```
|
| 239 |
+
|
| 240 |
+
深度和有效性视频都必须逐帧解码验收:float32 位串相同、bool 相同、T 相同,并检查 valid=true 的正有限值和 valid=false 的 NaN。读取器必须按 profile 还原,不能把 depth.mkv 的编码像素直接当深度值。
|
| 241 |
+
|
| 242 |
+
## 4. camera 相机、帧索引与标定
|
| 243 |
+
|
| 244 |
+
### 4.1 frames.jsonl:索引、时间与对应关系
|
| 245 |
+
|
| 246 |
+
`camera/frames.jsonl` 每行对应统一帧号 `frame_index=0..T-1`,是所有组件的唯一行索引。至少包含 `frame_index`、`timestamp_ns`、`clock_domain`、`source_locator`;原始帧号/文件名保存在 `source_frame_id`,不能被新帧号替代。每行还可有 `annotation_matches`,按组件键保存 `source_frame_id`、`source_timestamp_ns`、`clock_domain`、`match_method` 和 `delta_ns`;方法为 exact/index_map/nearest/interpolated,索引映射无时间依据时 delta_ns=null。nearest 必须记录允许误差;interpolated 必须记录两端源标识和权重。delta_ns 仅在同一时间域中计算为源标注时间减图像时间。多相机共享 `sequence_id`;已知同步关系必须用 `sync_id` 或明确的源帧/时间映射表达,不能仅凭相同数组索引认定同步。
|
| 247 |
+
|
| 248 |
+
每个视图必须提供此文件。源时间使用整数纳秒及 `clock_domain`,未知写 JSON `null`;不同时间域不能直接比较。逐帧 split 可以覆盖 metainfo 的视图默认划分,并保留来源,见 2.4。
|
| 249 |
+
|
| 250 |
+
### 4.2 坐标系与标定通则
|
| 251 |
+
|
| 252 |
+
| 项目 | 统一约定 |
|
| 253 |
+
|---|---|
|
| 254 |
+
| 相机坐标 | 右手系,X 向右、Y 向下、Z 向前,长度单位米 |
|
| 255 |
+
| 齐次变换 | 列向量,`p_target = T_target_from_source @ p_source` |
|
| 256 |
+
| 图像坐标 | `(u,v)`;左上像素中心为 `(0,0)`,u 向右、v 向下,单位 pixel |
|
| 257 |
+
| 固定标定 | 本版展开为 T 份,同一 schema 不混用静态与动态形状 |
|
| 258 |
+
| 分辨率或模型变化 | 分开存储为视图/片段,不在同一组件中混装 |
|
| 259 |
+
| 未知标定 | 相机内外参允许缺省,不填单位阵冒充已知标定 |
|
| 260 |
+
|
| 261 |
+
### 4.3 intrinsic.pt 与畸变参数
|
| 262 |
+
|
| 263 |
+
| model / schema_id | intrinsic.pt 的固定结构 |
|
| 264 |
+
|---|---|
|
| 265 |
+
| pinhole / camera/pinhole/v1 | `[T,3,3]`,标准 K,最后一行为 `[0,0,1]`;限无畸变或已校正图像 |
|
| 266 |
+
| fisheye624 / camera/fisheye624/v1 | `[T,15]`,`[f,cx,cy,k0,k1,k2,k3,k4,k5,p0,p1,s0,s1,s2,s3]`,采用 Project Aria Fisheye624 投影定义 |
|
| 267 |
+
| opencv_fisheye4 / camera/opencv_fisheye4/v1 | `intrinsic.pt [T,3,3]` 保存 K;同组件 `distortion_ref` 指向 `[T,4]`,顺序 `[k1,k2,k3,k4]`,使用 OpenCV fisheye 等距角度多项式;已由 ReInterHand 实际原始相机参数验证 |
|
| 268 |
+
| rational8 / camera/rational8/v1 | `intrinsic.pt [T,3,3]` 保存 K;同组件必需 `distortion_ref` 指向 `[T,8]`,顺序 `[k1,k2,p1,p2,k3,k4,k5,k6]` |
|
| 269 |
+
| unknown / null | 不提供可用 intrinsic,不声称可以投影 |
|
| 270 |
+
|
| 271 |
+
有畸变的其他模型必须注册新 schema,固定参数名、顺序和投影公式;不能塞进针孔 K 后遗失畸变项。`metainfo.camera.schema_id` 必须与 intrinsic 组件一致。同一模型的别名不可隐式改变参数布局。
|
| 272 |
+
|
| 273 |
+
`opencv_fisheye4`:对前方点令 `x=X/Z, y=Y/Z, r=sqrt(x²+y²), theta=atan(r)`,`theta_d=theta*(1+k1*theta²+k2*theta⁴+k3*theta⁶+k4*theta⁸)`;`u=fx*x*theta_d/r+cx, v=fy*y*theta_d/r+cy`。光轴 r=0 时使用连续极限 `theta_d/r=1`。四系数不能按普通径向畸变解释,也不能补零冒充 Fisheye624。
|
| 274 |
+
|
| 275 |
+
rational8 对归一化坐标 x=X/Z、y=Y/Z,令 r²=x²+y²,径向项为 `(1+k1*r²+k2*r⁴+k3*r⁶)/(1+k4*r²+k5*r⁴+k6*r⁶)`;再加 p1/p2 切向项并经 K 得到像素。`distortion_ref` 与 intrinsic 共用 `[T]` valid,保存到 camera/distortion.pt。不得把这种畸变三维坐标当作真实相机系 xyz 保存。
|
| 276 |
+
|
| 277 |
+
内参有效性为 `intrinsic_valid.pt [T] bool`;有畸变时使用对应 `distortion_ref`。同一模型的参数名和顺序固定。
|
| 278 |
+
|
| 279 |
+
### 4.4 extrinsic.pt 与 extrinsic_valid.pt
|
| 280 |
+
|
| 281 |
+
`extrinsic.pt` 为 `[T,4,4]`,schema `transform/se3/v1`,方向固定 `T_camera_from_world`,有效性 `[T]`。世界坐标含义及源坐标转换记录在 provenance 中;只有相机坐标标注不要求虚构世界坐标。旋转块须正交且 determinant≈1。
|
| 282 |
+
|
| 283 |
+
## 5. annotation 标注数据
|
| 284 |
+
|
| 285 |
+
### 5.1 标注通则:手槽、valid 与 visibility
|
| 286 |
+
|
| 287 |
+
手槽固定为 0=left、1=right,指解剖学左右,不按画面位置或可见性重排。本阶段只处理左右手两槽,不处理更多手。实体引用使用 `hand_left`、`hand_right`;手槽不证明跨采集片段的个人身份。
|
| 288 |
+
|
| 289 |
+
#### 5.1.1 valid:标注是否可用于监督
|
| 290 |
+
|
| 291 |
+
标注的 `valid=true` 表示:有对应实际标注、通过本 schema 数值检查,且通过来源明确提供并适用于该组件的有效性/QA 条件。`valid=false` 可由缺标注、无法建立帧对应、源无效占位或官方 QA 不通过导致;不等于画面没有手或手不可见。各组件独立判断,MANO 按 `[T,2]` 标记左右手,关键点按 `[T,2,K]` 标记。
|
| 292 |
+
|
| 293 |
+
**2026-09-20 将标注 valid 从“仅表示存在”修订为“可用于监督”,字段形状不变。** 公式为 `source_annotation_present AND numerical_checks_pass AND applicable_official_QA_pass`。没有官方 QA 时省略最后一项,不伪造 QA;不能把未知当成已通过已存在的 QA。适配器在组件 `valid_policy` 中记录具体规则、来源、聚合/广播作用域。缺失官方必需 QA 的记录须明确处理为未知或暂停验收,不能静默通过。无效浮点项仍填 NaN,原始数据保留在 raw;被排除原值可用于 doc 中明确标识的诊断渲染,不能冒充 shared 有效监督。
|
| 294 |
+
|
| 295 |
+
本地筛选须依据明确的规则,并在 `valid_policy.local_excluded_frame_indices`、排除原因和正式报告中记录。单个可疑投影作为问题记录,不直接硬编码排除该帧。已确认的曝光异常须明确作用范围,不能把一个序列的“前两帧有问题”套到所有序列。RGB 编码完好与几何监督可用是两件事,允许保留原图及帧索引而屏蔽对应标注;未发现问题不等于完成全部人工审核,试点待确认时不能作为已验收发布使用。
|
| 296 |
+
|
| 297 |
+
源字段必须按官方语义映射,不能直接按名字复制:
|
| 298 |
+
|
| 299 |
+
| 来源 | 官方含义 | 映射原则 |
|
| 300 |
+
|---|---|---|
|
| 301 |
+
| [H2O](https://github.com/taeinkwon/h2odataset) 的手标注首位 | 0 未标注、1 已标注 | 可作为对应手标注存在性的依据,不推断未标注原因 |
|
| 302 |
+
| [HOT3D](https://github.com/facebookresearch/hot3d#using-mask-files) 的 pose_available、visible、mask_qa_pass | 分别表达姿态存在、可见性、对画面中可见手物位姿的人工 QA | 逐手/物体记录决定存在性,再 AND 当前相机当前帧 QA;QA 是整帧聚合判定,保守排除该帧全部手物几何监督,不声称每个实体均有错误;源可见性基于位姿推导时,其自身 valid 同样受 QA 约束 |
|
| 303 |
+
| [Dex-YCB](https://github.com/NVlabs/dex-ycb-toolkit#loading-dataset-and-visualizing-samples) 的全零 pose_m、全 -1 joints | 不可见的手或缺标注共用占位表示 | 对应组件 valid=false;不能从该值判定 visibility=false,也不能声称原因是动捕缺失 |
|
| 304 |
+
| [ARCTIC](https://github.com/zc-alexfan/arctic/blob/master/docs/data/data_doc.md) 的 is_valid/left_valid/right_valid | 是否有效用于官方评估 | 核实每项筛选依据;不把可见性/评估选择直接等同 QA。本次原始 mano.npy 不含这些派生评估标记,按原记录与数值检查生成 valid,并声明没有额外官方 QA 输入 |
|
| 305 |
+
|
| 306 |
+
源 valid=false 若代表评估筛选或其他条件,应检查实际标注和源约定后映射;不能一律清空坐标。反之,占位零或 -1 只有在源官方明确规定时才判为缺失,不泛化成所有数据的判断规则。
|
| 307 |
+
|
| 308 |
+
`valid=true` 的标注应通过其 schema 的数值与形状检查;检查失败必须报告或修复,不能静默隐藏。QA 不通过应报告排除数量与原因,并保留可追溯信息;不能把这类无效称为缺标注。RGB、深度等观测有效性仍按各自 schema;手物 QA 不自动否定 RGB、静态相机内参或物体资产。相机外参是否过滤须依据其自身来源规则;HOT3D 本次保留源外参用于溯源和诊断,不能用其存在性证明 QA 失败帧的几何监督正确。
|
| 309 |
+
|
| 310 |
+
#### 5.1.2 visibility:可见性属性
|
| 311 |
+
|
| 312 |
+
附加质量属性只保留 `visibility`,存放在对应模态或标注集内,不设 quality 目录。同一份可见性仅存一次;uv 与 xyz 共用时引用同一个文件。
|
| 313 |
+
|
| 314 |
+
visibility 通过所属组件 attributes 登记 data_ref、axes、dtype、visibility_type、meaning、provenance、source_locator;未知值通过属性 valid_ref 标识,全已知可声明 valid=true。比例与布尔值不相互强转,也不按任意阈值二值化。没有 MANO 时,整手可见性挂在 keypoints 组件,使用独立的 whole_hand_visibility.pt,明确 meaning=whole_hand,不与逐关键点可见性混用。
|
| 315 |
+
|
| 316 |
+
`valid` 回答“这项标注能否用于监督”,`visibility` 回答“在当前图像中是否可见(或可见多少)”。不可见的手或关键点仍可有有效标注;不能因 visibility=0 就清空坐标。源没有 visibility 时缺省或标为未知,不由 valid 推断。
|
| 317 |
+
|
| 318 |
+
| 情况 | 手标注 valid | visibility |
|
| 319 |
+
|---|---|---|
|
| 320 |
+
| RGB 已开始录制,动捕尚未开始,没有其他对应手标注 | false | 以独立源可见性标注为准;没有则未知 |
|
| 321 |
+
| 手被遮挡,但源有标注且通过适用有效性检查 | true | 若源声明不可见,则 false 或源可见比例 |
|
| 322 |
+
| 手可见且有对应标注,通过适用 QA | true | 若源有此信息,则 true 或源可见比例 |
|
| 323 |
+
| 手可见,但该帧漏标或动捕中断 | false | 可以为 true,但必须有独立来源依据 |
|
| 324 |
+
| 有手部参数,但官方 QA 明确不通过 | false | 不据此断言不可见;源可见比例若基于不可靠位姿,其属性 valid 也为 false |
|
| 325 |
+
|
| 326 |
+
visibility 自己的 valid_ref 表示该可见性标注是否可用,不复用 MANO 或关键点坐标的 valid_ref;明确记录源存在性及适用的 QA 条件。上述例子不要求凭图像自动生成可见性。
|
| 327 |
+
|
| 328 |
+
不设 quality 组件或目录,不另存拟合误差、曝光、截断比例等通用质量数组。适用的官方 QA 合并进对应 valid,在 `valid_policy` 记录来源与规则;正式校验报告保留原始 QA 时间区间及排除统计。原始 QA 文件仍在 raw,官方 split 保留。
|
| 329 |
+
|
| 330 |
+
### 5.2 mano:参数与整手可见性
|
| 331 |
+
|
| 332 |
+
MANO schema `mano/axis_angle61/v1`:`motion.pt [T,2,61]`,顺序为完整 16 关节 axis-angle 48、shape betas 10、全局平移 3。姿态使用弧度,平移米,位于当前相机系。有效性 `[T,2]`;缺少一侧整槽 NaN。PCA 必须先按对应模型展开,不能将 PCA 系数直接填入 axis-angle。
|
| 333 |
+
|
| 334 |
+
`model_profile` 必须固定 MANO 版本、`flat_hand_mean=true`、左手 shapedirs 修正状态。平移表示模型输出顶点所加的全局平移,不是某个腕关节的坐标;源语义不同须转换。shape 无量纲。模型权重不作为共享数据附带上传。
|
| 335 |
+
|
| 336 |
+
`mano/visibility.pt [T,2]` 保存源整手可见比例时使用 float32 [0,1],`visibility_type=ratio`;只有实际采用 0–100 的百分比才除以100,不能只凭表头判断。HOT3D 的 `visibility_ratio[%]` 实值已经是0–1,官方读取器原样读取,必须保留原值。通过 MANO 组件 attributes 登记,使用独立有效性,不复用 motion_valid。
|
| 337 |
+
|
| 338 |
+
手部共享表示仅保留 MANO 参数与选定关键点,不发布独立手表面几何。需要渲染或接触计算时由 MANO 参数生成,几何引用使用固定 MANO 模型配置与顶点顺序;不影响 object 下的物体模型和材质资产。
|
| 339 |
+
|
| 340 |
+
### 5.3 keypoints:二维点、三维点与逐点可见性
|
| 341 |
+
|
| 342 |
+
关键点独立于 MANO 参数存在;没有 motion 也可有关键点。`uv.pt [T,2,K,2]` 与 `xyz.pt [T,2,K,3]`,有效性 `[T,2,K]`,分别采用 `keypoints/uv/v1` 和 `keypoints/xyz/v1`。K 由 `keypoint_schema` 固定,不能在同一数组中逐帧变化;同体系统一顺序。数值使用像素坐标或米制相机系。
|
| 343 |
+
|
| 344 |
+
| keypoint_schema | K 与固定索引 |
|
| 345 |
+
|---|---|
|
| 346 |
+
| mano21/v1 | 21;wrist 后依次 thumb/index/middle/ring/little,每指由近端至指尖 |
|
| 347 |
+
| rhd21/v1 | 21;保持 wrist,然后五指由近端至指尖;原始每指 tip→palm 反序。只统一顺序,不宣称解剖学位置等价于 MANO |
|
| 348 |
+
|
| 349 |
+
具体名称与源索引映射见 `schema.json`。当前只登记 MANO21 与 RHD21;不登记 MediaPipe、ReInterHand capture21 或 fit24 中间关键点。
|
| 350 |
+
|
| 351 |
+
每个发布中的每个视图只提供一套标准手关键点,直接放在 keypoints 下,不设 annotation_set_id 字段或目录。uv 与 xyz 是这套关键点的二维与三维表示,不是两套标注。provenance 分别记录二者来自原始标注还是计算结果;不要求已有 2D 必须由当前 xyz 重新投影覆盖。
|
| 352 |
+
|
| 353 |
+
ReInterHand 的 Original keypoints���Original fits keypoints 及带前臂关键点不纳入 shared;如需手关键点,从选定 MANO 参数生成 MANO21 并记录模型/指尖回归约定。其他数据集默认使用选定的官方关键点,不额外生成平行的 MANO 派生集合。后续主动更换生成方法或结果时发布新的 dataset_version,不在同一版本内增设方法分支。
|
| 354 |
+
|
| 355 |
+
manual/projection/fitting 只记录在 provenance,不作为目录或类型分支。不得通过坐标为零、是否出画或 visibility 判断标注是否存在。派生标注仅在实际生成并通过数值检查后声明 valid=true;没有生成的项为 false,不伪造坐标。
|
| 356 |
+
|
| 357 |
+
`keypoints/visibility.pt [T,2,K]` 保存源逐点可见性,布尔表示使用 `visibility_type=boolean`。uv 与 xyz 共用时引用同一份文件。整手比例属性没有 MANO 可挂载时使用 `whole_hand_visibility.pt [T,2]`,`meaning=whole_hand`;它与逐点可见性分开,通用登记规则见 5.1。
|
| 358 |
+
|
| 359 |
+
不使用 annotation_set_id;ReInterHand 中间关键点集合不进入 shared,raw 保留来源文件。
|
| 360 |
+
|
| 361 |
+
### 5.4 object:身份、资产、位姿与几何
|
| 362 |
+
|
| 363 |
+
#### 5.4.1 metainfo.json:物体身份与跟踪作用域
|
| 364 |
+
|
| 365 |
+
手用 `hand_left`、`hand_right` 及槽位 0、1 表示,不再另存 entities.json。物体身份登记在 `annotation/object/<object_id>/metainfo.json`,必填 `object_id`、`identity_scope`、`scope_id`、`source_locator`;可含 `category_id`、`source_object_id`、`mesh_ref`、`has_model`、部件引用。即使只有分割、没有 pose/mesh,也可只有这份物体元信息。
|
| 366 |
+
|
| 367 |
+
`identity_scope` 为 frame/subsequence/sequence,`scope_id` 指定具体作用域;跨相机共享身份只在已有源对应证据时使用。VISOR 按官方 subsequence 与实体名关联时记录 `association_basis=official_subsequence_entity_name`,不能声称这是全视频物理实例跟踪。无需与 object_id 一一对应的标准 track_id;官方独立轨迹标识存在时保留为 source_track_id,并声明作用域。手槽不证明跨采集片段的个人身份。
|
| 368 |
+
|
| 369 |
+
#### 5.4.2 assets:网格、材质与纹理
|
| 370 |
+
|
| 371 |
+
资产属于物体,统一存放在 `annotation/object/<object_id>/` 内,可用 `assets/` 子目录组织网格、材质、纹理和部件资产。序列层不设共享 assets。所有引用采用视图根目录为基准;其中物体资产组件的 `data_ref` 与部件的 `mesh_ref` 采用相对于当前视图目录的 POSIX 路径,例如 `annotation/object/cup_01/assets/cup.obj`,且必须指向所属物体目录内的资产。OBJ 内部的材质、纹理引用遵循文件格式自身的相对路径规则,依赖文件一并保留。不同相机视图允许各自保存物体资产,不要求跨视图去重;下载物体时包含其资产依赖。
|
| 372 |
+
|
| 373 |
+
网格 schema 为 `mesh/obj/v1`,顶点米制,静态有效性可直接声明标量 `valid`,或通过 `valid_ref` 指向标量 bool Tensor;不按 T 重复静态资产。由物体/部件通过引用关联,不仅凭文件名猜测。
|
| 374 |
+
|
| 375 |
+
#### 5.4.3 pose.pt、pose_valid.pt 与 visibility.pt
|
| 376 |
+
|
| 377 |
+
刚体 schema 为 `object/rigid/v1`,`pose.pt [T,4,4]` 固定为 `T_camera_from_object`,平移米制,有效性 `[T]`。物体坐标原点、轴向必须与 mesh 一致;旋转块为正交矩阵且 determinant≈1。
|
| 378 |
+
|
| 379 |
+
`object/<id>/visibility.pt [T]` 保存源物体可见比例,float32 [0,1],`visibility_type=ratio`。通过所属物体组件 attributes 登记,独立表达其有效性。
|
| 380 |
+
|
| 381 |
+
#### 5.4.4 articulation.json、部件位姿与 joint_state.pt
|
| 382 |
+
|
| 383 |
+
关节物体:schema `object/articulated/v1`,`articulation.json` 登记 `parts` 与 `joints`。每个 part 有 `part_id`、`parent_id`(根为 null)、`has_model`、`mesh_ref`;has_model=false 时 mesh_ref=null,结构节点允许没有网格。父链不得成环。每个 joint 有唯一 `joint_id`、`parent_part`、`child_part`、`type`;fixed 单位 null、revolute 弧度、prismatic 米。有源限位时保存 `limits:[lower,upper]`;没有时 null,不伪造上下限。部件姿态统一为 `T_camera_from_part [T,4,4]`,不与父局部变换混装。
|
| 384 |
+
|
| 385 |
+
若提供 `joint_state.pt [T,J]`,必须登记固定 joint_order、轴在父部件系的表达、零位变换与正方向,valid 为 `[T,J]`;缺少这些运动学定义时只发布部件位姿与已有来源信息,不伪造可驱动的关节模型。关节值与部件位姿同时存在时需验证一致性。
|
| 386 |
+
|
| 387 |
+
部件层级应声明语义:纯语义包含树允许 `joints=[]`,不将包含关系推断为机械关节。关节状态 schema 为 `object/joint_state/v1`;转动用弧度、移动用米,混合类型按 joint_order 对应的关节定义解释。
|
| 388 |
+
|
| 389 |
+
#### 5.4.5 dimensions、几何关键点与顶点部件标签
|
| 390 |
+
|
| 391 |
+
`dimensions.pt [T,3]` 采用 `object/dimensions/v1`,有效性为 `[T]`。
|
| 392 |
+
|
| 393 |
+
物体/部件 `dimensions` 为 `[length,width,height]` 米,轴顺序与该 mesh 的局部坐标关联,登记 `dimensions_semantics` 和来源。HOI4D dimensions 与 mesh 的具体尺度关���未验证前标为 source_unspecified,保留源值并暂停依赖该关系的几何验收,不能默认为待施加缩放。需要施加缩放时明确 scale_applied_to_mesh,禁止重复应用。
|
| 394 |
+
|
| 395 |
+
源物体关键点放 `object/<id>/keypoints/xyz.pt [T,K,3]`(相机系)或 `template_xyz.pt [K,3]`(物体系),schema 分别为 object_keypoints/camera/v1 和 object_keypoints/template/v1。明确 keypoint_schema、keypoint_names、单位及有效性;模板点配合 pose 可投影,无须重复生成全部帧。H2O 中心/角点/棱中点,以及 ARCTIC 部件点分别登记具体源顺序,不套用手的 21 点 schema。每个发布选择一套源几何点并记录选择,不另建方法分支。
|
| 396 |
+
|
| 397 |
+
`vertex_part_ids.pt [V] int64` 绑定 `mesh_ref` 与 topology_id,登记整数到 part_id 的映射;未知用 -1。ARCTIC 不同拓扑的资产分别绑定,不能共用未经转换的顶点标签。部件层级中 is_instance/has_model 等源属性保留,几何文件仍全部归 object。
|
| 398 |
+
|
| 399 |
+
### 5.5 segment:分割类别、编码与覆盖范围
|
| 400 |
+
|
| 401 |
+
每个发布选择一套任务使用的分割表示,不建立方法/标注集分支。没有分割就不创建 segment 目录,不为其他模态创建空的实体表。
|
| 402 |
+
|
| 403 |
+
| schema_id | 文件与数值语义 |
|
| 404 |
+
|---|---|
|
| 405 |
+
| segment/uint16_labels/v1 | mask.mkv;整数区域编号,通过 instances.jsonl 解释 |
|
| 406 |
+
| segment/instance_polygons/v1 | polygons.jsonl;实例多边形,可重叠;当前不支持孔洞拓扑 |
|
| 407 |
+
| segment/foreground_intensity/v1 | mask.mkv;0–255 前景强度,不是区域编号或经过校准的概率 |
|
| 408 |
+
|
| 409 |
+
#### 5.5.1 uint16 标签图与 instances.jsonl
|
| 410 |
+
|
| 411 |
+
组件声明 `segmentation_type=semantic/instance/part`;同一组件固定一种类型。`mask.mkv` 解码为 `[T,H,W] uint16`,schema `segment/uint16_labels/v1`,使用 `mkv/uint16_ffv1/v1`,FFV1 gray16le 无损;只有所有区域编码均 ≤255 时允许 gray8(pixel_format=gray),读取后转 uint16,数值不变。禁止调色板和有损编码。有效性 `[T]`,表示该帧有可用分割标注。数值 0 固定为 unassigned,65535 固定为 ignore,1–65534 为区域编码,不能直接等同 entity_id。
|
| 412 |
+
|
| 413 |
+
`instances.jsonl` 每帧一行,包含 `frame_index` 与 `labels`。每条标签包含 `mask_value`、`category_id`、`entity_id`、`part_id`;无意义或未知字段为 null。semantic 允许 entity_id=null;instance 必须引用 hand_left/hand_right 或登记的 object_id;part 还须关联登记部件。源实例 ID 和其他属性分别保存在 `source_instance_id`、`source_attributes`。mask 中每个非保留编码必须有且仅有一个映射。
|
| 414 |
+
|
| 415 |
+
FreiHAND 的试点按本任务需要,统一到手/背景类别,保留每个原生区域编码;不要求给原生细分区域猜测手指名称。需要细部件监督时,尚未核实的部件名称必须保持未知,不能因粗粒度手类别已核实便声称部件语义也已统一。
|
| 416 |
+
|
| 417 |
+
#### 5.5.2 重叠实例多边形
|
| 418 |
+
|
| 419 |
+
每发布选择一套任务使用的分割表示,不建立方法/标注集分支。VISOR 的实际试点存在重叠实例多边形,单层标签图不能无损表达。对此补充 `segment/instance_polygons/v1`:`segment/polygons.jsonl` 每帧包含 `frame_index` 和 `instances`,每实例包含 `mask_value` 与 `polygons`(列表,每个多边形为源图像像素坐标顶点序列,保留原始精度)。身份和类别仍由同一 `instances.jsonl` 映射,有效性仍为 `[T]`,通过 schema 区分物理编码。允许多实例重叠,不采用后画覆盖前画。消费者按需栅格化为独立实例二值 mask;不能声称合并的单层 mask 无损。
|
| 420 |
+
|
| 421 |
+
#### 5.5.3 灰度前景强度
|
| 422 |
+
|
| 423 |
+
ReInterHand 的官方渲染 mask 为双手合并的灰度前景掩码,实测存在 0–255 的中间值,不是左右手实例编号。登记 `segment/foreground_intensity/v1`:仍存 `segment/mask.mkv`,解码为 `[T,H,W] uint16`,使用 `mkv/uint16_ffv1/v1`,此类数据优先编码为 FFV1 gray8(pixel_format=gray),读取后转 uint16。有效值范围 0–255,归一化值为 `float32(value)/255`;0 为背景端点、255 为前景端点。组件声明 `foreground_category=hand`、`entity_id=null` 和双手合并语义,不使用区域编号映射。这里保留原始渲染 mask 强度,不把它称为经过校准的概率。若任务需要二值 mask,阈值化属于任务层派生操作,记录阈值;共享层不丢弃中间灰度。不同 schema 的数值含义不同,不能将该文件按整数类别图解码。
|
| 424 |
+
|
| 425 |
+
FreiHAND 训练集的 JPEG mask 使用 `segment/foreground_intensity/v1`,逐像素保留 JPEG 解码后的灰度,`entity_id=hand_right`。该 schema 不限定双手合并:单手或合并范围由 `entity_id` 与 `coverage` 明确声明。评估集整数区域图仍用 `segment/uint16_labels/v1`,两者不能仅凭文件名使用同一种解码语义。
|
| 426 |
+
|
| 427 |
+
#### 5.5.4 coverage 与有效性
|
| 428 |
+
|
| 429 |
+
`coverage.kind=full/selected_entities/partial/unknown`。full 指声明���标注范围完整;selected_entities 还应列出目标范围。无论哪种,0 本身不自动成为背景;背景要有明确类别映射,未标注区域不能用于构造负样本。保留源逐类/逐实例 exhaustive 信息,未知不可改写为完整。
|
| 430 |
+
|
| 431 |
+
三种表示的帧级有效性均为 `[T]`,表示该帧是否提供此分割标注;对应 valid_ref 在组件中登记,仍用小型 bool `.pt` 数组。栅格 mask 必须登记 storage,格式见 3.1.2,所有帧的整数编码或强度逐值完全相同。编码语义由 schema_id 决定,读取器不能仅依据 mask.mkv 文件名选择解码方式。
|
| 432 |
+
|
| 433 |
+
### 5.6 contact:接触、抓取、区域与距离
|
| 434 |
+
|
| 435 |
+
#### 5.6.1 relations.jsonl 与 relations_valid.pt
|
| 436 |
+
|
| 437 |
+
`annotation/contact/relations.jsonl`,schema contact/relations/v1,每帧一行含 frame_index、relations。每条记录含 relation_type(contact/grasp)、subject_id(手槽或登记实体)、object_id、status、source_locator、provenance。status 固定为 positive/negative/unknown/target_unannotated:positive 必须有可解析目标,negative 表示源明确否定该关系,unknown 为不确定,target_unannotated 为确有接触但目标未标注。非 positive 的 object_id 可 null,不能用 null 冒充“不接触”。稀疏源无记录的帧不自动补 negative。
|
| 438 |
+
|
| 439 |
+
VISOR 的对象 mask ID 必须先按同帧 source_instance_id 解析成 object_id;hand-not-in-contact、none-of-the-above、inconclusive 分别映射 negative、target_unannotated、unknown,保留原始字符串。Dex ycb_grasp_ind 通过 ycb_ids 映射到登记物体,以 relation_type=grasp 保存;不得当作逐顶点接触。
|
| 440 |
+
|
| 441 |
+
relations 组件的 valid_ref 指向 `relations_valid.pt [T] bool`,表示该帧是否有可用源关系标注。有效帧中可以存在 status=unknown 的明确不确定标注;无源标注的帧为 valid=false、relations=[]。组件仍声明 available/provenance/source_locator。
|
| 442 |
+
|
| 443 |
+
#### 5.6.2 实体对的顶点区域与距离
|
| 444 |
+
|
| 445 |
+
已发布的接触区域/距离按参与关系的 subject_id 与 object_id 组织,每对实体保留选定的一套结果,以精确 geometry_ref/topology_id 关联到手或物体/部件;不要求每套数据都有。顶点区域 schema contact/vertex_region/v1:bool `[T,V]` 加同形 valid;顶点距离 schema contact/vertex_distance/v1:float32 `[T,V]`、米、同形 valid,声明 source/target geometry_ref、distance_definition(signed/unsigned、测量到点集或表面等明确源定义)。geometry_ref 必须指向已登记 mesh 或由固定 MANO 模型配置确定的拓扑;拓扑/顶点数变化时按拓扑拆分片段。其他源区域表示只有在实际接入并登记 schema 后才可转换,不能随意栅格化宣称等价。
|
| 446 |
+
|
| 447 |
+
顶点区域/距离已有存储定义,但尚未完成真实输入试点;接入时必须提供源语义与几何验收证据,不因已经登记 schema 就视为通过。
|
| 448 |
+
|
| 449 |
+
## 附录:任务范围
|
| 450 |
+
|
| 451 |
+
不强制收录 2D bbox、完整高频动捕、动作程序、身体 SMPL-X、点云或网络特征。范围内的接触、visibility、选定手关键点、物体几何不能因不便处理而静默丢弃。分割采用的物理编码由第 5.5 节决定,存在重叠时不能以单层标签图声称无损。
|
| 452 |
+
|
| 453 |
+
不设置 entities_ref/segment/entities.json,不要求与 object_id 重复的 track_id。MediaPipe 不在当前关键点定义中;旧版本迁移必须保留可追溯关系,不能直接删表。手部共享表示不含独立 hand_mesh。
|
| 454 |
+
|
| 455 |
+
schema.json 是普通注册表,不是 JSON Schema 文档或可执行验收器;定义存在不代表真实数据已验证。验收须保留实测范围与未决项。
|
| 456 |
+
|
| 457 |
+
本存储约定只更新标准,不代表既有 FFV1/depth.pt 试点已迁移。新发布必须显式写 storage 配置;旧产物按其旧定义读取,不能只改文件后缀或版本标识伪装为合规。
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/docs/h2o-RAW_TO_SHARED.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# H2O raw → shared-v1.0
|
| 2 |
+
|
| 3 |
+
## 范围与来源
|
| 4 |
+
|
| 5 |
+
本版本仅转换 `raw/data/subject{1,2,3,4}_v1_1.tar.gz` 的真实五视角 (`cam0`–`cam4`) 序列;`h2o_CASA.tar` 是单独的扩展,不与标准序列混合。每个原始序列存于 `data/subjectN_<scene>_<sequence>/cam{0..4}/`。源压缩包保持不变,不合成源不存在的标注。输出仅在本地制作;完整序列试点及人工检查通过、更新全量预估之前,不启动全量。
|
| 6 |
+
|
| 7 |
+
| 源包/字段 | shared 文件/处理 |
|
| 8 |
+
| --- | --- |
|
| 9 |
+
| `subjectN_v1_1.tar.gz`: `camX/rgb/<frame>.png` | `observation/rgb.mkv`:逐帧源 RGB 解码为 RGB24,FFV1 直接编码;输出**每帧**解码与源 RGB 字节摘要完全一致。`rgb_valid.pt` 记录存在性,源帧号和每组件的包成员及 SHA256 写入 `camera/frames.jsonl`。不再额外编码未采用的 H.264 RGB 候选;FFV1 编码器进程失败时才尝试 H.264。 |
|
| 10 |
+
| 同包 `camX/depth/<frame>.png` | `observation/depth.mkv` 和 `depth_valid.mkv`;按源毫米单位除以 1000 转米,保留无效深度与全帧时间轴,深度位串以 FFV1 保真封装并逐帧校验。既不做 3 米裁剪也不造出缺失的深度。 |
|
| 11 |
+
| `camX/cam_intrinsics.txt`、`camX/cam_pose/<frame>.txt` | `camera/intrinsic.pt`、`extrinsic.pt`:保留源内参;逐帧源 `T_world_from_camera` 求逆后存 `T_camera_from_world`;声明变换约定与有效性。 |
|
| 12 |
+
| `camX/hand_pose_mano/<frame>.txt` | `annotation/mano/motion.pt`、`motion_valid.pt`:源左/右手标志各自判断有效性;姿态与平移保持源数值,声明 MANO 模型配置,缺模型则明确标依赖缺失,不伪造网格或掩码。 |
|
| 13 |
+
| `camX/hand_pose/<frame>.txt` | `annotation/keypoints/xyz.pt`、`xyz_valid.pt`:源双手 21 点,相机坐标系米制,与 MANO 有效性彼此独立。HTML 中的投影仅用于人工预览,不写回训练数据。 |
|
| 14 |
+
| `camX/obj_pose/<frame>.txt`、`obj_pose_rt/<frame>.txt` | `annotation/object/<name>/keypoints/xyz.pt`、`pose.pt`:按源类号关联 21 个物体点及物体→相机位姿;仅源存在时登记组件及有效性。 |
|
| 15 |
+
| `object.zip` | `annotation/object/<name>/assets/` 与源 OBJ、MTL、纹理;静态形状预览不等于所有帧网格位姿的投影证明。 |
|
| 16 |
+
| `label_split.zip` 的 `action_{train,val,test}.txt` | 序列元数据的官方划分及来源;未知映射明确记 `unknown`,不自行编排。 |
|
| 17 |
+
|
| 18 |
+
`cam4` 是 ego,`cam0`–`cam3` 是 exo。真实时间/FPS 缺乏可靠来源时使用 null,不把 MKV 封装帧率冒充采集时钟。源 `action_label`、`verb_label`、pose 任务帧列表和 `manolabel_v1.1.tar.gz` 保留在 raw;当前契约没有相应动作组件,本发布不宣称它们已转换。源没有像素分割,本版本不投影网格生成替代分割。
|
| 19 |
+
|
| 20 |
+
## 源资产文件名修复
|
| 21 |
+
|
| 22 |
+
源 `object/cocoa/cocoa.obj` 引用 `ovomaltine.mtl`,材质内写的是 `map_Kd cocoa.png`,但原 ZIP 只提供 `ovomaltine.png`。仅在临时解压目录为该已确认的纹理增加**字节相同**的 `cocoa.png` 别名,保留原 PNG、OBJ、MTL 不变;在网格 `source_locator.texture_aliases` 中记录别名、原始包成员和 SHA256。别名与已保留的旧 cocoa 资产一致,不替换图像、标注或网格。全部八类物体的材质依赖在读取大 subject 包之前预检,其他缺失/越界依赖仍报错。
|
| 23 |
+
|
| 24 |
+
## 加速与验收
|
| 25 |
+
|
| 26 |
+
四个互不依赖的 subject 压缩包可由 `--workers 1..4` 并行顺序读取,各 worker 一次只处理一个序列。数值库保持单线程;FFV1 编码支持 `--codec-threads 1|2|4|8|10`,当前全量按用户要求使用 10;`--decode-threads 10` 通过现有 `HAND_WAREHOUSE_FFMPEG_THREADS` 控制源 RGB PNG→RGB24、完整视频解码摘要、深度/有效性语义校验与 RGB 索引抽取的解码线程,完整校验仍保留。深度 PNG 使用 `--depth-threads 4` 有序分批读取,每批最多读取 4 帧,避免缓存整条序列,缺帧仍按原时间轴写 NaN;不并行改写姿态、标注或原始包。并发数由相同输入实测吞吐量决定,记录 OS 线程峰值和磁盘占用,不以 CPU 线程数本身作为提速证据。RGB 源为 PNG,不适用 ARCTIC/HOT3D 的 JPEG 包直封和 16 帧抽查:RGB、深度、有效性与数值模态仍逐帧精确校验。临时文件在 `/data` 上隔离放置,历史 62 条目录不复用、不覆盖;调整并发时,在新的运行目录复用本次全量已经原子发布的完整序列,并从源重新核对帧号及逐组件 SHA256;已发布视图只读源包并核对摘要,不再把源 PNG/标注写入临时目录,待转换视图才正常暂存。未完成的临时序列不复用,原运行的脚本、配置及 QC 保留用于溯源。
|
| 27 |
+
|
| 28 |
+
先运行不截帧的代表性完整序列试点,保存自动 QC、真实耗时和 `doc/validation/index.html`(RGB、深度、源 3D 关键点投影、原生物体网格和全组件数值/有效性)。试点由人工核查之后再决定全量;全量后再次抽样人工核查。报告须区分数据完整性、源未提供的模态与仅供人工判断的几何对齐。
|
| 29 |
+
|
| 30 |
+
2026-09-29 完整序列试点已获人工确认,用户已授权本地全量。2026-09-30 用户取消 CPU 使用量上限,指定 4 个独立压缩包 worker、每个 FFV1 编码器 10 线程、每个校验解码器 10 线程、每 worker 深度 PNG 读取 4 线程;Python worker、读取及校验子进程不计入这最多 40 个编码线程,因此总线程数不固定为 40。该配置不代表已证明加速倍数。源包和旧产物保留;代码变化使用独立运行目录,已完成序列保留原始构建记录及生产脚本快照。
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
## 多线程解码测速(2026-09-30)
|
| 34 |
+
|
| 35 |
+
在 101 上以真实 `subject4/h1/0/cam0` 的完整 RGB、深度和有效性视频,以及源头 100 帧 PNG 测试;采用 1、10、10、1 的解码线程顺序,源深度 PNG 另比较 1/2/4 线程。逐字节摘要和输出长度必须相同,测速脚本、全部轮次及结果保存在 `script/provenance/operations/` 和 `doc/validation/`。测速期间旧全量任务仍运行,磁盘负载和缓存会影响结果;不得将阶段加速比冒充整套转换加速比。四个 gzip 包已经独立并行读取,暂不引入多进程重构或增加数值库线程;小矩阵及标注处理没有已测得的进一步并行收益。
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
本次同输入结果(解码后长度和 SHA256 全部相同):
|
| 39 |
+
|
| 40 |
+
| 阶段 | 1 线程(秒) | 新配置(秒) | 范围 |
|
| 41 |
+
| --- | ---: | ---: | --- |
|
| 42 |
+
| FFV1 RGB 解码与摘要 | 39.46 | 8.70(10 线程) | 完整 501 帧,中位数 |
|
| 43 |
+
| FFV1 深度位串解码与摘要 | 34.91 | 11.56(10 线程) | 完整 501 帧,中位数 |
|
| 44 |
+
| 有效性视频解码与摘要 | 2.24 | 2.27(10 线程) | 完整 501 帧;未获提速 |
|
| 45 |
+
| 源 RGB PNG 解码 | 2.67 | 1.49(10 线程) | 100 帧,1 线程使用热缓存轮次,不使用冷缓存较慢轮次来夸大提速 |
|
| 46 |
+
| 源深度 PNG 读取及毫米→米 | 4.67 | 2.61(4 线程) | 100 帧,中位数;帧序与数值相同 |
|
| 47 |
+
|
| 48 |
+
这些结果只代表相应阶段;全流程还包括顺序 gzip 扫描、文件创建、源 SHA256、资产复制和磁盘读写,实际全量 ETA 待稳定吞吐后再更新。
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/docs/schema.json
ADDED
|
@@ -0,0 +1,869 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema_version": "hand-warehouse/1.0",
|
| 3 |
+
"validity_revision": "usable-annotation-2026-09-20",
|
| 4 |
+
"annotation_validity": {
|
| 5 |
+
"meaning": "annotation usable for supervision, not merely record presence",
|
| 6 |
+
"formula": "source_annotation_present AND numerical_checks_pass AND applicable_official_QA_pass AND NOT explicitly_reviewed_local_exclusion",
|
| 7 |
+
"without_official_qa": "omit QA term; declare source rules; do not fabricate QA",
|
| 8 |
+
"policy_field": "components.<name>.valid_policy",
|
| 9 |
+
"visibility_is_independent": true,
|
| 10 |
+
"invalid_float_value": "NaN",
|
| 11 |
+
"hot3d": "broadcast per-camera frame manual QA conservatively to hand/object labels and pose-derived visibility; retain RGB and source calibration; keep native QA in raw and review report",
|
| 12 |
+
"hot3d_visibility": "native visibility_ratio[%] already ranges from 0 to 1; do not divide by 100"
|
| 13 |
+
},
|
| 14 |
+
"hand_slots": [
|
| 15 |
+
"left",
|
| 16 |
+
"right"
|
| 17 |
+
],
|
| 18 |
+
"keypoints": {
|
| 19 |
+
"mano21/v1": {
|
| 20 |
+
"count": 21,
|
| 21 |
+
"names": [
|
| 22 |
+
"wrist",
|
| 23 |
+
"thumb_1",
|
| 24 |
+
"thumb_2",
|
| 25 |
+
"thumb_3",
|
| 26 |
+
"thumb_4",
|
| 27 |
+
"index_1",
|
| 28 |
+
"index_2",
|
| 29 |
+
"index_3",
|
| 30 |
+
"index_4",
|
| 31 |
+
"middle_1",
|
| 32 |
+
"middle_2",
|
| 33 |
+
"middle_3",
|
| 34 |
+
"middle_4",
|
| 35 |
+
"ring_1",
|
| 36 |
+
"ring_2",
|
| 37 |
+
"ring_3",
|
| 38 |
+
"ring_4",
|
| 39 |
+
"little_1",
|
| 40 |
+
"little_2",
|
| 41 |
+
"little_3",
|
| 42 |
+
"little_4"
|
| 43 |
+
],
|
| 44 |
+
"source_index_map": null,
|
| 45 |
+
"note": "adapter maps official MANO joint and fingertip convention"
|
| 46 |
+
},
|
| 47 |
+
"rhd21/v1": {
|
| 48 |
+
"count": 21,
|
| 49 |
+
"names": [
|
| 50 |
+
"wrist",
|
| 51 |
+
"thumb_1",
|
| 52 |
+
"thumb_2",
|
| 53 |
+
"thumb_3",
|
| 54 |
+
"thumb_4",
|
| 55 |
+
"index_1",
|
| 56 |
+
"index_2",
|
| 57 |
+
"index_3",
|
| 58 |
+
"index_4",
|
| 59 |
+
"middle_1",
|
| 60 |
+
"middle_2",
|
| 61 |
+
"middle_3",
|
| 62 |
+
"middle_4",
|
| 63 |
+
"ring_1",
|
| 64 |
+
"ring_2",
|
| 65 |
+
"ring_3",
|
| 66 |
+
"ring_4",
|
| 67 |
+
"little_1",
|
| 68 |
+
"little_2",
|
| 69 |
+
"little_3",
|
| 70 |
+
"little_4"
|
| 71 |
+
],
|
| 72 |
+
"source_index_map_per_hand": [
|
| 73 |
+
0,
|
| 74 |
+
4,
|
| 75 |
+
3,
|
| 76 |
+
2,
|
| 77 |
+
1,
|
| 78 |
+
8,
|
| 79 |
+
7,
|
| 80 |
+
6,
|
| 81 |
+
5,
|
| 82 |
+
12,
|
| 83 |
+
11,
|
| 84 |
+
10,
|
| 85 |
+
9,
|
| 86 |
+
16,
|
| 87 |
+
15,
|
| 88 |
+
14,
|
| 89 |
+
13,
|
| 90 |
+
20,
|
| 91 |
+
19,
|
| 92 |
+
18,
|
| 93 |
+
17
|
| 94 |
+
]
|
| 95 |
+
}
|
| 96 |
+
},
|
| 97 |
+
"camera": {
|
| 98 |
+
"opencv_fisheye4": {
|
| 99 |
+
"K": [
|
| 100 |
+
3,
|
| 101 |
+
3
|
| 102 |
+
],
|
| 103 |
+
"distortion": [
|
| 104 |
+
"k1",
|
| 105 |
+
"k2",
|
| 106 |
+
"k3",
|
| 107 |
+
"k4"
|
| 108 |
+
],
|
| 109 |
+
"projection": "theta=atan(r); theta_d=theta*(1+k1*theta^2+k2*theta^4+k3*theta^6+k4*theta^8); source ReInterHand"
|
| 110 |
+
},
|
| 111 |
+
"pinhole": {
|
| 112 |
+
"K": [
|
| 113 |
+
3,
|
| 114 |
+
3
|
| 115 |
+
]
|
| 116 |
+
},
|
| 117 |
+
"fisheye624": {
|
| 118 |
+
"parameters": [
|
| 119 |
+
"f",
|
| 120 |
+
"cx",
|
| 121 |
+
"cy",
|
| 122 |
+
"k0",
|
| 123 |
+
"k1",
|
| 124 |
+
"k2",
|
| 125 |
+
"k3",
|
| 126 |
+
"k4",
|
| 127 |
+
"k5",
|
| 128 |
+
"p0",
|
| 129 |
+
"p1",
|
| 130 |
+
"s0",
|
| 131 |
+
"s1",
|
| 132 |
+
"s2",
|
| 133 |
+
"s3"
|
| 134 |
+
]
|
| 135 |
+
},
|
| 136 |
+
"rational8": {
|
| 137 |
+
"K": [
|
| 138 |
+
3,
|
| 139 |
+
3
|
| 140 |
+
],
|
| 141 |
+
"distortion": [
|
| 142 |
+
"k1",
|
| 143 |
+
"k2",
|
| 144 |
+
"p1",
|
| 145 |
+
"p2",
|
| 146 |
+
"k3",
|
| 147 |
+
"k4",
|
| 148 |
+
"k5",
|
| 149 |
+
"k6"
|
| 150 |
+
]
|
| 151 |
+
}
|
| 152 |
+
},
|
| 153 |
+
"segmentation": {
|
| 154 |
+
"segment/uint16_labels/v1": {
|
| 155 |
+
"storage": "mask.mkv",
|
| 156 |
+
"dtype": "uint16",
|
| 157 |
+
"mapping": "instances.jsonl",
|
| 158 |
+
"valid_shape": [
|
| 159 |
+
"T"
|
| 160 |
+
],
|
| 161 |
+
"required_metadata": [
|
| 162 |
+
"segmentation_type",
|
| 163 |
+
"coverage",
|
| 164 |
+
"mapping_ref",
|
| 165 |
+
"storage"
|
| 166 |
+
],
|
| 167 |
+
"shape": [
|
| 168 |
+
"T",
|
| 169 |
+
"H",
|
| 170 |
+
"W"
|
| 171 |
+
],
|
| 172 |
+
"reserved_codes": {
|
| 173 |
+
"0": "unassigned",
|
| 174 |
+
"65535": "ignore"
|
| 175 |
+
},
|
| 176 |
+
"region_codes": [
|
| 177 |
+
1,
|
| 178 |
+
65534
|
| 179 |
+
],
|
| 180 |
+
"allowed_storage_profiles": [
|
| 181 |
+
"mkv/uint16_ffv1/v1"
|
| 182 |
+
]
|
| 183 |
+
},
|
| 184 |
+
"segment/instance_polygons/v1": {
|
| 185 |
+
"storage": "polygons.jsonl",
|
| 186 |
+
"mapping": "instances.jsonl",
|
| 187 |
+
"frame_keys": [
|
| 188 |
+
"frame_index",
|
| 189 |
+
"instances"
|
| 190 |
+
],
|
| 191 |
+
"instance_keys": [
|
| 192 |
+
"mask_value",
|
| 193 |
+
"polygons"
|
| 194 |
+
],
|
| 195 |
+
"coordinate_unit": "pixel",
|
| 196 |
+
"overlap_allowed": true,
|
| 197 |
+
"valid_shape": [
|
| 198 |
+
"T"
|
| 199 |
+
],
|
| 200 |
+
"required_metadata": [
|
| 201 |
+
"segmentation_type",
|
| 202 |
+
"coverage",
|
| 203 |
+
"mapping_ref"
|
| 204 |
+
],
|
| 205 |
+
"polygon_shape": [
|
| 206 |
+
"N",
|
| 207 |
+
2
|
| 208 |
+
],
|
| 209 |
+
"holes_supported": false
|
| 210 |
+
},
|
| 211 |
+
"segment/foreground_intensity/v1": {
|
| 212 |
+
"storage": "mask.mkv",
|
| 213 |
+
"dtype": "uint16",
|
| 214 |
+
"value_range": [
|
| 215 |
+
0,
|
| 216 |
+
255
|
| 217 |
+
],
|
| 218 |
+
"normalization_scale": 0.00392156862745098,
|
| 219 |
+
"axes": [
|
| 220 |
+
"T",
|
| 221 |
+
"height",
|
| 222 |
+
"width"
|
| 223 |
+
],
|
| 224 |
+
"meaning": "native hand foreground intensity; individual hand or union declared in metadata; not instance codes or calibrated probability",
|
| 225 |
+
"zero": "background",
|
| 226 |
+
"full_scale": "foreground",
|
| 227 |
+
"mapping": "foreground_category in component metadata",
|
| 228 |
+
"valid_shape": [
|
| 229 |
+
"T"
|
| 230 |
+
],
|
| 231 |
+
"required_metadata": [
|
| 232 |
+
"segmentation_type",
|
| 233 |
+
"coverage",
|
| 234 |
+
"value_range",
|
| 235 |
+
"normalization_scale",
|
| 236 |
+
"foreground_category",
|
| 237 |
+
"entity_id",
|
| 238 |
+
"storage"
|
| 239 |
+
],
|
| 240 |
+
"shape": [
|
| 241 |
+
"T",
|
| 242 |
+
"H",
|
| 243 |
+
"W"
|
| 244 |
+
],
|
| 245 |
+
"allowed_storage_profiles": [
|
| 246 |
+
"mkv/uint16_ffv1/v1"
|
| 247 |
+
]
|
| 248 |
+
}
|
| 249 |
+
},
|
| 250 |
+
"note": "Registry for hand-warehouse/1.0. Read CONTRACT.md for field semantics. This is not a JSON Schema document or executable validator.",
|
| 251 |
+
"components": {
|
| 252 |
+
"mano/axis_angle61/v1": {
|
| 253 |
+
"storage": "pt",
|
| 254 |
+
"dtype": "float32",
|
| 255 |
+
"shape": [
|
| 256 |
+
"T",
|
| 257 |
+
2,
|
| 258 |
+
61
|
| 259 |
+
],
|
| 260 |
+
"valid_shape": [
|
| 261 |
+
"T",
|
| 262 |
+
2
|
| 263 |
+
],
|
| 264 |
+
"unit": "m",
|
| 265 |
+
"angle_unit": "rad",
|
| 266 |
+
"coordinate_frame": "camera",
|
| 267 |
+
"layout": {
|
| 268 |
+
"pose_axis_angle": [
|
| 269 |
+
0,
|
| 270 |
+
48
|
| 271 |
+
],
|
| 272 |
+
"shape": [
|
| 273 |
+
48,
|
| 274 |
+
58
|
| 275 |
+
],
|
| 276 |
+
"translation": [
|
| 277 |
+
58,
|
| 278 |
+
61
|
| 279 |
+
]
|
| 280 |
+
}
|
| 281 |
+
},
|
| 282 |
+
"keypoints/uv/v1": {
|
| 283 |
+
"storage": "pt",
|
| 284 |
+
"dtype": "float32",
|
| 285 |
+
"shape": [
|
| 286 |
+
"T",
|
| 287 |
+
2,
|
| 288 |
+
21,
|
| 289 |
+
2
|
| 290 |
+
],
|
| 291 |
+
"valid_shape": [
|
| 292 |
+
"T",
|
| 293 |
+
2,
|
| 294 |
+
21
|
| 295 |
+
],
|
| 296 |
+
"unit": "pixel",
|
| 297 |
+
"required_metadata": [
|
| 298 |
+
"keypoint_schema"
|
| 299 |
+
]
|
| 300 |
+
},
|
| 301 |
+
"keypoints/xyz/v1": {
|
| 302 |
+
"storage": "pt",
|
| 303 |
+
"dtype": "float32",
|
| 304 |
+
"shape": [
|
| 305 |
+
"T",
|
| 306 |
+
2,
|
| 307 |
+
21,
|
| 308 |
+
3
|
| 309 |
+
],
|
| 310 |
+
"valid_shape": [
|
| 311 |
+
"T",
|
| 312 |
+
2,
|
| 313 |
+
21
|
| 314 |
+
],
|
| 315 |
+
"unit": "m",
|
| 316 |
+
"required_metadata": [
|
| 317 |
+
"keypoint_schema"
|
| 318 |
+
]
|
| 319 |
+
},
|
| 320 |
+
"depth/z_float32/v1": {
|
| 321 |
+
"storage": "mkv",
|
| 322 |
+
"dtype": "float32",
|
| 323 |
+
"shape": [
|
| 324 |
+
"T",
|
| 325 |
+
"H",
|
| 326 |
+
"W"
|
| 327 |
+
],
|
| 328 |
+
"valid_shape": [
|
| 329 |
+
"T",
|
| 330 |
+
"H",
|
| 331 |
+
"W"
|
| 332 |
+
],
|
| 333 |
+
"unit": "m",
|
| 334 |
+
"depth_type": "z",
|
| 335 |
+
"pixel_grid": "current_rgb",
|
| 336 |
+
"coordinate_frame": "current_rgb_camera",
|
| 337 |
+
"valid_storage": "mkv",
|
| 338 |
+
"allowed_storage_profiles": [
|
| 339 |
+
"mkv/depth_float32_bits/v1"
|
| 340 |
+
],
|
| 341 |
+
"allowed_valid_storage_profiles": [
|
| 342 |
+
"mkv/bool_ffv1/v1"
|
| 343 |
+
],
|
| 344 |
+
"required_metadata": [
|
| 345 |
+
"storage",
|
| 346 |
+
"valid_storage",
|
| 347 |
+
"depth_origin"
|
| 348 |
+
],
|
| 349 |
+
"depth_origin_values": [
|
| 350 |
+
"measured",
|
| 351 |
+
"rendered",
|
| 352 |
+
"unknown"
|
| 353 |
+
]
|
| 354 |
+
},
|
| 355 |
+
"transform/se3/v1": {
|
| 356 |
+
"storage": "pt",
|
| 357 |
+
"dtype": "float32",
|
| 358 |
+
"shape": [
|
| 359 |
+
"T",
|
| 360 |
+
4,
|
| 361 |
+
4
|
| 362 |
+
],
|
| 363 |
+
"valid_shape": [
|
| 364 |
+
"T"
|
| 365 |
+
],
|
| 366 |
+
"unit": "m",
|
| 367 |
+
"required_metadata": [
|
| 368 |
+
"convention"
|
| 369 |
+
]
|
| 370 |
+
},
|
| 371 |
+
"object/rigid/v1": {
|
| 372 |
+
"storage": "pt",
|
| 373 |
+
"dtype": "float32",
|
| 374 |
+
"shape": [
|
| 375 |
+
"T",
|
| 376 |
+
4,
|
| 377 |
+
4
|
| 378 |
+
],
|
| 379 |
+
"valid_shape": [
|
| 380 |
+
"T"
|
| 381 |
+
],
|
| 382 |
+
"unit": "m",
|
| 383 |
+
"required_metadata": [
|
| 384 |
+
"convention"
|
| 385 |
+
]
|
| 386 |
+
},
|
| 387 |
+
"camera/pinhole/v1": {
|
| 388 |
+
"storage": "pt",
|
| 389 |
+
"dtype": "float32",
|
| 390 |
+
"shape": [
|
| 391 |
+
"T",
|
| 392 |
+
3,
|
| 393 |
+
3
|
| 394 |
+
],
|
| 395 |
+
"valid_shape": [
|
| 396 |
+
"T"
|
| 397 |
+
]
|
| 398 |
+
},
|
| 399 |
+
"camera/rational8/v1": {
|
| 400 |
+
"storage": "pt",
|
| 401 |
+
"dtype": "float32",
|
| 402 |
+
"shape": [
|
| 403 |
+
"T",
|
| 404 |
+
3,
|
| 405 |
+
3
|
| 406 |
+
],
|
| 407 |
+
"valid_shape": [
|
| 408 |
+
"T"
|
| 409 |
+
]
|
| 410 |
+
},
|
| 411 |
+
"camera/opencv_fisheye4/v1": {
|
| 412 |
+
"storage": "pt",
|
| 413 |
+
"dtype": "float32",
|
| 414 |
+
"shape": [
|
| 415 |
+
"T",
|
| 416 |
+
3,
|
| 417 |
+
3
|
| 418 |
+
],
|
| 419 |
+
"valid_shape": [
|
| 420 |
+
"T"
|
| 421 |
+
]
|
| 422 |
+
},
|
| 423 |
+
"camera/fisheye624/v1": {
|
| 424 |
+
"storage": "pt",
|
| 425 |
+
"dtype": "float32",
|
| 426 |
+
"shape": [
|
| 427 |
+
"T",
|
| 428 |
+
15
|
| 429 |
+
],
|
| 430 |
+
"valid_shape": [
|
| 431 |
+
"T"
|
| 432 |
+
]
|
| 433 |
+
},
|
| 434 |
+
"camera/distortion8/v1": {
|
| 435 |
+
"storage": "pt",
|
| 436 |
+
"dtype": "float32",
|
| 437 |
+
"shape": [
|
| 438 |
+
"T",
|
| 439 |
+
8
|
| 440 |
+
],
|
| 441 |
+
"valid_shape": [
|
| 442 |
+
"T"
|
| 443 |
+
]
|
| 444 |
+
},
|
| 445 |
+
"camera/fisheye4_distortion/v1": {
|
| 446 |
+
"storage": "pt",
|
| 447 |
+
"dtype": "float32",
|
| 448 |
+
"shape": [
|
| 449 |
+
"T",
|
| 450 |
+
4
|
| 451 |
+
],
|
| 452 |
+
"valid_shape": [
|
| 453 |
+
"T"
|
| 454 |
+
]
|
| 455 |
+
},
|
| 456 |
+
"object/joint_state/v1": {
|
| 457 |
+
"storage": "pt",
|
| 458 |
+
"dtype": "float32",
|
| 459 |
+
"shape": [
|
| 460 |
+
"T",
|
| 461 |
+
"J"
|
| 462 |
+
],
|
| 463 |
+
"valid_shape": [
|
| 464 |
+
"T",
|
| 465 |
+
"J"
|
| 466 |
+
],
|
| 467 |
+
"required_metadata": [
|
| 468 |
+
"joint_order"
|
| 469 |
+
],
|
| 470 |
+
"unit_rule": "revolute radians; prismatic metres; mixed types declared per joint"
|
| 471 |
+
},
|
| 472 |
+
"object_keypoints/camera/v1": {
|
| 473 |
+
"storage": "pt",
|
| 474 |
+
"dtype": "float32",
|
| 475 |
+
"shape": [
|
| 476 |
+
"T",
|
| 477 |
+
"K",
|
| 478 |
+
3
|
| 479 |
+
],
|
| 480 |
+
"valid_shape": [
|
| 481 |
+
"T",
|
| 482 |
+
"K"
|
| 483 |
+
],
|
| 484 |
+
"unit": "m",
|
| 485 |
+
"coordinate_frame": "camera",
|
| 486 |
+
"required_metadata": [
|
| 487 |
+
"keypoint_schema"
|
| 488 |
+
]
|
| 489 |
+
},
|
| 490 |
+
"object/dimensions/v1": {
|
| 491 |
+
"storage": "pt",
|
| 492 |
+
"dtype": "float32",
|
| 493 |
+
"shape": [
|
| 494 |
+
"T",
|
| 495 |
+
3
|
| 496 |
+
],
|
| 497 |
+
"valid_shape": [
|
| 498 |
+
"T"
|
| 499 |
+
],
|
| 500 |
+
"unit": "m",
|
| 501 |
+
"required_metadata": [
|
| 502 |
+
"dimensions_semantics"
|
| 503 |
+
],
|
| 504 |
+
"axis_order": [
|
| 505 |
+
"length",
|
| 506 |
+
"width",
|
| 507 |
+
"height"
|
| 508 |
+
],
|
| 509 |
+
"scale_rule": "do not apply to mesh without source-supported size/scale relation"
|
| 510 |
+
},
|
| 511 |
+
"object_keypoints/template/v1": {
|
| 512 |
+
"storage": "pt",
|
| 513 |
+
"dtype": "float32",
|
| 514 |
+
"shape": [
|
| 515 |
+
"K",
|
| 516 |
+
3
|
| 517 |
+
],
|
| 518 |
+
"valid_shape": [
|
| 519 |
+
"K"
|
| 520 |
+
],
|
| 521 |
+
"unit": "m",
|
| 522 |
+
"coordinate_frame": "object",
|
| 523 |
+
"static": true,
|
| 524 |
+
"required_metadata": [
|
| 525 |
+
"keypoint_schema"
|
| 526 |
+
]
|
| 527 |
+
},
|
| 528 |
+
"mesh/obj/v1": {
|
| 529 |
+
"storage": "obj",
|
| 530 |
+
"unit": "m",
|
| 531 |
+
"static": true,
|
| 532 |
+
"valid_shape": [],
|
| 533 |
+
"dependencies": "MTL and textures retained under owning object"
|
| 534 |
+
},
|
| 535 |
+
"rgb/uint8/v1": {
|
| 536 |
+
"storage": "mkv",
|
| 537 |
+
"dtype": "uint8",
|
| 538 |
+
"shape": [
|
| 539 |
+
"T",
|
| 540 |
+
"H",
|
| 541 |
+
"W",
|
| 542 |
+
3
|
| 543 |
+
],
|
| 544 |
+
"valid_shape": [
|
| 545 |
+
"T"
|
| 546 |
+
],
|
| 547 |
+
"color_order": "RGB",
|
| 548 |
+
"allowed_storage_profiles": [
|
| 549 |
+
"mkv/mjpeg_copy/v1",
|
| 550 |
+
"mkv/source_copy/v1",
|
| 551 |
+
"mkv/h264_rgb_lossless/v1",
|
| 552 |
+
"mkv/ffv1_rgb/v1"
|
| 553 |
+
],
|
| 554 |
+
"required_metadata": [
|
| 555 |
+
"storage"
|
| 556 |
+
]
|
| 557 |
+
},
|
| 558 |
+
"contact/relations/v1": {
|
| 559 |
+
"storage": "jsonl",
|
| 560 |
+
"valid_shape": [
|
| 561 |
+
"T"
|
| 562 |
+
],
|
| 563 |
+
"frame_keys": [
|
| 564 |
+
"frame_index",
|
| 565 |
+
"relations"
|
| 566 |
+
],
|
| 567 |
+
"absence_semantics": "no record is not a negative contact annotation"
|
| 568 |
+
},
|
| 569 |
+
"contact/vertex_region/v1": {
|
| 570 |
+
"storage": "pt",
|
| 571 |
+
"dtype": "bool",
|
| 572 |
+
"shape": [
|
| 573 |
+
"T",
|
| 574 |
+
"V"
|
| 575 |
+
],
|
| 576 |
+
"valid_shape": [
|
| 577 |
+
"T",
|
| 578 |
+
"V"
|
| 579 |
+
],
|
| 580 |
+
"required_metadata": [
|
| 581 |
+
"source_geometry_ref",
|
| 582 |
+
"target_geometry_ref",
|
| 583 |
+
"topology_id"
|
| 584 |
+
],
|
| 585 |
+
"pilot_status": "defined_not_empirically_validated"
|
| 586 |
+
},
|
| 587 |
+
"contact/vertex_distance/v1": {
|
| 588 |
+
"storage": "pt",
|
| 589 |
+
"dtype": "float32",
|
| 590 |
+
"shape": [
|
| 591 |
+
"T",
|
| 592 |
+
"V"
|
| 593 |
+
],
|
| 594 |
+
"valid_shape": [
|
| 595 |
+
"T",
|
| 596 |
+
"V"
|
| 597 |
+
],
|
| 598 |
+
"unit": "m",
|
| 599 |
+
"required_metadata": [
|
| 600 |
+
"source_geometry_ref",
|
| 601 |
+
"target_geometry_ref",
|
| 602 |
+
"topology_id",
|
| 603 |
+
"distance_definition"
|
| 604 |
+
],
|
| 605 |
+
"pilot_status": "defined_not_empirically_validated"
|
| 606 |
+
},
|
| 607 |
+
"object/articulated/v1": {
|
| 608 |
+
"storage": "json",
|
| 609 |
+
"required_keys": [
|
| 610 |
+
"parts",
|
| 611 |
+
"joints"
|
| 612 |
+
],
|
| 613 |
+
"part_keys": [
|
| 614 |
+
"part_id",
|
| 615 |
+
"parent_id",
|
| 616 |
+
"has_model",
|
| 617 |
+
"mesh_ref"
|
| 618 |
+
],
|
| 619 |
+
"hierarchy_semantics": "declare mechanical articulation or semantic containment; containment alone does not imply joints",
|
| 620 |
+
"acyclic": true
|
| 621 |
+
},
|
| 622 |
+
"segment/uint16_labels/v1": {
|
| 623 |
+
"storage": "mkv",
|
| 624 |
+
"dtype": "uint16",
|
| 625 |
+
"mapping": "instances.jsonl",
|
| 626 |
+
"valid_shape": [
|
| 627 |
+
"T"
|
| 628 |
+
],
|
| 629 |
+
"required_metadata": [
|
| 630 |
+
"segmentation_type",
|
| 631 |
+
"coverage",
|
| 632 |
+
"mapping_ref",
|
| 633 |
+
"storage"
|
| 634 |
+
],
|
| 635 |
+
"shape": [
|
| 636 |
+
"T",
|
| 637 |
+
"H",
|
| 638 |
+
"W"
|
| 639 |
+
],
|
| 640 |
+
"reserved_codes": {
|
| 641 |
+
"0": "unassigned",
|
| 642 |
+
"65535": "ignore"
|
| 643 |
+
},
|
| 644 |
+
"region_codes": [
|
| 645 |
+
1,
|
| 646 |
+
65534
|
| 647 |
+
],
|
| 648 |
+
"allowed_storage_profiles": [
|
| 649 |
+
"mkv/uint16_ffv1/v1"
|
| 650 |
+
]
|
| 651 |
+
},
|
| 652 |
+
"segment/instance_polygons/v1": {
|
| 653 |
+
"storage": "jsonl",
|
| 654 |
+
"mapping": "instances.jsonl",
|
| 655 |
+
"frame_keys": [
|
| 656 |
+
"frame_index",
|
| 657 |
+
"instances"
|
| 658 |
+
],
|
| 659 |
+
"instance_keys": [
|
| 660 |
+
"mask_value",
|
| 661 |
+
"polygons"
|
| 662 |
+
],
|
| 663 |
+
"coordinate_unit": "pixel",
|
| 664 |
+
"overlap_allowed": true,
|
| 665 |
+
"valid_shape": [
|
| 666 |
+
"T"
|
| 667 |
+
],
|
| 668 |
+
"required_metadata": [
|
| 669 |
+
"segmentation_type",
|
| 670 |
+
"coverage",
|
| 671 |
+
"mapping_ref"
|
| 672 |
+
],
|
| 673 |
+
"polygon_shape": [
|
| 674 |
+
"N",
|
| 675 |
+
2
|
| 676 |
+
],
|
| 677 |
+
"holes_supported": false
|
| 678 |
+
},
|
| 679 |
+
"segment/foreground_intensity/v1": {
|
| 680 |
+
"storage": "mkv",
|
| 681 |
+
"dtype": "uint16",
|
| 682 |
+
"value_range": [
|
| 683 |
+
0,
|
| 684 |
+
255
|
| 685 |
+
],
|
| 686 |
+
"normalization_scale": 0.00392156862745098,
|
| 687 |
+
"axes": [
|
| 688 |
+
"T",
|
| 689 |
+
"height",
|
| 690 |
+
"width"
|
| 691 |
+
],
|
| 692 |
+
"meaning": "native hand foreground intensity; individual hand or union declared in metadata; not instance codes or calibrated probability",
|
| 693 |
+
"zero": "background",
|
| 694 |
+
"full_scale": "foreground",
|
| 695 |
+
"mapping": "foreground_category in component metadata",
|
| 696 |
+
"valid_shape": [
|
| 697 |
+
"T"
|
| 698 |
+
],
|
| 699 |
+
"required_metadata": [
|
| 700 |
+
"segmentation_type",
|
| 701 |
+
"coverage",
|
| 702 |
+
"value_range",
|
| 703 |
+
"normalization_scale",
|
| 704 |
+
"foreground_category",
|
| 705 |
+
"entity_id",
|
| 706 |
+
"storage"
|
| 707 |
+
],
|
| 708 |
+
"shape": [
|
| 709 |
+
"T",
|
| 710 |
+
"H",
|
| 711 |
+
"W"
|
| 712 |
+
],
|
| 713 |
+
"allowed_storage_profiles": [
|
| 714 |
+
"mkv/uint16_ffv1/v1"
|
| 715 |
+
]
|
| 716 |
+
}
|
| 717 |
+
},
|
| 718 |
+
"storage_revision": "lossless-video-2026-09-18",
|
| 719 |
+
"sampling": {
|
| 720 |
+
"image": {
|
| 721 |
+
"single": {
|
| 722 |
+
"T": 1
|
| 723 |
+
},
|
| 724 |
+
"independent": {
|
| 725 |
+
"T": ">=2",
|
| 726 |
+
"required_frame_fields": [
|
| 727 |
+
"sample_id",
|
| 728 |
+
"source_locator"
|
| 729 |
+
],
|
| 730 |
+
"temporal_relationship": false
|
| 731 |
+
},
|
| 732 |
+
"source_fps": null
|
| 733 |
+
},
|
| 734 |
+
"video": {
|
| 735 |
+
"sampling_types": [
|
| 736 |
+
"dense",
|
| 737 |
+
"sparse"
|
| 738 |
+
]
|
| 739 |
+
}
|
| 740 |
+
},
|
| 741 |
+
"storage_profiles": {
|
| 742 |
+
"mkv/mjpeg_copy/v1": {
|
| 743 |
+
"container": "matroska",
|
| 744 |
+
"codec": "mjpeg",
|
| 745 |
+
"method": "stream_copy_from_source_jpeg",
|
| 746 |
+
"logical_dtype": "uint8",
|
| 747 |
+
"decoded_pixel_format": "rgb24",
|
| 748 |
+
"validation": [
|
| 749 |
+
"source_jpeg_packet_sha256_exact",
|
| 750 |
+
"all_packet_count_order_and_dimensions_exact",
|
| 751 |
+
"deterministic_decoded_rgb_sample_exact",
|
| 752 |
+
"pilot_and_final_selected_whole_sequences_decoded_rgb_exact"
|
| 753 |
+
],
|
| 754 |
+
"validation_policy": {
|
| 755 |
+
"id": "jpeg-packets-all-rgb-sample16/v1",
|
| 756 |
+
"sample_count_per_view": 16,
|
| 757 |
+
"short_views": "all_frames_if_T_less_than_16",
|
| 758 |
+
"fixed_indices": "0,T-1,T//4,T//2,3*T//4, deduplicated",
|
| 759 |
+
"remaining_indices": "sample without replacement to min(T,16) using Python random.Random(seed)",
|
| 760 |
+
"seed": "first 8 bytes of SHA256(sequence_id/camera_id/20260920), big-endian integer",
|
| 761 |
+
"report": "policy, exact selected frame indices, seed, separate packet and pixel coverage",
|
| 762 |
+
"legacy_all_frame_pixel_proofs": "still accepted; preserve historical evidence"
|
| 763 |
+
}
|
| 764 |
+
},
|
| 765 |
+
"mkv/source_copy/v1": {
|
| 766 |
+
"container": "matroska",
|
| 767 |
+
"codec": "source_codec_declared_in_metadata",
|
| 768 |
+
"method": "stream_copy_only",
|
| 769 |
+
"logical_dtype": "uint8",
|
| 770 |
+
"decoded_pixel_format": "rgb24",
|
| 771 |
+
"validation": [
|
| 772 |
+
"no_reencoding",
|
| 773 |
+
"all_decoded_rgb_frames_exact",
|
| 774 |
+
"presentation_frame_order_exact"
|
| 775 |
+
]
|
| 776 |
+
},
|
| 777 |
+
"mkv/h264_rgb_lossless/v1": {
|
| 778 |
+
"container": "matroska",
|
| 779 |
+
"codec": "h264",
|
| 780 |
+
"encoder": "libx264rgb",
|
| 781 |
+
"crf": 0,
|
| 782 |
+
"decoded_pixel_format": "rgb24",
|
| 783 |
+
"logical_dtype": "uint8",
|
| 784 |
+
"gop": "declared_in_encoder_parameters",
|
| 785 |
+
"validation": [
|
| 786 |
+
"all_decoded_rgb_frames_exact"
|
| 787 |
+
],
|
| 788 |
+
"forbidden": [
|
| 789 |
+
"lossy_rate_control",
|
| 790 |
+
"rgb_to_yuv420_subsampling"
|
| 791 |
+
]
|
| 792 |
+
},
|
| 793 |
+
"mkv/ffv1_rgb/v1": {
|
| 794 |
+
"container": "matroska",
|
| 795 |
+
"codec": "ffv1",
|
| 796 |
+
"decoded_pixel_format": "rgb24",
|
| 797 |
+
"logical_dtype": "uint8",
|
| 798 |
+
"validation": [
|
| 799 |
+
"all_decoded_rgb_frames_exact"
|
| 800 |
+
]
|
| 801 |
+
},
|
| 802 |
+
"mkv/depth_float32_bits/v1": {
|
| 803 |
+
"container": "matroska",
|
| 804 |
+
"codec": "ffv1",
|
| 805 |
+
"pixel_format": "gray16le",
|
| 806 |
+
"logical_dtype": "float32",
|
| 807 |
+
"logical_shape": [
|
| 808 |
+
"T",
|
| 809 |
+
"H",
|
| 810 |
+
"W"
|
| 811 |
+
],
|
| 812 |
+
"encoded_shape": [
|
| 813 |
+
"T",
|
| 814 |
+
"H",
|
| 815 |
+
"2*W"
|
| 816 |
+
],
|
| 817 |
+
"packing": "IEEE754 little-endian float32 bits; low uint16 in first W columns, high uint16 in last W columns",
|
| 818 |
+
"decode": "reinterpret_float32(uint32(low) | (uint32(high) << 16))",
|
| 819 |
+
"validation": [
|
| 820 |
+
"all_float32_bits_exact_including_nan"
|
| 821 |
+
]
|
| 822 |
+
},
|
| 823 |
+
"mkv/bool_ffv1/v1": {
|
| 824 |
+
"container": "matroska",
|
| 825 |
+
"codec": "ffv1",
|
| 826 |
+
"pixel_format": "gray",
|
| 827 |
+
"logical_dtype": "bool",
|
| 828 |
+
"stored_values": [
|
| 829 |
+
0,
|
| 830 |
+
1
|
| 831 |
+
],
|
| 832 |
+
"validation": [
|
| 833 |
+
"all_bool_values_exact"
|
| 834 |
+
]
|
| 835 |
+
},
|
| 836 |
+
"mkv/uint16_ffv1/v1": {
|
| 837 |
+
"container": "matroska",
|
| 838 |
+
"codec": "ffv1",
|
| 839 |
+
"pixel_formats": [
|
| 840 |
+
"gray",
|
| 841 |
+
"gray16le"
|
| 842 |
+
],
|
| 843 |
+
"logical_dtype": "uint16",
|
| 844 |
+
"gray_condition": "all values <=255; decode by exact uint8-to-uint16 promotion",
|
| 845 |
+
"validation": [
|
| 846 |
+
"all_integer_values_exact"
|
| 847 |
+
]
|
| 848 |
+
}
|
| 849 |
+
},
|
| 850 |
+
"video_metadata": {
|
| 851 |
+
"required": [
|
| 852 |
+
"profile",
|
| 853 |
+
"codec",
|
| 854 |
+
"pixel_format",
|
| 855 |
+
"encoded_size",
|
| 856 |
+
"decoder",
|
| 857 |
+
"encoder_parameters",
|
| 858 |
+
"source_lossy"
|
| 859 |
+
],
|
| 860 |
+
"source_lossy_values": [
|
| 861 |
+
true,
|
| 862 |
+
false,
|
| 863 |
+
"unknown"
|
| 864 |
+
],
|
| 865 |
+
"timebase_role": "index_only",
|
| 866 |
+
"lossless_reference": "source compressed packets or fixed-decoder source pixels; depth uses normalized standard float32 bits",
|
| 867 |
+
"selection": "choose smaller complete candidate only after exact roundtrip validation"
|
| 868 |
+
}
|
| 869 |
+
}
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/full.log
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Verified existing subject1/h1/0
|
| 2 |
+
Verified existing subject4/h1/0
|
| 3 |
+
Verified existing subject3/h1/0
|
| 4 |
+
Verified existing subject1/h1/6
|
| 5 |
+
Verified existing subject2/h1/0
|
| 6 |
+
Verified existing subject1/h1/3
|
| 7 |
+
Verified existing subject2/h1/6
|
| 8 |
+
Verified existing subject1/h1/7
|
| 9 |
+
Converted subject3/h1/6
|
| 10 |
+
Converted subject4/h1/6
|
| 11 |
+
Verified existing subject1/h1/4
|
| 12 |
+
Verified existing subject1/h1/2
|
| 13 |
+
Verified existing subject2/h1/3
|
| 14 |
+
Verified existing subject1/h1/1
|
| 15 |
+
Verified existing subject1/h1/5
|
| 16 |
+
Verified existing subject1/o1/0
|
| 17 |
+
Converted subject3/h1/3
|
| 18 |
+
Verified existing subject2/h1/7
|
| 19 |
+
Verified existing subject1/o1/6
|
| 20 |
+
Converted subject4/h1/3
|
| 21 |
+
Verified existing subject1/o1/3
|
| 22 |
+
Verified existing subject2/h1/4
|
| 23 |
+
Verified existing subject1/o1/7
|
| 24 |
+
Verified existing subject1/o1/4
|
| 25 |
+
Verified existing subject2/h1/2
|
| 26 |
+
Verified existing subject1/o1/2
|
| 27 |
+
Converted subject3/h1/7
|
| 28 |
+
Converted subject4/h1/7
|
| 29 |
+
Verified existing subject1/o1/1
|
| 30 |
+
Verified existing subject2/h1/1
|
| 31 |
+
Verified existing subject1/o1/5
|
| 32 |
+
Verified existing subject1/o2/0
|
| 33 |
+
Converted subject3/h1/4
|
| 34 |
+
Verified existing subject2/h1/5
|
| 35 |
+
Verified existing subject1/o2/6
|
| 36 |
+
Verified existing subject1/o2/3
|
| 37 |
+
Verified existing subject2/o1/0
|
| 38 |
+
Converted subject4/h1/4
|
| 39 |
+
Verified existing subject1/o2/7
|
| 40 |
+
Verified existing subject1/o2/4
|
| 41 |
+
Converted subject3/h1/2
|
| 42 |
+
Verified existing subject2/o1/6
|
| 43 |
+
Converted subject4/h1/2
|
| 44 |
+
Verified existing subject1/o2/2
|
| 45 |
+
Verified existing subject2/o1/3
|
| 46 |
+
Converted subject3/h1/1
|
| 47 |
+
Verified existing subject1/o2/1
|
| 48 |
+
Verified existing subject1/o2/5
|
| 49 |
+
Verified existing subject1/k1/0
|
| 50 |
+
Verified existing subject1/k1/6
|
| 51 |
+
Verified existing subject2/o1/4
|
| 52 |
+
Verified existing subject1/k1/3
|
| 53 |
+
Converted subject3/h1/5
|
| 54 |
+
Converted subject4/h1/1
|
| 55 |
+
Verified existing subject1/k1/7
|
| 56 |
+
Verified existing subject2/o1/2
|
| 57 |
+
Converted subject4/h1/5
|
| 58 |
+
Converted subject3/o1/0
|
| 59 |
+
Converted subject1/k1/4
|
| 60 |
+
Converted subject4/o1/0
|
| 61 |
+
Verified existing subject2/o1/1
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/full.status
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
START=2026-09-30T11:03:05+08:00
|
| 2 |
+
WORKERS=4 CODEC_THREADS=10 DECODE_THREADS=10 DEPTH_THREADS=4 SUBJECTS=1,2,3,4 CASA=false
|
| 3 |
+
CPU_LIMIT=none
|
| 4 |
+
CGROUP=/user.slice/user-25044.slice/user@25044.service/app.slice/h2o-full-d10-20260930.scope
|
| 5 |
+
CPU_MAX=max controller_disabled
|
| 6 |
+
|
| 7 |
+
RECONFIGURE=2026-09-30T15:47:55+08:00 REASON=process16_camera_pipeline_ram32_streaming
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/run-full.sh
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -u
|
| 3 |
+
base="$HOME/Datasets/uni-hoi-h2o-full-20260930-w4-c10-d10"
|
| 4 |
+
raw="$HOME/Datasets/Hand-Datasets-Raw/H2O"
|
| 5 |
+
cd "$HOME/Projects/uni-hoi-dataset" || exit 1
|
| 6 |
+
mkdir -p "$base/scratch"
|
| 7 |
+
export TMPDIR="$base/scratch" PYTHONUNBUFFERED=1
|
| 8 |
+
for n in 1 2 3 4; do test -s "$raw/raw/data/subject${n}_v1_1.tar.gz" || exit 2; done
|
| 9 |
+
test ! -e "$base/full.status" || exit 3
|
| 10 |
+
cg=$(awk -F: '$1=="0" {print $3}' /proc/self/cgroup)
|
| 11 |
+
if [[ -f "/sys/fs/cgroup$cg/cpu.max" ]]; then
|
| 12 |
+
read -r quota period < "/sys/fs/cgroup$cg/cpu.max"
|
| 13 |
+
else
|
| 14 |
+
quota=max
|
| 15 |
+
period=controller_disabled
|
| 16 |
+
fi
|
| 17 |
+
printf 'START=%s\nWORKERS=4 CODEC_THREADS=10 DECODE_THREADS=10 DEPTH_THREADS=4 SUBJECTS=1,2,3,4 CASA=false\nCPU_LIMIT=none\nCGROUP=%s\nCPU_MAX=%s %s\n' "$(date -Is)" "$cg" "$quota" "$period" > "$base/full.status"
|
| 18 |
+
if [[ "$quota" != max ]]; then
|
| 19 |
+
printf 'EXIT=4 ERROR=UNEXPECTED_CPU_QUOTA\n' >> "$base/full.status"
|
| 20 |
+
exit 4
|
| 21 |
+
fi
|
| 22 |
+
/usr/bin/time -v .venv/bin/python "$base/frozen-code/scripts/convert_h2o_v1.0.py" --root "$raw" --out "$base" --release-id shared-v1.0 --workers 4 --codec-threads 10 --decode-threads 10 --depth-threads 4 --mano-dir "$HOME/Projects/WiLoR/mano_data" > "$base/full.log" 2>&1
|
| 23 |
+
code=$?
|
| 24 |
+
printf 'EXIT=%s END=%s\n' "$code" "$(date -Is)" >> "$base/full.status"
|
| 25 |
+
if [[ -f "/sys/fs/cgroup$cg/cpu.stat" ]]; then cat "/sys/fs/cgroup$cg/cpu.stat" >> "$base/full.status"; fi
|
| 26 |
+
exit "$code"
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/script/check_dexycb_projection.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Check saved Dex-YCB source 3D joints against saved source 2D joints in sampled views."""
|
| 3 |
+
import json
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
import sys
|
| 6 |
+
|
| 7 |
+
import numpy as np
|
| 8 |
+
import torch
|
| 9 |
+
|
| 10 |
+
root = Path(sys.argv[1])
|
| 11 |
+
report = json.loads((root / 'doc/validation/STRUCTURAL_AUDIT.json').read_text())
|
| 12 |
+
checks = []
|
| 13 |
+
for name in report['sampled_views']:
|
| 14 |
+
view = root / name
|
| 15 |
+
load = lambda path: torch.load(view / path, weights_only=True, map_location='cpu').numpy()
|
| 16 |
+
k = load('camera/intrinsic.pt')
|
| 17 |
+
xyz = load('annotation/keypoints/xyz.pt')
|
| 18 |
+
uv = load('annotation/keypoints/uv.pt')
|
| 19 |
+
valid = load('annotation/keypoints/xyz_valid.pt') & load('annotation/keypoints/uv_valid.pt')
|
| 20 |
+
z = xyz[..., 2]
|
| 21 |
+
valid &= np.isfinite(xyz).all(axis=-1) & np.isfinite(uv).all(axis=-1) & (z > 0)
|
| 22 |
+
z = np.where(valid, z, 1)
|
| 23 |
+
pred = np.stack((k[:, 0, 0, None, None] * xyz[..., 0] / z + k[:, 0, 2, None, None],
|
| 24 |
+
k[:, 1, 1, None, None] * xyz[..., 1] / z + k[:, 1, 2, None, None]), axis=-1)
|
| 25 |
+
errors = np.linalg.norm(pred[valid] - uv[valid], axis=-1)
|
| 26 |
+
checks.append(dict(view=name, points=int(errors.size), median_px=float(np.median(errors)) if errors.size else None,
|
| 27 |
+
p95_px=float(np.percentile(errors, 95)) if errors.size else None))
|
| 28 |
+
(root / 'doc/validation/KEYPOINT_PROJECTION_QC.json').write_text(json.dumps({
|
| 29 |
+
'scope': 'Saved source 3D joints projected with saved color intrinsics vs saved source 2D joints; independent of hand mesh rendering.',
|
| 30 |
+
'views': checks}, ensure_ascii=False, indent=2) + '\n')
|
| 31 |
+
print(json.dumps(checks, ensure_ascii=False), flush=True)
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/script/config.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"root": "/home/xuzhefeng/Datasets/Hand-Datasets-Raw/H2O",
|
| 3 |
+
"out": "/home/xuzhefeng/Datasets/uni-hoi-h2o-full-20260930-w4-c10-d10",
|
| 4 |
+
"release_id": "shared-v1.0",
|
| 5 |
+
"limit": null,
|
| 6 |
+
"max_frames": null,
|
| 7 |
+
"mano_dir": "/home/xuzhefeng/Projects/WiLoR/mano_data",
|
| 8 |
+
"views": null,
|
| 9 |
+
"jpeg_full_check": false,
|
| 10 |
+
"workers": 4,
|
| 11 |
+
"codec_threads": 10,
|
| 12 |
+
"decode_threads": 10,
|
| 13 |
+
"depth_threads": 4,
|
| 14 |
+
"subjects": null,
|
| 15 |
+
"include_casa": false,
|
| 16 |
+
"archive": null
|
| 17 |
+
}
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/script/convert_dexycb_v1.0.py
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Dex-YCB source annotations → CONTRACT.md v1.0. No derived annotations."""
|
| 3 |
+
import io
|
| 4 |
+
import re
|
| 5 |
+
import shutil
|
| 6 |
+
import tarfile
|
| 7 |
+
import tempfile
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
|
| 10 |
+
import numpy as np
|
| 11 |
+
from PIL import Image
|
| 12 |
+
import yaml
|
| 13 |
+
|
| 14 |
+
from warehouse_v1_0 import (View, build_record, find_file, locator, mano_models, mesh_asset,
|
| 15 |
+
model_profile, parser, pca_to_axis_angle, release, roots, safe_member, sequence_dir)
|
| 16 |
+
|
| 17 |
+
IMG_W, IMG_H = 640, 480
|
| 18 |
+
|
| 19 |
+
class _Loader(yaml.SafeLoader):
|
| 20 |
+
pass
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
_Loader.add_constructor("tag:yaml.org,2002:python/tuple",
|
| 24 |
+
lambda l, n: tuple(l.construct_sequence(n)))
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def yaml_load_bytes(data: bytes):
|
| 28 |
+
return yaml.load(io.BytesIO(data), Loader=_Loader)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
class Calibration:
|
| 32 |
+
def __init__(self, dexycb_root: Path):
|
| 33 |
+
self.intrinsics = {} # serial -> {fx,fy,cx,cy,w,h}
|
| 34 |
+
self.extrinsics = {} # group -> {serial: [12] 行优先 3×4 cam→world}
|
| 35 |
+
self.betas = {} # mano_calib_name -> [10]
|
| 36 |
+
calib_dir = dexycb_root / "calibration"
|
| 37 |
+
if calib_dir.is_dir():
|
| 38 |
+
self._load((p.as_posix(), p.read_bytes())
|
| 39 |
+
for p in sorted(calib_dir.rglob("*")) if p.is_file())
|
| 40 |
+
else:
|
| 41 |
+
tar_path = dexycb_root / "calibration.tar.gz"
|
| 42 |
+
if not tar_path.exists():
|
| 43 |
+
raise FileNotFoundError(f"no calibration/ nor calibration.tar.gz in {dexycb_root}")
|
| 44 |
+
with tarfile.open(tar_path, "r:gz") as tf:
|
| 45 |
+
self._load((m.name, tf.extractfile(m).read()) for m in tf if m.isfile())
|
| 46 |
+
|
| 47 |
+
_RE_INTR = re.compile(r"(?:^|/)intrinsics/(\d+)_\d+x\d+\.yml$")
|
| 48 |
+
_RE_EXTRA = re.compile(r"(?:^|/)extrinsics_(\d{8}_\d{6})/extrinsics\.yml$")
|
| 49 |
+
_RE_MANO = re.compile(r"(?:^|/)mano_(\d{8}_\d{6}_subject-\d{2}_right)/mano\.yml$")
|
| 50 |
+
|
| 51 |
+
def _load(self, files):
|
| 52 |
+
for rel, data in files:
|
| 53 |
+
m = self._RE_INTR.search(rel)
|
| 54 |
+
if m:
|
| 55 |
+
c = yaml_load_bytes(data)["color"]
|
| 56 |
+
self.intrinsics[m.group(1)] = {"fx": float(c["fx"]), "fy": float(c["fy"]),
|
| 57 |
+
"cx": float(c["ppx"]), "cy": float(c["ppy"]),
|
| 58 |
+
"w": IMG_W, "h": IMG_H}
|
| 59 |
+
continue
|
| 60 |
+
m = self._RE_EXTRA.search(rel)
|
| 61 |
+
if m:
|
| 62 |
+
raw = yaml_load_bytes(data)["extrinsics"]
|
| 63 |
+
self.extrinsics[m.group(1)] = {
|
| 64 |
+
str(s): [float(x) for x in np.asarray(v).ravel()] for s, v in raw.items()}
|
| 65 |
+
continue
|
| 66 |
+
m = self._RE_MANO.search(rel)
|
| 67 |
+
if m:
|
| 68 |
+
self.betas[m.group(1)] = [float(b) for b in yaml_load_bytes(data)["betas"]]
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
def calibration_locator(path, member, **extra):
|
| 73 |
+
if path.is_dir():
|
| 74 |
+
return locator(path / member.removeprefix('calibration/'), **extra)
|
| 75 |
+
return locator(path, member, **extra)
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def prepare_models(root, destination):
|
| 79 |
+
archive = find_file(root, 'models.tar.gz')
|
| 80 |
+
if archive is None:
|
| 81 |
+
return {}, None
|
| 82 |
+
pattern = re.compile(r'^models/(\d{3}_[a-z0-9_]+)/(textured_simple\.obj(?:\.mtl)?|texture_map\.png)$')
|
| 83 |
+
names = set()
|
| 84 |
+
with tarfile.open(archive, 'r|gz') as tf:
|
| 85 |
+
for member in tf:
|
| 86 |
+
match = pattern.fullmatch(member.name)
|
| 87 |
+
if member.isfile() and match:
|
| 88 |
+
names.add(match[1])
|
| 89 |
+
path = safe_member(destination, '/'.join(match.groups()))
|
| 90 |
+
path.parent.mkdir(parents=True, exist_ok=True)
|
| 91 |
+
path.write_bytes(tf.extractfile(member).read())
|
| 92 |
+
if len(names) != 21:
|
| 93 |
+
raise ValueError('expected all 21 source YCB model directories')
|
| 94 |
+
return {i: destination / name for i, name in enumerate(sorted(names), 1)}, archive
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
def convert_view(path, args, seq, serial, frames, meta, meta_loc, calib, calib_path, models, assets, asset_archive):
|
| 98 |
+
total = int(meta.get('num_frames', max(frames) + 1))
|
| 99 |
+
ids = list(range(min(total, args.max_frames) if args.max_frames else total))
|
| 100 |
+
for f in ids:
|
| 101 |
+
frames.setdefault(f, {})
|
| 102 |
+
if not ids:
|
| 103 |
+
raise ValueError('no RGB frames')
|
| 104 |
+
source_rows = []
|
| 105 |
+
for f in ids:
|
| 106 |
+
row = frames[f]
|
| 107 |
+
source_rows.append(dict(source_frame_id=f, sync_id=f'{seq}:{f}',
|
| 108 |
+
source_locator=row['color'][1] if 'color' in row else (meta_loc | {'source_frame_id': f, 'missing_rgb': True}), annotation_matches={
|
| 109 |
+
'labels': {'source_frame_id': f, 'source_timestamp_ns': None, 'clock_domain': None,
|
| 110 |
+
'match_method': 'index_map', 'delta_ns': None, 'source_locator': row['labels'][1]}
|
| 111 |
+
for _ in [0] if 'labels' in row},
|
| 112 |
+
component_sources={k: v[1] for k, v in row.items()}))
|
| 113 |
+
view = View(path, 'dex-ycb', args.release_id, seq, serial, source_rows,
|
| 114 |
+
sampling='dense' if ids == list(range(ids[0], ids[-1] + 1)) else 'sparse')
|
| 115 |
+
view.valid_rules = {
|
| 116 |
+
'mano': 'Source pose_m present and not all zero; side model/calibration available',
|
| 117 |
+
'keypoints': 'Corresponding joint_2d/joint_3d present; whole-hand all -1 is missing, broadcast to its 21 points',
|
| 118 |
+
'pose': 'Source pose_y for this ycb_ids slot present and not an all-zero matrix',
|
| 119 |
+
'segment': 'Source seg array provided for this frame; region codes and entity references validated',
|
| 120 |
+
'relations': 'Source sequence ycb_grasp_ind resolves through ycb_ids; broadcast sequence grasp to selected frames',
|
| 121 |
+
}
|
| 122 |
+
view.full_jpeg = getattr(args, 'jpeg_full_check', False)
|
| 123 |
+
view.meta['view_type'] = 'exo'
|
| 124 |
+
view.meta['sampling']['selection'] = {'max_frames': args.max_frames, 'views': args.views}
|
| 125 |
+
subject = re.search(r'subject-(\d+)', seq)
|
| 126 |
+
if subject and 1 <= int(subject[1]) <= 10:
|
| 127 |
+
index = int(subject[1])
|
| 128 |
+
view.meta.update(split='val' if index == 7 else 'test' if index in (8, 9) else 'train',
|
| 129 |
+
split_scheme='Dex-YCB/s1', split_source_locator={
|
| 130 |
+
'url': 'https://github.com/NVlabs/dex-ycb-toolkit/blob/master/dex_ycb_toolkit/dex_ycb.py',
|
| 131 |
+
'rule': 's1 unseen-subject: 01-06/10 train, 07 val, 08-09 test'})
|
| 132 |
+
view.meta.pop('split_reason', None)
|
| 133 |
+
view.rgb([frames[f]['color'][0] if 'color' in frames[f] else None for f in ids], {'frames_ref': 'camera/frames.jsonl'})
|
| 134 |
+
n = len(ids)
|
| 135 |
+
intr = calib.intrinsics.get(serial)
|
| 136 |
+
K = None if intr is None else np.array([[intr['fx'], 0, intr['cx']], [0, intr['fy'], intr['cy']], [0, 0, 1]])
|
| 137 |
+
ext = calib.extrinsics.get(str(meta['extrinsics']), {}).get(serial)
|
| 138 |
+
E = None
|
| 139 |
+
if ext is not None:
|
| 140 |
+
E = np.eye(4)
|
| 141 |
+
E[:3] = np.asarray(ext).reshape(3, 4)
|
| 142 |
+
E = np.linalg.inv(E)
|
| 143 |
+
view.camera(K, calibration_locator(calib_path, f'calibration/intrinsics/{serial}_640x480.yml'), E,
|
| 144 |
+
calibration_locator(calib_path, f'calibration/extrinsics_{meta["extrinsics"]}/extrinsics.yml',
|
| 145 |
+
conversion='inverse of source T_world_from_camera'))
|
| 146 |
+
sides = meta.get('mano_sides')
|
| 147 |
+
if sides not in (['left'], ['right']):
|
| 148 |
+
raise ValueError(f'expected exactly one anatomical source hand: {sides}')
|
| 149 |
+
side = sides[0]
|
| 150 |
+
slot = ['left', 'right'].index(side)
|
| 151 |
+
cal_name = meta['mano_calib'][0] if isinstance(meta['mano_calib'], list) else meta['mano_calib']
|
| 152 |
+
labels = [dict(np.load(frames[f]['labels'][0])) if 'labels' in frames[f] else {} for f in ids]
|
| 153 |
+
label_loc = {'frames_ref': 'camera/frames.jsonl', 'source_field': 'component_sources.labels'}
|
| 154 |
+
motion = np.full((n, 2, 61), np.nan, np.float32)
|
| 155 |
+
mv = np.zeros((n, 2), bool)
|
| 156 |
+
if side in models and any('pose_m' in lab for lab in labels):
|
| 157 |
+
for i, lab in enumerate(labels):
|
| 158 |
+
if 'pose_m' not in lab:
|
| 159 |
+
continue
|
| 160 |
+
pose = np.asarray(lab['pose_m']).reshape(51)
|
| 161 |
+
if not np.any(pose): # Official Dex-YCB missing-pose sentinel, independent of joints/seg.
|
| 162 |
+
continue
|
| 163 |
+
motion[i, slot] = np.r_[pose[:3], pca_to_axis_angle(pose[3:48], models[side]),
|
| 164 |
+
calib.betas[cal_name], pose[48:51]]
|
| 165 |
+
mv[i, slot] = True
|
| 166 |
+
view.tensor('mano', 'mano/axis_angle61/v1', 'annotation/mano/motion.pt', motion, mv,
|
| 167 |
+
['T', 'hand', 'parameter'], label_loc, model_profile=model_profile(models),
|
| 168 |
+
calibration_source=calibration_locator(calib_path, f'calibration/mano_{cal_name}/mano.yml'),
|
| 169 |
+
provenance={'kind': 'format_conversion', 'method': 'source PCA @ hands_components + hands_mean; explicit axis-angle consumed with flat_hand_mean=true'})
|
| 170 |
+
elif any('pose_m' in lab for lab in labels):
|
| 171 |
+
view.absent('mano', 'Source PCA exists; provide --mano-dir to expand it', 'dependency_missing')
|
| 172 |
+
else:
|
| 173 |
+
view.absent('mano', 'No source pose_m field')
|
| 174 |
+
for source_key, key, dim, unit in [('joint_2d', 'uv', 2, 'pixel'), ('joint_3d', 'xyz', 3, 'm')]:
|
| 175 |
+
if not any(source_key in x for x in labels):
|
| 176 |
+
view.absent('keypoints_' + key, 'No source ' + source_key)
|
| 177 |
+
continue
|
| 178 |
+
points = np.full((n, 2, 21, dim), np.nan, np.float32)
|
| 179 |
+
valid = np.zeros((n, 2, 21), bool)
|
| 180 |
+
for i, lab in enumerate(labels):
|
| 181 |
+
if source_key not in lab:
|
| 182 |
+
continue
|
| 183 |
+
p = np.asarray(lab[source_key]).reshape(21, dim)
|
| 184 |
+
points[i, slot] = p
|
| 185 |
+
valid[i, slot] = not np.all(p == -1) # Official sentinel covers the whole source hand.
|
| 186 |
+
# An individual off-image point (-1, -1) is not evidence of missing annotation.
|
| 187 |
+
view.tensor('keypoints_' + key, f'keypoints/{key}/v1', f'annotation/keypoints/{key}.pt',
|
| 188 |
+
points, valid, ['T', 'hand', 'keypoint', 'coordinate'], label_loc,
|
| 189 |
+
keypoint_schema='mano21/v1', unit=unit)
|
| 190 |
+
ycb_ids = [int(x) for x in meta['ycb_ids']]
|
| 191 |
+
for j, oid in enumerate(ycb_ids):
|
| 192 |
+
entity = f'ycb_{oid:02d}'
|
| 193 |
+
view.object(entity, meta_loc, source_object_id=oid, category_id=oid)
|
| 194 |
+
poses = np.full((n, 4, 4), np.nan, np.float32)
|
| 195 |
+
valid = np.zeros(n, bool)
|
| 196 |
+
for i, lab in enumerate(labels):
|
| 197 |
+
if 'pose_y' in lab:
|
| 198 |
+
pose = np.asarray(lab['pose_y'])
|
| 199 |
+
if pose.shape != (len(ycb_ids), 3, 4):
|
| 200 |
+
raise ValueError('pose_y shape differs from ycb_ids')
|
| 201 |
+
if np.any(pose[j]): # Official all-zero missing object pose sentinel.
|
| 202 |
+
poses[i] = np.eye(4)
|
| 203 |
+
poses[i, :3] = pose[j]
|
| 204 |
+
valid[i] = True
|
| 205 |
+
if any('pose_y' in lab for lab in labels):
|
| 206 |
+
view.tensor('pose_' + entity, 'object/rigid/v1', f'annotation/object/{entity}/pose.pt',
|
| 207 |
+
poses, valid, ['T', 'row', 'column'], label_loc,
|
| 208 |
+
convention='T_camera_from_object', unit='m')
|
| 209 |
+
else:
|
| 210 |
+
view.absent('pose_' + entity, 'No source pose_y field')
|
| 211 |
+
if oid in assets:
|
| 212 |
+
mesh_asset(view, entity, assets[oid], assets[oid] / 'textured_simple.obj',
|
| 213 |
+
locator(asset_archive, f'models/{assets[oid].name}/textured_simple.obj'))
|
| 214 |
+
else:
|
| 215 |
+
view.absent('mesh_' + entity, 'models.tar.gz unavailable', 'not_downloaded')
|
| 216 |
+
if any('seg' in lab for lab in labels):
|
| 217 |
+
mask_rows = []
|
| 218 |
+
width, height = view.meta['camera']['image_size']
|
| 219 |
+
for i, lab in enumerate(labels):
|
| 220 |
+
values = np.unique(lab.get('seg', np.zeros((height, width), np.uint8)))
|
| 221 |
+
mappings = []
|
| 222 |
+
for value in values:
|
| 223 |
+
value = int(value)
|
| 224 |
+
if value == 0:
|
| 225 |
+
continue
|
| 226 |
+
if value != 255 and value not in ycb_ids:
|
| 227 |
+
raise ValueError(f'unknown Dex-YCB region value {value}')
|
| 228 |
+
mappings.append(dict(mask_value=value, category_id='hand' if value == 255 else value,
|
| 229 |
+
entity_id='hand_' + side if value == 255 else f'ycb_{value:02d}', part_id=None,
|
| 230 |
+
source_instance_id=value))
|
| 231 |
+
mask_rows.append(dict(frame_index=i, labels=mappings))
|
| 232 |
+
view.raster('segment', (lab.get('seg', np.zeros((height, width), np.uint16)) for lab in labels),
|
| 233 |
+
['seg' in lab for lab in labels], label_loc, mask_rows)
|
| 234 |
+
view.meta['components']['segment'].update(coverage={'kind': 'selected_entities',
|
| 235 |
+
'entities': ['hand_' + side] + [f'ycb_{o:02d}' for o in ycb_ids]}, source_zero_meaning='background')
|
| 236 |
+
else:
|
| 237 |
+
view.absent('segment', 'No source seg field')
|
| 238 |
+
if any('aligned_depth_to_color' in frames[f] for f in ids):
|
| 239 |
+
def depths():
|
| 240 |
+
width, height = view.meta['camera']['image_size']
|
| 241 |
+
for f in ids:
|
| 242 |
+
item = frames[f].get('aligned_depth_to_color')
|
| 243 |
+
if item is None:
|
| 244 |
+
yield np.full((height, width), np.nan, np.float32)
|
| 245 |
+
else:
|
| 246 |
+
with Image.open(item[0]) as im:
|
| 247 |
+
yield np.asarray(im).astype(np.float32) / 1000.0
|
| 248 |
+
view.raster('depth', depths(), None, {'frames_ref': 'camera/frames.jsonl',
|
| 249 |
+
'source_field': 'component_sources.aligned_depth_to_color', 'conversion': 'millimetres to metres'})
|
| 250 |
+
else:
|
| 251 |
+
view.absent('depth', 'No source aligned_depth_to_color frames')
|
| 252 |
+
grasp = meta.get('ycb_grasp_ind')
|
| 253 |
+
if grasp is not None:
|
| 254 |
+
if not 0 <= int(grasp) < len(ycb_ids):
|
| 255 |
+
raise ValueError('invalid ycb_grasp_ind')
|
| 256 |
+
relation = dict(relation_type='grasp', subject_id='hand_' + side,
|
| 257 |
+
object_id=f'ycb_{ycb_ids[int(grasp)]:02d}', status='positive', source_locator=meta_loc,
|
| 258 |
+
provenance={'kind': 'source', 'method': 'sequence ycb_grasp_ind resolved through ycb_ids; not per-frame contact'})
|
| 259 |
+
view.relations([{'frame_index': i, 'relations': [relation]} for i in range(n)], np.ones(n, bool), meta_loc)
|
| 260 |
+
else:
|
| 261 |
+
view.absent('relations', 'No source grasp/contact relation')
|
| 262 |
+
return view.finish()
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
MEMBER = re.compile(r'^([^/]+)/(\d{8}_\d{6})/(meta\.yml|(\d{12})/(color|labels|aligned_depth_to_color)_(\d+)\.(jpg|npz|png))$')
|
| 266 |
+
|
| 267 |
+
|
| 268 |
+
def convert_archive(archive, args, out, calib, calib_path, models, assets, asset_archive):
|
| 269 |
+
selected_views = set(args.views.split(',')) if args.views else None
|
| 270 |
+
done = 0
|
| 271 |
+
current, meta, meta_loc, rows = None, None, None, {}
|
| 272 |
+
with tempfile.TemporaryDirectory(prefix='dex-source-') as wd:
|
| 273 |
+
work = Path(wd)
|
| 274 |
+
def flush():
|
| 275 |
+
nonlocal done
|
| 276 |
+
if not rows:
|
| 277 |
+
return
|
| 278 |
+
seq = archive.name.split('.tar')[0] + '_' + current
|
| 279 |
+
reports = {}
|
| 280 |
+
with sequence_dir(out, seq) as target:
|
| 281 |
+
for serial, frames in sorted(rows.items()):
|
| 282 |
+
reports[serial] = convert_view(target / serial, args, seq, serial, frames, meta,
|
| 283 |
+
meta_loc, calib, calib_path, models, assets, asset_archive)
|
| 284 |
+
build_record(out, seq, reports)
|
| 285 |
+
for staged in list(work.iterdir()):
|
| 286 |
+
if staged.is_dir():
|
| 287 |
+
shutil.rmtree(staged)
|
| 288 |
+
else:
|
| 289 |
+
staged.unlink()
|
| 290 |
+
done += 1
|
| 291 |
+
print(f'Converted {seq}', flush=True)
|
| 292 |
+
with tarfile.open(archive, 'r|gz') as tf:
|
| 293 |
+
for member in tf:
|
| 294 |
+
match = MEMBER.fullmatch(member.name)
|
| 295 |
+
if not member.isfile() or not match:
|
| 296 |
+
continue
|
| 297 |
+
seq = match[2]
|
| 298 |
+
if seq != current:
|
| 299 |
+
flush()
|
| 300 |
+
if args.limit and done >= args.limit:
|
| 301 |
+
break
|
| 302 |
+
current, meta, meta_loc, rows = seq, None, None, {}
|
| 303 |
+
data_kind = match[3]
|
| 304 |
+
if data_kind == 'meta.yml':
|
| 305 |
+
data = tf.extractfile(member).read()
|
| 306 |
+
meta = yaml_load_bytes(data)
|
| 307 |
+
meta_loc = locator(archive, member.name, data)
|
| 308 |
+
continue
|
| 309 |
+
serial, kind, f = match[4], match[5], int(match[6])
|
| 310 |
+
if selected_views and serial not in selected_views or args.max_frames and f >= args.max_frames:
|
| 311 |
+
continue
|
| 312 |
+
data = tf.extractfile(member).read()
|
| 313 |
+
dest = safe_member(work, member.name)
|
| 314 |
+
dest.parent.mkdir(parents=True, exist_ok=True)
|
| 315 |
+
dest.write_bytes(data)
|
| 316 |
+
row = rows.setdefault(serial, {}).setdefault(f, {})
|
| 317 |
+
if kind in row:
|
| 318 |
+
raise ValueError('duplicate archive frame')
|
| 319 |
+
row[kind] = (dest, locator(archive, member.name, data))
|
| 320 |
+
else:
|
| 321 |
+
flush()
|
| 322 |
+
return done
|
| 323 |
+
|
| 324 |
+
|
| 325 |
+
def main(argv=None):
|
| 326 |
+
p = parser('dex-ycb', __doc__)
|
| 327 |
+
p.add_argument('--subjects')
|
| 328 |
+
args = p.parse_args(argv)
|
| 329 |
+
archives = sorted({a for r in roots(args.root) for a in r.glob('*-subject-*.tar.gz')})
|
| 330 |
+
if args.subjects:
|
| 331 |
+
subjects = {s.strip().zfill(2) for s in args.subjects.split(',')}
|
| 332 |
+
archives = [a for a in archives if re.search(r'subject-(\d+)', a.name)[1] in subjects]
|
| 333 |
+
if not archives:
|
| 334 |
+
p.error('no Dex-YCB subject archives found')
|
| 335 |
+
cp = find_file(args.root, 'calibration.tar.gz') or find_file(args.root, 'calibration')
|
| 336 |
+
if cp is None:
|
| 337 |
+
p.error('calibration source missing')
|
| 338 |
+
calib = Calibration(cp.parent)
|
| 339 |
+
models = mano_models(args.mano_dir)
|
| 340 |
+
out = release(args, 'dex-ycb')
|
| 341 |
+
with tempfile.TemporaryDirectory(prefix='dex-models-') as wd:
|
| 342 |
+
assets, asset_archive = prepare_models(args.root, Path(wd))
|
| 343 |
+
for archive in archives:
|
| 344 |
+
convert_archive(archive, args, out, calib, cp, models, assets, asset_archive)
|
| 345 |
+
return 0
|
| 346 |
+
|
| 347 |
+
|
| 348 |
+
if __name__ == '__main__':
|
| 349 |
+
raise SystemExit(main())
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/script/convert_h2o_v1.0.py
ADDED
|
@@ -0,0 +1,545 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""H2O native RGB-D, MANO, joints and objects → CONTRACT.md v1.0 (no rendered masks)."""
|
| 3 |
+
from concurrent.futures import ThreadPoolExecutor
|
| 4 |
+
import json
|
| 5 |
+
import os
|
| 6 |
+
import re
|
| 7 |
+
import shutil
|
| 8 |
+
import tarfile
|
| 9 |
+
import tempfile
|
| 10 |
+
from pathlib import Path
|
| 11 |
+
import zipfile
|
| 12 |
+
|
| 13 |
+
# Bound native libraries before loading NumPy/Torch; each worker still uses independent FFmpeg processes.
|
| 14 |
+
for key in ('OMP_NUM_THREADS', 'OPENBLAS_NUM_THREADS', 'MKL_NUM_THREADS', 'NUMEXPR_NUM_THREADS'):
|
| 15 |
+
os.environ[key] = '1'
|
| 16 |
+
|
| 17 |
+
import numpy as np
|
| 18 |
+
from PIL import Image
|
| 19 |
+
import torch
|
| 20 |
+
|
| 21 |
+
from warehouse_v1_0 import (View, build_record, check_mesh, find_file, locator, mano_models, mesh_asset,
|
| 22 |
+
model_profile, parser, release, roots, safe_member, sequence_dir, sha256)
|
| 23 |
+
|
| 24 |
+
OBJECTS = {1: 'book', 2: 'espresso', 3: 'lotion', 4: 'spray',
|
| 25 |
+
5: 'milk', 6: 'cocoa', 7: 'chips', 8: 'cappuccino'}
|
| 26 |
+
MEMBER = re.compile(r'^(?:h2o_CASA/)?(subject\d+)/([^/]+)/(\d+)/(cam\d)/(.+)$')
|
| 27 |
+
FRAME = re.compile(r'(rgb|depth|cam_pose|hand_pose|hand_pose_mano|obj_pose|obj_pose_rt)/(\d+)\.(png|jpg|txt)$')
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def load_splits(root):
|
| 31 |
+
archive = find_file(root, 'label_split.zip')
|
| 32 |
+
result = {}
|
| 33 |
+
if archive is not None:
|
| 34 |
+
with zipfile.ZipFile(archive) as z:
|
| 35 |
+
for split in ('train', 'val', 'test'):
|
| 36 |
+
member = f'label_split/action_{split}.txt'
|
| 37 |
+
for line_no, line in enumerate(z.read(member).decode().splitlines(), 1):
|
| 38 |
+
fields = line.split()
|
| 39 |
+
if len(fields) < 2 or fields[1] == 'path':
|
| 40 |
+
continue
|
| 41 |
+
key = fields[1]
|
| 42 |
+
if key in result and result[key][0] != split:
|
| 43 |
+
raise ValueError('conflicting official splits')
|
| 44 |
+
result[key] = (split, locator(archive, member, record=line_no))
|
| 45 |
+
return result
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def load_assets(root, work):
|
| 49 |
+
archive = find_file(root, 'object.zip')
|
| 50 |
+
if archive is None:
|
| 51 |
+
return {}, None
|
| 52 |
+
with zipfile.ZipFile(archive) as z:
|
| 53 |
+
for member in z.infolist():
|
| 54 |
+
if member.is_dir():
|
| 55 |
+
continue
|
| 56 |
+
path = safe_member(work, member.filename)
|
| 57 |
+
path.parent.mkdir(parents=True, exist_ok=True)
|
| 58 |
+
path.write_bytes(z.read(member))
|
| 59 |
+
result = {}
|
| 60 |
+
for oid, name in OBJECTS.items():
|
| 61 |
+
directory = work / 'object' / name
|
| 62 |
+
aliases = []
|
| 63 |
+
# Source cocoa.obj -> ovomaltine.mtl -> cocoa.png, but the ZIP names the
|
| 64 |
+
# supplied texture ovomaltine.png. Keep all originals and add a byte-identical alias.
|
| 65 |
+
if name == 'cocoa' and not (directory / 'cocoa.png').exists():
|
| 66 |
+
mtl = directory / 'ovomaltine.mtl'
|
| 67 |
+
if mtl.is_file() and 'map_Kd cocoa.png' in mtl.read_text().splitlines():
|
| 68 |
+
texture = directory / 'ovomaltine.png'
|
| 69 |
+
shutil.copyfile(texture, directory / 'cocoa.png')
|
| 70 |
+
aliases.append({'file': 'cocoa.png', 'sha256': sha256(texture),
|
| 71 |
+
'source': locator(archive, 'object/cocoa/ovomaltine.png')})
|
| 72 |
+
candidates = list(directory.glob('*.obj'))
|
| 73 |
+
if len(candidates) != 1:
|
| 74 |
+
raise ValueError(f'expected one source OBJ for {name}')
|
| 75 |
+
check_mesh(candidates[0], directory) # Fail before decoding any large subject archive.
|
| 76 |
+
result[oid] = (directory, candidates[0], aliases)
|
| 77 |
+
return result, archive
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
def convert_view(path, args, seq, cam, rows, intr, splits, models, assets, asset_archive):
|
| 81 |
+
codec_threads = getattr(args, 'codec_threads', 1)
|
| 82 |
+
ids = list(range(min(rows), max(rows) + 1))
|
| 83 |
+
for f in ids:
|
| 84 |
+
rows.setdefault(f, {})
|
| 85 |
+
n = len(ids)
|
| 86 |
+
if not n:
|
| 87 |
+
raise ValueError('no RGB frames')
|
| 88 |
+
split, split_loc = splits.get(seq, ('unknown', None))
|
| 89 |
+
frame_rows = [dict(source_frame_id=f, sync_id=f'{seq}:{f}', source_locator=rows[f]['rgb'][1] if 'rgb' in rows[f] else {'sequence': seq, 'camera': cam, 'source_frame_id': f, 'missing_rgb': True},
|
| 90 |
+
component_sources={k: item[1] for k, item in rows[f].items()},
|
| 91 |
+
annotation_matches={k: dict(source_frame_id=f, source_timestamp_ns=None,
|
| 92 |
+
clock_domain=None, match_method='index_map', delta_ns=None)
|
| 93 |
+
for k in rows[f] if k != 'rgb'}) for f in ids]
|
| 94 |
+
view = View(path, 'H2O', args.release_id, seq.replace('/', '_'), cam, frame_rows, split=split)
|
| 95 |
+
view.valid_rules = {
|
| 96 |
+
'mano': 'Per-hand hand_pose_mano flag equals 1; corresponding side model available',
|
| 97 |
+
'keypoints': "Per-hand hand_pose flag equals 1, broadcast to that hand's 21 source points independently of MANO",
|
| 98 |
+
'pose': 'Source obj_pose_rt class equals this nonzero object class',
|
| 99 |
+
'points': 'Source obj_pose class equals this nonzero object class, broadcast to its 21 points',
|
| 100 |
+
}
|
| 101 |
+
view.full_jpeg = getattr(args, 'jpeg_full_check', False)
|
| 102 |
+
view.meta['view_type'] = 'ego' if cam == 'cam4' else 'exo' if cam in ('cam0', 'cam1', 'cam2', 'cam3') else 'unknown'
|
| 103 |
+
view.meta['sampling']['selection'] = {'max_frames': args.max_frames, 'views': args.views}
|
| 104 |
+
if split_loc:
|
| 105 |
+
view.meta.update(split_scheme='official_action_split', split_source_locator=split_loc)
|
| 106 |
+
# In the measured 275 H2O views, exact FFV1 was always smaller than exact H.264.
|
| 107 |
+
view.rgb([rows[f]['rgb'][0] if 'rgb' in rows[f] else None for f in ids],
|
| 108 |
+
{'frames_ref': 'camera/frames.jsonl'}, ffv1_first=True, codec_threads=codec_threads)
|
| 109 |
+
loc = {'frames_ref': 'camera/frames.jsonl', 'source_field': 'component_sources'}
|
| 110 |
+
if intr is not None:
|
| 111 |
+
fx, fy, cx, cy, width, height = np.loadtxt(intr[0]).ravel()
|
| 112 |
+
if [int(width), int(height)] != view.meta['camera']['image_size']:
|
| 113 |
+
raise ValueError('source intrinsics resolution mismatch')
|
| 114 |
+
K = np.array([[fx, 0, cx], [0, fy, cy], [0, 0, 1]])
|
| 115 |
+
view.camera(K, intr[1])
|
| 116 |
+
camps = np.full((n, 4, 4), np.nan, np.float32)
|
| 117 |
+
cv = np.zeros(n, bool)
|
| 118 |
+
data = []
|
| 119 |
+
for i, f in enumerate(ids):
|
| 120 |
+
lab = {k: np.loadtxt(item[0]).ravel() for k, item in rows[f].items() if k not in ('rgb', 'depth')}
|
| 121 |
+
data.append(lab)
|
| 122 |
+
if 'cam_pose' in lab:
|
| 123 |
+
camps[i] = np.linalg.inv(lab['cam_pose'].reshape(4, 4))
|
| 124 |
+
cv[i] = True
|
| 125 |
+
if cv.any():
|
| 126 |
+
view.tensor('extrinsic', 'transform/se3/v1', 'camera/extrinsic.pt', camps, cv,
|
| 127 |
+
['T', 'row', 'column'], loc, convention='T_camera_from_world',
|
| 128 |
+
source_convention='T_world_from_camera')
|
| 129 |
+
motion, mv = np.full((n, 2, 61), np.nan, np.float32), np.zeros((n, 2), bool)
|
| 130 |
+
points, pv = np.full((n, 2, 21, 3), np.nan, np.float32), np.zeros((n, 2, 21), bool)
|
| 131 |
+
object_ids = set()
|
| 132 |
+
for i, lab in enumerate(data):
|
| 133 |
+
if 'hand_pose_mano' in lab:
|
| 134 |
+
hands = lab['hand_pose_mano'].reshape(2, 62)
|
| 135 |
+
for side, row in enumerate(hands):
|
| 136 |
+
if row[0] not in (0, 1):
|
| 137 |
+
raise ValueError('unexpected H2O MANO presence flag')
|
| 138 |
+
if row[0] == 1:
|
| 139 |
+
motion[i, side] = np.r_[row[4:52], row[52:62], row[1:4]]
|
| 140 |
+
mv[i, side] = True
|
| 141 |
+
if 'hand_pose' in lab:
|
| 142 |
+
hands = lab['hand_pose'].reshape(2, 64)
|
| 143 |
+
for side, row in enumerate(hands):
|
| 144 |
+
if row[0] not in (0, 1):
|
| 145 |
+
raise ValueError('unexpected H2O keypoint presence flag')
|
| 146 |
+
if row[0] == 1:
|
| 147 |
+
points[i, side] = row[1:].reshape(21, 3)
|
| 148 |
+
pv[i, side] = True
|
| 149 |
+
for key in ('obj_pose', 'obj_pose_rt'):
|
| 150 |
+
if key in lab and lab[key][0] != 0:
|
| 151 |
+
object_ids.add(int(lab[key][0]))
|
| 152 |
+
if any('hand_pose_mano' in lab for lab in data):
|
| 153 |
+
if len(models) == 2:
|
| 154 |
+
view.tensor('mano', 'mano/axis_angle61/v1', 'annotation/mano/motion.pt', motion, mv,
|
| 155 |
+
['T', 'hand', 'parameter'], loc, model_profile=model_profile(models))
|
| 156 |
+
else:
|
| 157 |
+
view.absent('mano', 'Source parameters exist; --mano-dir must identify both model profiles', 'dependency_missing')
|
| 158 |
+
if any('hand_pose' in lab for lab in data):
|
| 159 |
+
view.tensor('keypoints_xyz', 'keypoints/xyz/v1', 'annotation/keypoints/xyz.pt', points, pv,
|
| 160 |
+
['T', 'hand', 'keypoint', 'coordinate'], loc, keypoint_schema='mano21/v1', unit='m')
|
| 161 |
+
for oid in sorted(object_ids):
|
| 162 |
+
if oid not in OBJECTS:
|
| 163 |
+
raise ValueError(f'unknown H2O object class {oid}')
|
| 164 |
+
entity = OBJECTS[oid]
|
| 165 |
+
view.object(entity, loc, category_id=oid, source_object_id=oid)
|
| 166 |
+
poses, ov = np.full((n, 4, 4), np.nan, np.float32), np.zeros(n, bool)
|
| 167 |
+
pts, kv = np.full((n, 21, 3), np.nan, np.float32), np.zeros((n, 21), bool)
|
| 168 |
+
for i, lab in enumerate(data):
|
| 169 |
+
if 'obj_pose_rt' in lab and lab['obj_pose_rt'][0] == oid:
|
| 170 |
+
poses[i] = lab['obj_pose_rt'][1:].reshape(4, 4)
|
| 171 |
+
ov[i] = True
|
| 172 |
+
if 'obj_pose' in lab and lab['obj_pose'][0] == oid:
|
| 173 |
+
pts[i] = lab['obj_pose'][1:].reshape(21, 3)
|
| 174 |
+
kv[i] = True
|
| 175 |
+
if ov.any():
|
| 176 |
+
view.tensor('pose_' + entity, 'object/rigid/v1', f'annotation/object/{entity}/pose.pt',
|
| 177 |
+
poses, ov, ['T', 'row', 'column'], loc, convention='T_camera_from_object', unit='m')
|
| 178 |
+
if kv.any():
|
| 179 |
+
view.tensor('points_' + entity, 'object_keypoints/camera/v1',
|
| 180 |
+
f'annotation/object/{entity}/keypoints/xyz.pt', pts, kv,
|
| 181 |
+
['T', 'keypoint', 'coordinate'], loc, keypoint_schema='H2O_official_object21',
|
| 182 |
+
keypoint_names=['center'] + [f'corner_{i}' for i in range(8)] + [f'edge_midpoint_{i}' for i in range(12)],
|
| 183 |
+
source_order='official obj_point_order.jpg: center, 8 corners, 12 edge midpoints', unit='m')
|
| 184 |
+
if oid in assets:
|
| 185 |
+
directory, obj, aliases = assets[oid]
|
| 186 |
+
asset_loc = locator(asset_archive, f'object/{entity}/{obj.name}')
|
| 187 |
+
if aliases:
|
| 188 |
+
asset_loc['texture_aliases'] = aliases
|
| 189 |
+
mesh_asset(view, entity, directory, obj, asset_loc)
|
| 190 |
+
else:
|
| 191 |
+
view.absent('mesh_' + entity, 'Source object.zip unavailable', 'not_downloaded')
|
| 192 |
+
if any('depth' in rows[f] for f in ids):
|
| 193 |
+
width, height = view.meta['camera']['image_size']
|
| 194 |
+
depth_threads = getattr(args, 'depth_threads', 1)
|
| 195 |
+
def read_depth(f):
|
| 196 |
+
item = rows[f].get('depth')
|
| 197 |
+
if item:
|
| 198 |
+
with Image.open(item[0]) as im:
|
| 199 |
+
return np.asarray(im).astype(np.float32) / 1000.0
|
| 200 |
+
return np.full((height, width), np.nan, np.float32)
|
| 201 |
+
def depths():
|
| 202 |
+
if depth_threads == 1:
|
| 203 |
+
yield from map(read_depth, ids)
|
| 204 |
+
else:
|
| 205 |
+
with ThreadPoolExecutor(max_workers=depth_threads) as pool:
|
| 206 |
+
# Ordered batches bound decoded arrays to depth_threads frames per view.
|
| 207 |
+
for start in range(0, len(ids), depth_threads):
|
| 208 |
+
yield from pool.map(read_depth, ids[start:start + depth_threads])
|
| 209 |
+
view.raster('depth', depths(), None, loc | {'source_field': 'component_sources.depth',
|
| 210 |
+
'definition': 'https://github.com/taeinkwon/h2oplayer/blob/main/utils.py',
|
| 211 |
+
'conversion': 'registered millimetre camera-Z to metres; no viewer range clipping'},
|
| 212 |
+
codec_threads=codec_threads)
|
| 213 |
+
else:
|
| 214 |
+
view.absent('depth', 'No source depth frames')
|
| 215 |
+
view.absent('segment', 'H2O provides no native segmentation; rendering deferred to v2.0')
|
| 216 |
+
view.absent('relations', 'No source contact/grasp annotation')
|
| 217 |
+
return view.finish()
|
| 218 |
+
|
| 219 |
+
|
| 220 |
+
def convert_archive(archive, args, out, splits, models, assets, asset_archive):
|
| 221 |
+
selected_views = set(args.views.split(',')) if args.views else None
|
| 222 |
+
subjects = {'subject' + s.strip() for s in args.subjects.split(',')} if args.subjects else None
|
| 223 |
+
current, rows, intrinsics, done = None, {}, {}, 0
|
| 224 |
+
published_views = set()
|
| 225 |
+
with tempfile.TemporaryDirectory(prefix='h2o-source-') as wd:
|
| 226 |
+
work = Path(wd)
|
| 227 |
+
def flush():
|
| 228 |
+
nonlocal done
|
| 229 |
+
if not rows:
|
| 230 |
+
return
|
| 231 |
+
seq = '/'.join(current)
|
| 232 |
+
reports, pending = {}, {}
|
| 233 |
+
for cam, frames in sorted(rows.items()):
|
| 234 |
+
existing = out / 'data' / seq.replace('/', '_') / cam
|
| 235 |
+
if (existing / 'metainfo.json').is_file():
|
| 236 |
+
old_frames = [json.loads(line) for line in (existing / 'camera/frames.jsonl').read_text().splitlines()]
|
| 237 |
+
if [f['source_frame_id'] for f in old_frames] != list(range(min(frames), max(frames) + 1)):
|
| 238 |
+
raise ValueError('existing view has different sampling; choose a new release-id')
|
| 239 |
+
for frame in old_frames:
|
| 240 |
+
incoming = frames.get(frame['source_frame_id'], {})
|
| 241 |
+
previous = frame.get('component_sources', {})
|
| 242 |
+
if set(previous) != set(incoming) or any(previous[k].get('sha256') != v[1].get('sha256') for k, v in incoming.items()):
|
| 243 |
+
raise ValueError('duplicate H2O view differs from the published source; choose a new release-id')
|
| 244 |
+
else:
|
| 245 |
+
pending[cam] = frames
|
| 246 |
+
if pending:
|
| 247 |
+
with sequence_dir(out, seq.replace('/', '_')) as target:
|
| 248 |
+
for cam, frames in pending.items():
|
| 249 |
+
reports[cam] = convert_view(target / cam, args, seq, cam, frames,
|
| 250 |
+
intrinsics.get(cam), splits, models, assets, asset_archive)
|
| 251 |
+
build_record(out, seq.replace('/', '_'), reports)
|
| 252 |
+
for staged in list(work.iterdir()):
|
| 253 |
+
if staged.is_dir():
|
| 254 |
+
shutil.rmtree(staged)
|
| 255 |
+
else:
|
| 256 |
+
staged.unlink()
|
| 257 |
+
done += 1
|
| 258 |
+
print(f'{"Converted" if pending else "Verified existing"} {seq}', flush=True)
|
| 259 |
+
# Uncompressed CASA supports seeking over large frames; gzip is single-pass.
|
| 260 |
+
mode = 'r:' if archive.suffix == '.tar' else 'r|gz'
|
| 261 |
+
with tarfile.open(archive, mode) as tf:
|
| 262 |
+
for member in tf:
|
| 263 |
+
match = MEMBER.fullmatch(member.name)
|
| 264 |
+
if not member.isfile() or not match:
|
| 265 |
+
continue
|
| 266 |
+
subj, scene, seq, cam, tail = match.groups()
|
| 267 |
+
if subjects and subj not in subjects:
|
| 268 |
+
continue
|
| 269 |
+
key = (subj, scene, seq)
|
| 270 |
+
if key != current:
|
| 271 |
+
flush()
|
| 272 |
+
if args.limit and done >= args.limit:
|
| 273 |
+
break
|
| 274 |
+
current, rows, intrinsics = key, {}, {}
|
| 275 |
+
published_views = {view.name for view in
|
| 276 |
+
(out / 'data' / '_'.join(key)).glob('cam*')
|
| 277 |
+
if (view / 'metainfo.json').is_file()}
|
| 278 |
+
if selected_views and cam not in selected_views:
|
| 279 |
+
continue
|
| 280 |
+
frame = FRAME.fullmatch(tail)
|
| 281 |
+
if tail != 'cam_intrinsics.txt' and not frame:
|
| 282 |
+
continue
|
| 283 |
+
if frame and args.max_frames and int(frame[2]) >= args.max_frames:
|
| 284 |
+
continue
|
| 285 |
+
data = tf.extractfile(member).read()
|
| 286 |
+
dest = safe_member(work, member.name)
|
| 287 |
+
if cam not in published_views:
|
| 288 |
+
dest.parent.mkdir(parents=True, exist_ok=True)
|
| 289 |
+
dest.write_bytes(data)
|
| 290 |
+
# Published views still verify source bytes, but never read their staging paths.
|
| 291 |
+
item = (dest, locator(archive, member.name, data))
|
| 292 |
+
if tail == 'cam_intrinsics.txt':
|
| 293 |
+
intrinsics[cam] = item
|
| 294 |
+
else:
|
| 295 |
+
kind, f = frame[1], int(frame[2])
|
| 296 |
+
row = rows.setdefault(cam, {}).setdefault(f, {})
|
| 297 |
+
if kind in row:
|
| 298 |
+
raise ValueError('duplicate H2O frame')
|
| 299 |
+
row[kind] = item
|
| 300 |
+
else:
|
| 301 |
+
flush()
|
| 302 |
+
return done
|
| 303 |
+
|
| 304 |
+
|
| 305 |
+
def main(argv=None):
|
| 306 |
+
p = parser('H2O', __doc__)
|
| 307 |
+
p.set_defaults(release_id='shared-v1.0')
|
| 308 |
+
p.add_argument('--workers', type=int, choices=range(1, 5), default=1,
|
| 309 |
+
help='Independent subject archives in parallel, 1..4; benchmark before using >2')
|
| 310 |
+
p.add_argument('--codec-threads', type=int, choices=(1, 2, 4, 8, 10), default=4,
|
| 311 |
+
help='FFV1 slice threads per encode; default 4, use 10 for the current full run')
|
| 312 |
+
p.add_argument('--decode-threads', type=int, choices=(1, 2, 4, 8, 10), default=1,
|
| 313 |
+
help='FFmpeg threads for source RGB decoding and decoded-media checks')
|
| 314 |
+
p.add_argument('--depth-threads', type=int, choices=(1, 2, 4), default=1,
|
| 315 |
+
help='Bounded ordered source depth PNG loading per worker')
|
| 316 |
+
p.add_argument('--subjects')
|
| 317 |
+
p.add_argument('--include-casa', action='store_true')
|
| 318 |
+
p.add_argument('--archive', type=Path, help='Convert one explicit source archive')
|
| 319 |
+
args = p.parse_args(argv)
|
| 320 |
+
os.environ['HAND_WAREHOUSE_FFMPEG_THREADS'] = str(args.decode_threads)
|
| 321 |
+
if args.include_casa and args.workers != 1:
|
| 322 |
+
p.error('CASA can share sequence IDs with subject archives; convert it sequentially in a separate release')
|
| 323 |
+
archives = [args.archive.expanduser()] if args.archive else sorted(
|
| 324 |
+
{a for root in roots(args.root) for a in root.glob('subject*_v1_1.tar.gz')})
|
| 325 |
+
if args.subjects and not args.archive:
|
| 326 |
+
requested = {'subject' + s.strip() for s in args.subjects.split(',')}
|
| 327 |
+
archives = [arc for arc in archives if arc.name.split('_', 1)[0] in requested]
|
| 328 |
+
if args.include_casa:
|
| 329 |
+
casa = find_file(args.root, 'h2o_CASA.tar')
|
| 330 |
+
if casa:
|
| 331 |
+
archives.append(casa)
|
| 332 |
+
if not archives:
|
| 333 |
+
p.error('no H2O archives found')
|
| 334 |
+
out = release(args, 'H2O')
|
| 335 |
+
source_mapping = next(p for p in (Path(__file__).resolve().parents[1] / 'docs/h2o-RAW_TO_SHARED.md',
|
| 336 |
+
Path(__file__).resolve().parents[1] / 'doc/RAW_TO_SHARED.md',
|
| 337 |
+
out / 'doc/RAW_TO_SHARED.md') if p.is_file())
|
| 338 |
+
mapping = out / 'doc/RAW_TO_SHARED.md'
|
| 339 |
+
if mapping.exists() and mapping.read_bytes() != source_mapping.read_bytes():
|
| 340 |
+
raise ValueError('RAW_TO_SHARED.md changed; choose a new release-id')
|
| 341 |
+
if not mapping.exists():
|
| 342 |
+
shutil.copyfile(source_mapping, mapping)
|
| 343 |
+
torch.set_num_threads(1)
|
| 344 |
+
models, splits = mano_models(args.mano_dir), load_splits(args.root)
|
| 345 |
+
with tempfile.TemporaryDirectory(prefix='h2o-assets-') as wd:
|
| 346 |
+
assets, asset_archive = load_assets(args.root, Path(wd))
|
| 347 |
+
def convert_one(archive):
|
| 348 |
+
return convert_archive(archive, args, out, splits, models, assets, asset_archive)
|
| 349 |
+
if args.workers == 1:
|
| 350 |
+
for archive in archives:
|
| 351 |
+
convert_one(archive)
|
| 352 |
+
else:
|
| 353 |
+
with ThreadPoolExecutor(max_workers=args.workers) as pool:
|
| 354 |
+
for archive, count in zip(archives, pool.map(convert_one, archives), strict=True):
|
| 355 |
+
print(f'Archive {archive.name}: {count} sequences', flush=True)
|
| 356 |
+
return 0
|
| 357 |
+
|
| 358 |
+
|
| 359 |
+
if __name__ == '__main__':
|
| 360 |
+
raise SystemExit(main())
|
| 361 |
+
|
| 362 |
+
# TODO(v2.0): 以下旧 MANO 网格和渲染分割代码仅保留备查;v1.0 不生成标注。
|
| 363 |
+
# def load_mano_model(path: Path):
|
| 364 |
+
# """MPI MANO pkl → numpy 字典。shapedirs 在 pkl 内为 chumpy Select(对 (778,3,20) 基
|
| 365 |
+
# 底 flat 选取前 10 个 shape 分量;idxs 已核实等价于 base[:,:,:10])。"""
|
| 366 |
+
# with open(path, "rb") as f:
|
| 367 |
+
# d = _ManoUnpickler(f, encoding="latin1").load()
|
| 368 |
+
# sd = d["shapedirs"]
|
| 369 |
+
# base = np.asarray(sd.a.x, np.float64) # (778, 3, 20)
|
| 370 |
+
# shapedirs = base.reshape(-1)[np.asarray(sd.idxs)].reshape(base.shape[0], 3, -1)
|
| 371 |
+
# jreg = d["J_regressor"]
|
| 372 |
+
# jreg = np.asarray(jreg.todense()) if hasattr(jreg, "todense") else np.asarray(jreg)
|
| 373 |
+
# return {"v_template": np.asarray(d["v_template"], np.float64),
|
| 374 |
+
# "shapedirs": shapedirs,
|
| 375 |
+
# "posedirs": np.asarray(d["posedirs"], np.float64),
|
| 376 |
+
# "weights": np.asarray(d["weights"], np.float64),
|
| 377 |
+
# "J_regressor": np.asarray(jreg, np.float64),
|
| 378 |
+
# "kintree": np.asarray(d["kintree_table"], np.int64),
|
| 379 |
+
# "faces": np.asarray(d["f"], np.int64)}
|
| 380 |
+
#
|
| 381 |
+
#
|
| 382 |
+
# def rodrigues(r):
|
| 383 |
+
# """axis-angle (N,3) → 旋转矩阵 (N,3,3)。公式 I + sinθ·K + (1−cosθ)·K²(已对 scipy 核验)。"""
|
| 384 |
+
# r = np.asarray(r, np.float64).reshape(-1, 3)
|
| 385 |
+
# th = np.linalg.norm(r, axis=1)
|
| 386 |
+
# R = np.zeros((len(r), 3, 3))
|
| 387 |
+
# nz = th > 1e-12
|
| 388 |
+
# R[~nz] = np.eye(3)
|
| 389 |
+
# k = r[nz] / th[nz, None]
|
| 390 |
+
# K = np.zeros((len(k), 3, 3))
|
| 391 |
+
# K[:, 0, 1], K[:, 0, 2], K[:, 1, 2] = -k[:, 2], k[:, 1], -k[:, 0]
|
| 392 |
+
# K[:, 1, 0], K[:, 2, 0], K[:, 2, 1] = k[:, 2], -k[:, 1], k[:, 0]
|
| 393 |
+
# s, c = np.sin(th[nz])[:, None, None], np.cos(th[nz])[:, None, None]
|
| 394 |
+
# R[nz] = np.eye(3) + s * K + (1 - c) * (K @ K)
|
| 395 |
+
# return R
|
| 396 |
+
#
|
| 397 |
+
#
|
| 398 |
+
# def _mano_chain(model, betas, pose):
|
| 399 |
+
# """返回 (v_shaped, J, Rs, G):G 为 16 个关节的全局变换(平移列 = 关节位置)。"""
|
| 400 |
+
# v = model["v_template"] + np.einsum("nkc,c->nk", model["shapedirs"], betas)
|
| 401 |
+
# J = model["J_regressor"] @ v
|
| 402 |
+
# Rs = rodrigues(np.asarray(pose, np.float64).reshape(16, 3))
|
| 403 |
+
# kt = model["kintree"]
|
| 404 |
+
# G = np.zeros((16, 4, 4))
|
| 405 |
+
# for j in range(16):
|
| 406 |
+
# p = kt[0, j] if j else -1
|
| 407 |
+
# loc = np.eye(4)
|
| 408 |
+
# loc[:3, :3] = Rs[j]
|
| 409 |
+
# loc[:3, 3] = J[j] - (J[p] if j else 0.0)
|
| 410 |
+
# G[j] = loc if not j else G[p] @ loc
|
| 411 |
+
# return v, J, Rs, G
|
| 412 |
+
#
|
| 413 |
+
#
|
| 414 |
+
# def mano_forward(model, betas, pose, transl):
|
| 415 |
+
# """MANO LBS 前向(经典蒙皮 M_j = G_j·G0_j⁻¹;对 hand_pose 21 关节实证 0.0 mm)。
|
| 416 |
+
# pose: 48 axis-angle([0:3] 全局);返回相机系米顶点 (778,3)。"""
|
| 417 |
+
# v, J, Rs, G = _mano_chain(model, betas, pose)
|
| 418 |
+
# lrot = (Rs[1:] - np.eye(3)).ravel()
|
| 419 |
+
# v_posed = v + np.einsum("nkc,c->nk", model["posedirs"], lrot)
|
| 420 |
+
# kt = model["kintree"]
|
| 421 |
+
# G0 = np.zeros((16, 4, 4))
|
| 422 |
+
# for j in range(16):
|
| 423 |
+
# p = kt[0, j] if j else -1
|
| 424 |
+
# loc = np.eye(4)
|
| 425 |
+
# loc[:3, 3] = J[j] - (J[p] if j else 0.0)
|
| 426 |
+
# G0[j] = loc if not j else G0[p] @ loc
|
| 427 |
+
# M = np.einsum("nj,jab->nab", model["weights"], G @ np.linalg.inv(G0))
|
| 428 |
+
# out = np.einsum("nab,nb->na", M[:, :3, :3], v_posed) + M[:, :3, 3]
|
| 429 |
+
# return out + np.asarray(transl, np.float64)
|
| 430 |
+
#
|
| 431 |
+
#
|
| 432 |
+
# def mano_chain_joints(model, betas, pose, transl):
|
| 433 |
+
# """16 个关节位置(相机系米)= 链平移列;自检用。"""
|
| 434 |
+
# _, _, _, G = _mano_chain(model, betas, pose)
|
| 435 |
+
# return G[:, :3, 3] + np.asarray(transl, np.float64)
|
| 436 |
+
#
|
| 437 |
+
#
|
| 438 |
+
# def rasterize(verts_cam, faces, labels, W, H, fx, fy, cx, cy):
|
| 439 |
+
# z = verts_cam[:, 2]
|
| 440 |
+
# P = faces
|
| 441 |
+
# ok = (z[P] > 0.02).all(1) # 任一顶点在相机后 → 丢弃该三角形
|
| 442 |
+
# P, labels = P[ok], labels[ok]
|
| 443 |
+
# if len(P) == 0:
|
| 444 |
+
# return np.zeros((H, W), np.uint16), np.zeros(0, np.int64)
|
| 445 |
+
# x = verts_cam[:, 0] / z * fx + cx
|
| 446 |
+
# y = verts_cam[:, 1] / z * fy + cy
|
| 447 |
+
# xa = np.maximum(0, np.minimum(np.floor(x[P[:, 0]]), np.minimum(
|
| 448 |
+
# np.floor(x[P[:, 1]]), np.floor(x[P[:, 2]]))).astype(np.int64))
|
| 449 |
+
# xb = np.minimum(W - 1, np.maximum(np.ceil(x[P[:, 0]]), np.maximum(
|
| 450 |
+
# np.ceil(x[P[:, 1]]), np.ceil(x[P[:, 2]]))).astype(np.int64))
|
| 451 |
+
# ya = np.maximum(0, np.minimum(np.floor(y[P[:, 0]]), np.minimum(
|
| 452 |
+
# np.floor(y[P[:, 1]]), np.floor(y[P[:, 2]]))).astype(np.int64))
|
| 453 |
+
# yb = np.minimum(H - 1, np.maximum(np.ceil(y[P[:, 0]]), np.maximum(
|
| 454 |
+
# np.ceil(y[P[:, 1]]), np.ceil(y[P[:, 2]]))).astype(np.int64))
|
| 455 |
+
# xa, ya = np.minimum(xa, xb), np.minimum(ya, yb) # 完全出画的三角形 → 空 bbox
|
| 456 |
+
# wdt, hgt = xb - xa + 1, yb - ya + 1
|
| 457 |
+
# cnt = wdt * hgt
|
| 458 |
+
# tot = int(cnt.sum())
|
| 459 |
+
# tri = np.repeat(np.arange(len(P)), cnt)
|
| 460 |
+
# k = np.arange(tot) - (np.cumsum(cnt) - cnt)[tri]
|
| 461 |
+
# px = xa[tri] + k % wdt[tri] + 0.5
|
| 462 |
+
# py = ya[tri] + k // wdt[tri] + 0.5
|
| 463 |
+
# ax, ay = x[P[tri, 0]], y[P[tri, 0]]
|
| 464 |
+
# bx, by = x[P[tri, 1]], y[P[tri, 1]]
|
| 465 |
+
# cx_, cy_ = x[P[tri, 2]], y[P[tri, 2]]
|
| 466 |
+
# area = ((x[P[:, 1]] - x[P[:, 0]]) * (y[P[:, 2]] - y[P[:, 0]])
|
| 467 |
+
# - (y[P[:, 1]] - y[P[:, 0]]) * (x[P[:, 2]] - x[P[:, 0]]))
|
| 468 |
+
# areat = area[tri]
|
| 469 |
+
# e0 = (bx - ax) * (py - ay) - (by - ay) * (px - ax)
|
| 470 |
+
# e1 = (cx_ - bx) * (py - by) - (cy_ - by) * (px - bx)
|
| 471 |
+
# e2 = (ax - cx_) * (py - cy_) - (ay - cy_) * (px - cx_)
|
| 472 |
+
# s = np.sign(areat)
|
| 473 |
+
# inside = (np.abs(areat) > 1e-9) & ((e0 * s >= 0) & (e1 * s >= 0) & (e2 * s >= 0))
|
| 474 |
+
# px, py, tri = px[inside], py[inside], tri[inside]
|
| 475 |
+
# at = areat[inside]
|
| 476 |
+
# w0, w1, w2 = e1[inside] / at, e2[inside] / at, e0[inside] / at
|
| 477 |
+
# zz = w0 * z[P[tri, 0]] + w1 * z[P[tri, 1]] + w2 * z[P[tri, 2]]
|
| 478 |
+
# pix = py.astype(np.int64) * W + px.astype(np.int64)
|
| 479 |
+
# order = np.lexsort((zz, pix)) # 同像素按深度升序 → 首条即最近
|
| 480 |
+
# pix, tri = pix[order], tri[order]
|
| 481 |
+
# first = np.unique(pix, return_index=True)[1]
|
| 482 |
+
# mask = np.zeros(H * W, np.uint16)
|
| 483 |
+
# win = tri[first]
|
| 484 |
+
# mask[pix[first]] = labels[win] + 1 # 临时标签 +1(0=背景)
|
| 485 |
+
# return mask.reshape(H, W), np.bincount(labels[win] + 1)
|
| 486 |
+
#
|
| 487 |
+
#
|
| 488 |
+
# # ============================================================================
|
| 489 |
+
# # ffmpeg 写出与核验(与 convert_dexycb.py 同构)
|
| 490 |
+
# # ============================================================================
|
| 491 |
+
# verts, faces_all, labels = [], [], []
|
| 492 |
+
# for ti, (tid, kind) in enumerate(tracks):
|
| 493 |
+
# if kind == "hand_left" and b["mano"][0] > 0.5:
|
| 494 |
+
# verts.append(mano_forward(mano_models["left"], b["mano"][52:62],
|
| 495 |
+
# b["mano"][4:52], b["mano"][1:4]))
|
| 496 |
+
# faces_all.append(mano_models["left"]["faces"])
|
| 497 |
+
# elif kind == "hand_right" and b["mano"][62] > 0.5:
|
| 498 |
+
# verts.append(mano_forward(mano_models["right"], b["mano"][114:124],
|
| 499 |
+
# b["mano"][66:114], b["mano"][63:66]))
|
| 500 |
+
# faces_all.append(mano_models["right"]["faces"])
|
| 501 |
+
# elif isinstance(kind, tuple) and int(b["objp"][0]) == kind[1]:
|
| 502 |
+
# M = np.asarray(b["objrt"][1:17], np.float64).reshape(4, 4)
|
| 503 |
+
# V0, F0 = meshes[kind[1]]
|
| 504 |
+
# verts.append(V0 @ M[:3, :3].T + M[:3, 3])
|
| 505 |
+
# faces_all.append(F0)
|
| 506 |
+
# else:
|
| 507 |
+
# continue
|
| 508 |
+
# labels.append(np.full(len(faces_all[-1]), ti))
|
| 509 |
+
# if verts:
|
| 510 |
+
# V = np.concatenate(verts)
|
| 511 |
+
# offs = np.cumsum([0] + [len(v) for v in verts[:-1]])
|
| 512 |
+
# F = np.concatenate([fa + o for fa, o in zip(faces_all, offs)])
|
| 513 |
+
# mask, counts = rasterize(V, F, np.concatenate(labels),
|
| 514 |
+
# IMG_W, IMG_H, fx, fy, cx, cy)
|
| 515 |
+
# else:
|
| 516 |
+
# mask, counts = np.zeros((IMG_H, IMG_W), np.uint16), np.zeros(0, np.int64)
|
| 517 |
+
# lut = np.zeros(n_tracks + 1, np.uint16)
|
| 518 |
+
# for ti in range(n_tracks):
|
| 519 |
+
# present = ti + 1 < len(counts) and counts[ti + 1] > 0
|
| 520 |
+
# if present:
|
| 521 |
+
# presence[tracks[ti][0]][f] = True
|
| 522 |
+
# if active_id[ti] is None:
|
| 523 |
+
# pid = next(i for i in range(1, 65535) if i not in used)
|
| 524 |
+
# used.add(pid)
|
| 525 |
+
# active_id[ti], seg_start[ti] = pid, f
|
| 526 |
+
# frame_maps[ti].append({"id": pid})
|
| 527 |
+
# lut[ti + 1] = active_id[ti]
|
| 528 |
+
# elif active_id[ti] is not None:
|
| 529 |
+
# frame_maps[ti][-1]["frames"] = [seg_start[ti], f - 1]
|
| 530 |
+
# segments[ti].append([seg_start[ti], f - 1])
|
| 531 |
+
# used.discard(active_id[ti])
|
| 532 |
+
# active_id[ti] = None
|
| 533 |
+
# mw.write(lut[mask])
|
| 534 |
+
|
| 535 |
+
|
| 536 |
+
# TODO(v2.0): 旧物体尺寸派生代码;v1.0 仅保留源物体关键点。
|
| 537 |
+
# pts = np.asarray(b["objp"][1:64], np.float64).reshape(21, 3)
|
| 538 |
+
# half = np.abs((pts[1:9] - pts[0]) @ M[:3, :3]).max(0)
|
| 539 |
+
# obj_recs.append({
|
| 540 |
+
# "track_id": f"o{classes.index(c)}", "frame": f,
|
| 541 |
+
# "mesh_ref": f"h2o/{OBJ_CLASSES[c]}.obj",
|
| 542 |
+
# "pose": {"quat": rotmat_to_quat_wxyz(M[:3, :3])[0].tolist(),
|
| 543 |
+
# "trans": M[:3, 3].tolist()},
|
| 544 |
+
# "bbox_center3d": pts[0].tolist(),
|
| 545 |
+
# "bbox_size": (2 * half).tolist()})
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/script/convert_hoi4d_v1.0.py
ADDED
|
@@ -0,0 +1,595 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""HOI4D native observations and annotations → CONTRACT.md v1.0."""
|
| 3 |
+
from collections import Counter
|
| 4 |
+
from concurrent.futures import ThreadPoolExecutor
|
| 5 |
+
from contextlib import ExitStack
|
| 6 |
+
from functools import lru_cache
|
| 7 |
+
import gzip
|
| 8 |
+
import io
|
| 9 |
+
import json
|
| 10 |
+
import os
|
| 11 |
+
from pathlib import Path
|
| 12 |
+
import pickle
|
| 13 |
+
import re
|
| 14 |
+
import shutil
|
| 15 |
+
import shlex
|
| 16 |
+
import posixpath
|
| 17 |
+
import subprocess
|
| 18 |
+
import tempfile
|
| 19 |
+
import tarfile
|
| 20 |
+
import threading
|
| 21 |
+
import zipfile
|
| 22 |
+
|
| 23 |
+
# Each worker owns one Python thread; prevent native libraries spawning CPU pools.
|
| 24 |
+
for key in ('OMP_NUM_THREADS', 'OPENBLAS_NUM_THREADS', 'MKL_NUM_THREADS', 'NUMEXPR_NUM_THREADS'):
|
| 25 |
+
os.environ[key] = '1'
|
| 26 |
+
|
| 27 |
+
import numpy as np
|
| 28 |
+
from PIL import Image
|
| 29 |
+
from scipy.spatial.transform import Rotation
|
| 30 |
+
|
| 31 |
+
import torch
|
| 32 |
+
|
| 33 |
+
from warehouse_v1_0 import (View, build_record, check_mesh, decode_args, find_file, json_write, locator,
|
| 34 |
+
mano_models, model_profile, parser, probe, release, run, safe_member, sequence_dir)
|
| 35 |
+
|
| 36 |
+
CATEGORIES = {
|
| 37 |
+
1: dict(cad="rigid/ToyCar", groups=[("main", [1], "Toy Car", 1)],
|
| 38 |
+
hands={2: "right"}, objmap={"Toycar": "main"}),
|
| 39 |
+
2: dict(cad="rigid/Mug", groups=[("a", [1], "Mug", 2), ("b", [3], "Mug", 2)],
|
| 40 |
+
hands={2: "right"}, objmap={"Watercup": "a"}),
|
| 41 |
+
3: dict(cad="articulated/Laptop", groups=[("main", [1, 3], "Laptop", 3)],
|
| 42 |
+
hands={2: "right"},
|
| 43 |
+
objmap={"Laptopdisplay": "main", "Laptopkeyboard": "main"}),
|
| 44 |
+
4: dict(cad="articulated/StorageFurniture",
|
| 45 |
+
groups=[("main", [1, 3, 4], "Storage Furniture", 4),
|
| 46 |
+
("bottle", [5], "Bottle", 5)],
|
| 47 |
+
hands={2: "right"},
|
| 48 |
+
objmap={"Lockerbody": "main", "Lockersldingdoor": "main",
|
| 49 |
+
"Lockerdrawer": "main", "Safebox": "main"}),
|
| 50 |
+
5: dict(cad="rigid/Bottle", groups=[("main", [1], "Bottle", 5),
|
| 51 |
+
("mug", [3], "Mug", 2)],
|
| 52 |
+
hands={2: "right"}, objmap={"bottleddrinks": "main"}),
|
| 53 |
+
6: dict(cad="articulated/Safe", groups=[("main", [1, 3], "Safe", 6),
|
| 54 |
+
("bottle", [4], "Bottle", 5)],
|
| 55 |
+
hands={2: "right"}, objmap={"Safebox": "main", "Safedoor": "main"}),
|
| 56 |
+
7: dict(cad="rigid/Bowl", groups=[("main", [1], "Bowl", 7),
|
| 57 |
+
("ball", [3], "Ball", None)],
|
| 58 |
+
hands={2: "right"}, objmap={"bowl": "main"}),
|
| 59 |
+
8: dict(cad="articulated/Bucket",
|
| 60 |
+
groups=[("a", [1, 3], "Bucket", 8), ("b", [4, 5], "Bucket", 8)],
|
| 61 |
+
hands={2: "right", 6: "left"},
|
| 62 |
+
objmap={"bucket": "a", "Buckethandle": "a"}),
|
| 63 |
+
9: dict(cad="articulated/Scissors", groups=[("main", [1, 3], "Scissors", 9)],
|
| 64 |
+
hands={2: "right"},
|
| 65 |
+
objmap={"scissors": "main", "scissors2": None}), # scissors2:场景道具,无掩码
|
| 66 |
+
11: dict(cad="articulated/Pliers", groups=[("main", [1, 3], "Pliers", 11)],
|
| 67 |
+
hands={2: "right"}, objmap={"Pliersleft": "main", "Pliersright": "main"}),
|
| 68 |
+
12: dict(cad="rigid/Kettle", groups=[("main", [1], "Kettle", 12),
|
| 69 |
+
("mug", [3], "Mug", 2)],
|
| 70 |
+
hands={2: "right"}, objmap={"kettle": "main"}),
|
| 71 |
+
13: dict(cad="rigid/Knife", groups=[("main", [1], "Knife", 13),
|
| 72 |
+
("apple", [3], "Apple", None)],
|
| 73 |
+
hands={2: "right"}, objmap={"knife": "main"}),
|
| 74 |
+
14: dict(cad="articulated/TrashCan",
|
| 75 |
+
groups=[("main", [1, 3], "Trash Can", 14), ("bottle", [4], "Bottle", 5)],
|
| 76 |
+
hands={2: "right"}, objmap={"Dustbinbase": "main", "Dustbincover": "main"}),
|
| 77 |
+
17: dict(cad="articulated/Lamp", groups=[("main", [1, 3, 4, 5], "Lamp", 17)],
|
| 78 |
+
hands={2: "right", 6: "left"},
|
| 79 |
+
objmap={"Lampbase": "main", "Tablelampfirstjoint": "main",
|
| 80 |
+
"Tablelampsecondjoint": "main", "Thirdjointoftablelamp": "main"}),
|
| 81 |
+
18: dict(cad="articulated/Stapler",
|
| 82 |
+
groups=[("main", [1, 3, 4], "Stapler", 18), ("paper", [5], "Paper", None)],
|
| 83 |
+
hands={2: "right", 6: "left"}, # 6=左手:官方 label.csv 缺列,实测修正
|
| 84 |
+
objmap={"Staplerbase": "main", "Staplercover": "main"}),
|
| 85 |
+
20: dict(cad="rigid/Chair", groups=[("main", [1], "Chair", 20)],
|
| 86 |
+
hands={2: "right", 3: "left"}, objmap={"chair": "main"}),
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
# Official HOI4D definitions/motion segmentation/label.csv; no spatial side inference.
|
| 91 |
+
REGION_NAMES = {1: {1: 'Toy Car', 2: 'Right Hand'}, 2: {1: 'Mug', 2: 'Right Hand', 3: 'Mug'}, 3: {1: 'Screen', 2: 'Right Hand', 3: 'Keyboard'}, 4: {1: 'Door', 2: 'Right Hand', 3: 'Body of the Cabinet', 4: 'Drawer', 5: 'Bottle'}, 5: {1: 'Bottle', 2: 'Right Hand', 3: 'Mug'}, 6: {1: 'Body of the Safe', 2: 'Right Hand', 3: 'Door', 4: 'Bottle'}, 7: {1: 'Bowl', 2: 'Right Hand', 3: 'Ball'}, 8: {1: 'Body of the Bucket', 2: 'Right Hand', 3: 'Handle', 4: 'Body of the Bucket', 5: 'Handle', 6: 'Left Hand'}, 9: {1: 'Left Part of the Scissors', 2: 'Right Hand', 3: 'Right Part of the Scissors'}, 11: {1: 'Left Part of the Pliers', 2: 'Right Hand', 3: 'Right Part of the Pliers'}, 12: {1: 'Kettle', 2: 'Right Hand', 3: 'Mug'}, 13: {1: 'Knife', 2: 'Right Hand', 3: 'Apple'}, 14: {1: 'Body of the Trash Can', 2: 'Right Hand', 3: 'Lid', 4: 'Bottle'}, 17: {1: 'Base', 2: 'Right Hand', 3: 'Tube', 4: 'Top Link', 5: 'Bottom Link', 6: 'Left Hand'}, 18: {1: 'Base', 2: 'Right Hand', 3: 'Slot', 4: 'Lid', 5: 'Paper'}, 20: {1: 'Chair', 2: 'Right Hand', 3: 'Left Hand'}}
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
class SplitFiles(io.RawIOBase):
|
| 95 |
+
"""Read concatenated source gzip parts without concatenating 119 GB on disk."""
|
| 96 |
+
def __init__(self, paths):
|
| 97 |
+
self.paths = iter(paths)
|
| 98 |
+
self.current = None
|
| 99 |
+
|
| 100 |
+
def readable(self):
|
| 101 |
+
return True
|
| 102 |
+
|
| 103 |
+
def readinto(self, buffer):
|
| 104 |
+
while True:
|
| 105 |
+
if self.current is None:
|
| 106 |
+
path = next(self.paths, None)
|
| 107 |
+
if path is None:
|
| 108 |
+
return 0
|
| 109 |
+
self.current = path.open('rb')
|
| 110 |
+
n = self.current.readinto(buffer)
|
| 111 |
+
if n:
|
| 112 |
+
return n
|
| 113 |
+
self.current.close()
|
| 114 |
+
self.current = None
|
| 115 |
+
|
| 116 |
+
def close(self):
|
| 117 |
+
if self.current is not None:
|
| 118 |
+
self.current.close()
|
| 119 |
+
super().close()
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
def extract_depths(root, sequences, work):
|
| 123 |
+
directory = find_file(root, 'DEPTH')
|
| 124 |
+
if directory is None:
|
| 125 |
+
return {}, []
|
| 126 |
+
parts = sorted(directory.glob('HOI4D_depth_video.tar.gz*'), key=lambda p: int(p.name.split('.gz')[1] or 0))
|
| 127 |
+
if not parts:
|
| 128 |
+
return {}, []
|
| 129 |
+
wanted = {f'HOI4D_depth_video/{seq}/align_depth/depth_video.avi': seq for seq in sequences}
|
| 130 |
+
found = {}
|
| 131 |
+
with SplitFiles(parts) as joined, io.BufferedReader(joined) as inp, gzip.GzipFile(fileobj=inp) as gz:
|
| 132 |
+
with tarfile.open(fileobj=gz, mode='r|') as tf:
|
| 133 |
+
for member in tf:
|
| 134 |
+
if member.isfile() and member.name in wanted:
|
| 135 |
+
seq = wanted[member.name]
|
| 136 |
+
dest = work / (seq.replace('/', '_') + '.avi')
|
| 137 |
+
with tf.extractfile(member) as src, dest.open('wb') as dst:
|
| 138 |
+
shutil.copyfileobj(src, dst)
|
| 139 |
+
found[seq] = (dest, {'files': [str(p.resolve()) for p in parts], 'member': member.name})
|
| 140 |
+
if len(found) == len(wanted):
|
| 141 |
+
break
|
| 142 |
+
return found, parts
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
def palette_mask(data):
|
| 146 |
+
with Image.open(io.BytesIO(data)) as im:
|
| 147 |
+
arr = np.asarray(im)
|
| 148 |
+
if arr.ndim == 2:
|
| 149 |
+
return arr.astype(np.uint16)
|
| 150 |
+
if arr.shape[-1] != 3:
|
| 151 |
+
raise ValueError('unsupported HOI4D mask representation')
|
| 152 |
+
# VOC's 256-color palette interleaves eight label bits into the high RGB bits.
|
| 153 |
+
# Invert it directly instead of sorting every pixel with np.unique.
|
| 154 |
+
if np.any(arr & np.array([31, 31, 63], dtype=np.uint8)):
|
| 155 |
+
raise ValueError('source mask has colors outside official VOC palette')
|
| 156 |
+
mask = np.zeros(arr.shape[:2], dtype=np.uint16)
|
| 157 |
+
for bit in range(8):
|
| 158 |
+
mask |= ((arr[..., bit % 3] >> (7 - bit // 3)) & 1).astype(np.uint16) << bit
|
| 159 |
+
return mask
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
# Four workers each reuse annotation and hand indices instead of rebuilding the ZIP directory.
|
| 163 |
+
@lru_cache(maxsize=8)
|
| 164 |
+
def index_frames(z):
|
| 165 |
+
index = {}
|
| 166 |
+
for name in z.namelist():
|
| 167 |
+
parent, _, filename = name.rpartition('/')
|
| 168 |
+
stem, dot, suffix = filename.rpartition('.')
|
| 169 |
+
if not dot or not stem.isdigit() or suffix not in ('png', 'json', 'pickle'):
|
| 170 |
+
continue
|
| 171 |
+
entries = index.setdefault((parent + '/', '.' + suffix), {})
|
| 172 |
+
f = int(stem)
|
| 173 |
+
if f in entries:
|
| 174 |
+
raise ValueError(f'duplicate frame number under {parent}')
|
| 175 |
+
entries[f] = name
|
| 176 |
+
return index
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
def frame_members(z, prefix, suffix):
|
| 180 |
+
return index_frames(z).get((prefix, suffix), {})
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
def convert_sequence(seq, args, target, rgbz, annz, hpz, calz, cadz, paths, models, depth):
|
| 184 |
+
# ponytail: cache only one sequence's encoded annotation bytes; no decoded masks or CAD cache.
|
| 185 |
+
@lru_cache(maxsize=None)
|
| 186 |
+
def read_annotation(archive, name):
|
| 187 |
+
return archive.read(name)
|
| 188 |
+
|
| 189 |
+
category = int(re.search(r'/C(\d+)/', seq)[1])
|
| 190 |
+
definition = CATEGORIES.get(category)
|
| 191 |
+
if definition is None:
|
| 192 |
+
raise ValueError(f'category mapping unavailable: {category}')
|
| 193 |
+
prefix = f'HOI4D_annotations/{seq}'
|
| 194 |
+
mask_members = frame_members(annz, prefix + '/2Dseg/mask/', '.png')
|
| 195 |
+
shifted = frame_members(annz, prefix + '/2Dseg/shift_mask/', '.png')
|
| 196 |
+
if not mask_members:
|
| 197 |
+
mask_members = shifted
|
| 198 |
+
pose_members = frame_members(annz, prefix + '/objpose/', '.json')
|
| 199 |
+
hand_members = {side: frame_members(hpz, f'Hand_pose/handpose_{side}_hand/{seq}/', '.pickle')
|
| 200 |
+
for side in ('left', 'right')} if hpz else {'left': {}, 'right': {}}
|
| 201 |
+
with tempfile.TemporaryDirectory(prefix='hoi4d-source-') as wd:
|
| 202 |
+
work = Path(wd)
|
| 203 |
+
member = f'HOI4D_release/{seq}/align_rgb/image.mp4'
|
| 204 |
+
video = work / 'rgb.mp4'
|
| 205 |
+
with rgbz.open(member) as src, video.open('wb') as dst:
|
| 206 |
+
shutil.copyfileobj(src, dst)
|
| 207 |
+
info = probe(video)
|
| 208 |
+
if 'nb_frames' not in info:
|
| 209 |
+
info['nb_frames'] = json.loads(run(['ffprobe', '-v', 'error', '-count_frames', '-select_streams', 'v:0',
|
| 210 |
+
'-show_entries', 'stream=nb_read_frames', '-of', 'json', str(video)], stdout=subprocess.PIPE).stdout)['streams'][0]['nb_read_frames']
|
| 211 |
+
n = int(info['nb_frames'])
|
| 212 |
+
if args.max_frames:
|
| 213 |
+
n = min(n, args.max_frames)
|
| 214 |
+
if shifted and mask_members != shifted and any(f not in mask_members and f in shifted for f in range(n)):
|
| 215 |
+
raise ValueError('shift_mask has frames absent from mask; correspondence unverified')
|
| 216 |
+
frames = []
|
| 217 |
+
for f in range(n):
|
| 218 |
+
sources = {}
|
| 219 |
+
if f in mask_members:
|
| 220 |
+
sources['segment'] = locator(paths['annotations'], mask_members[f], read_annotation(annz, mask_members[f]))
|
| 221 |
+
if f in pose_members:
|
| 222 |
+
sources['object'] = locator(paths['annotations'], pose_members[f], read_annotation(annz, pose_members[f]))
|
| 223 |
+
for side in ('left', 'right'):
|
| 224 |
+
if f in hand_members[side]:
|
| 225 |
+
sources['hand_' + side] = locator(paths['hand'], hand_members[side][f], read_annotation(hpz, hand_members[side][f]))
|
| 226 |
+
frames.append(dict(source_frame_id=f, source_locator=locator(paths['release'], member, frame=f),
|
| 227 |
+
component_sources=sources, annotation_matches={k: dict(source_frame_id=f, source_timestamp_ns=None,
|
| 228 |
+
clock_domain=None, match_method='index_map', delta_ns=None) for k in sources}))
|
| 229 |
+
view = View(target, 'HOI4D', args.release_id, seq.replace('/', '_'), 'ego', frames)
|
| 230 |
+
view.valid_rules = {
|
| 231 |
+
'mano': 'Matched side pickle contains poseCoeff, beta, trans and corresponding model available; zero angles are not missing',
|
| 232 |
+
'keypoints': 'Matched side pickle contains kps2D; independently provided source points, no visibility gate',
|
| 233 |
+
'pose': 'Matched source object record contains rotation and center; record identity retained',
|
| 234 |
+
'dimensions': 'Matched source object record contains dimensions; size/mesh relation remains source_unspecified',
|
| 235 |
+
'segment': 'Source mask or shift_mask present with verified palette codes and entity/part mapping',
|
| 236 |
+
}
|
| 237 |
+
view.full_jpeg = getattr(args, 'jpeg_full_check', False)
|
| 238 |
+
view.meta['view_type'] = 'ego'
|
| 239 |
+
view.meta['sampling']['selection'] = {'max_frames': args.max_frames, 'source_sequence': seq}
|
| 240 |
+
view.rgb([], locator(paths['release'], member), video=video, count=n)
|
| 241 |
+
intr_name = f'camera_params/{seq.split("/")[0]}/intrin.npy'
|
| 242 |
+
if calz and intr_name in calz.namelist():
|
| 243 |
+
view.camera(np.load(io.BytesIO(calz.read(intr_name))), locator(paths['camera'], intr_name))
|
| 244 |
+
extr_name = prefix + '/3Dseg/output.log'
|
| 245 |
+
if extr_name in annz.NameToInfo:
|
| 246 |
+
lines = [line for line in annz.read(extr_name).decode().splitlines() if line.strip()]
|
| 247 |
+
if len(lines) % 5:
|
| 248 |
+
raise ValueError('invalid Open3D camera trajectory')
|
| 249 |
+
extr, valid = np.full((n, 4, 4), np.nan, np.float32), np.zeros(n, bool)
|
| 250 |
+
for i in range(0, len(lines), 5):
|
| 251 |
+
idx = int(lines[i].split()[0])
|
| 252 |
+
if idx < n:
|
| 253 |
+
if valid[idx]:
|
| 254 |
+
raise ValueError('duplicate trajectory index')
|
| 255 |
+
extr[idx] = np.linalg.inv(np.loadtxt(io.StringIO('\n'.join(lines[i + 1:i + 5]))))
|
| 256 |
+
valid[idx] = True
|
| 257 |
+
view.tensor('extrinsic', 'transform/se3/v1', 'camera/extrinsic.pt', extr, valid,
|
| 258 |
+
['T', 'row', 'column'], locator(paths['annotations'], extr_name),
|
| 259 |
+
convention='T_camera_from_world', source_convention='Open3D LOG camera-to-world; inverted')
|
| 260 |
+
loc = {'frames_ref': 'camera/frames.jsonl', 'source_field': 'component_sources'}
|
| 261 |
+
motion, mv = np.full((n, 2, 61), np.nan, np.float32), np.zeros((n, 2), bool)
|
| 262 |
+
points, pv = np.full((n, 2, 21, 2), np.nan, np.float32), np.zeros((n, 2, 21), bool)
|
| 263 |
+
for slot, side in enumerate(('left', 'right')):
|
| 264 |
+
for f, name in hand_members[side].items():
|
| 265 |
+
if f >= n:
|
| 266 |
+
continue
|
| 267 |
+
data = pickle.loads(read_annotation(hpz, name), encoding='latin1')
|
| 268 |
+
if all(k in data for k in ('poseCoeff', 'beta', 'trans')):
|
| 269 |
+
motion[f, slot] = np.r_[np.asarray(data['poseCoeff']).reshape(48),
|
| 270 |
+
np.asarray(data['beta']).reshape(10), np.asarray(data['trans']).reshape(3)]
|
| 271 |
+
mv[f, slot] = True # Zero angles are a valid pose, not a missing sentinel.
|
| 272 |
+
if 'kps2D' in data:
|
| 273 |
+
points[f, slot] = np.asarray(data['kps2D']).reshape(21, 2)
|
| 274 |
+
pv[f, slot] = True
|
| 275 |
+
if mv.any():
|
| 276 |
+
if all(side in models for slot, side in enumerate(('left', 'right')) if mv[:, slot].any()):
|
| 277 |
+
view.tensor('mano', 'mano/axis_angle61/v1', 'annotation/mano/motion.pt', motion, mv,
|
| 278 |
+
['T', 'hand', 'parameter'], loc, model_profile=model_profile(models))
|
| 279 |
+
else:
|
| 280 |
+
view.absent('mano', 'Source MANO exists; provide --mano-dir to fix model identity', 'dependency_missing')
|
| 281 |
+
if pv.any():
|
| 282 |
+
view.tensor('keypoints_uv', 'keypoints/uv/v1', 'annotation/keypoints/uv.pt', points, pv,
|
| 283 |
+
['T', 'hand', 'keypoint', 'coordinate'], loc, keypoint_schema='mano21/v1', unit='pixel',
|
| 284 |
+
source_method='Upstream fitted MANO projection already present in kps2D')
|
| 285 |
+
objects = {}
|
| 286 |
+
groups = {key: (vals, name, cls) for key, vals, name, cls in definition['groups']}
|
| 287 |
+
def ensure_object(key, source_loc, category_id=None, frame=None, source_id=None):
|
| 288 |
+
if key not in objects:
|
| 289 |
+
view.object(key, source_loc, scope='frame' if frame is not None else 'sequence',
|
| 290 |
+
scope_id=f'{seq}:{frame}' if frame is not None else None,
|
| 291 |
+
category_id=category_id, source_object_id=source_id)
|
| 292 |
+
objects[key] = {}
|
| 293 |
+
mappings = []
|
| 294 |
+
mask_valid = [f in mask_members for f in range(n)]
|
| 295 |
+
if any(mask_valid):
|
| 296 |
+
width, height = view.meta['camera']['image_size']
|
| 297 |
+
def masks():
|
| 298 |
+
for f in range(n):
|
| 299 |
+
labels = []
|
| 300 |
+
if f in mask_members:
|
| 301 |
+
mask = palette_mask(read_annotation(annz, mask_members[f]))
|
| 302 |
+
for value in np.unique(mask):
|
| 303 |
+
value = int(value)
|
| 304 |
+
if value in (0, 255):
|
| 305 |
+
if value == 255:
|
| 306 |
+
raise ValueError('HOI4D 255 region semantics unverified')
|
| 307 |
+
continue
|
| 308 |
+
if REGION_NAMES[category].get(value) in ('Left Hand', 'Right Hand'):
|
| 309 |
+
entity, part, cls = 'hand_' + REGION_NAMES[category][value].split()[0].lower(), None, 'hand'
|
| 310 |
+
else:
|
| 311 |
+
group = next((k for k, (vals, _, _) in groups.items() if value in vals), None)
|
| 312 |
+
entity = group or f'unknown_region_{value}'
|
| 313 |
+
cls = groups[group][2] if group else None
|
| 314 |
+
part = f'region_{value}' if group and len(groups[group][0]) > 1 else None
|
| 315 |
+
ensure_object(entity, frames[f]['component_sources']['segment'], cls)
|
| 316 |
+
if part:
|
| 317 |
+
objects[entity].setdefault('parts', {})[part] = {'part_id': part, 'parent_id': None,
|
| 318 |
+
'has_model': False, 'mesh_ref': None, 'source_region_code': value, 'name': REGION_NAMES[category].get(value)}
|
| 319 |
+
labels.append(dict(mask_value=value, category_id=cls, entity_id=entity,
|
| 320 |
+
part_id=part, source_instance_id=value,
|
| 321 |
+
source_attributes={'region_name': REGION_NAMES[category].get(value)}))
|
| 322 |
+
else:
|
| 323 |
+
mask = np.zeros((height, width), np.uint16)
|
| 324 |
+
mappings.append(dict(frame_index=f, labels=labels))
|
| 325 |
+
yield mask
|
| 326 |
+
view.raster('segment', masks(), mask_valid, loc, mappings)
|
| 327 |
+
view.meta['components']['segment']['coverage'] = {'kind': 'unknown'}
|
| 328 |
+
if any(label['part_id'] for row in mappings for label in row['labels']):
|
| 329 |
+
view.meta['components']['segment']['segmentation_type'] = 'part'
|
| 330 |
+
else:
|
| 331 |
+
view.absent('segment', 'No native segmentation for this source sequence')
|
| 332 |
+
records = {}
|
| 333 |
+
for f, name in pose_members.items():
|
| 334 |
+
if f >= n:
|
| 335 |
+
continue
|
| 336 |
+
data = json.loads(read_annotation(annz, name))
|
| 337 |
+
# isEffective is not used to erase existing numerical annotations.
|
| 338 |
+
source_records = data.get('dataList', data.get('objects'))
|
| 339 |
+
if source_records is None:
|
| 340 |
+
raise ValueError('unrecognized source object annotation structure')
|
| 341 |
+
if category == 2 and source_records and (len(source_records) != 1 or
|
| 342 |
+
source_records[0].get('id') != 1 or source_records[0].get('label') != 'Watercup'):
|
| 343 |
+
raise ValueError('C2 native pose differs from the verified one-object target; cannot map to mask region 1')
|
| 344 |
+
label_counts = Counter(record['label'] for record in source_records)
|
| 345 |
+
per_frame = set()
|
| 346 |
+
for record_index, record in enumerate(source_records):
|
| 347 |
+
label = record['label']
|
| 348 |
+
group = definition['objmap'].get(label)
|
| 349 |
+
# Pinned official ObjTracking reads dataList[0] with segmentation label 1.
|
| 350 |
+
source_primary = category == 2 and record_index == 0 and record.get('id') == 1 and group == 'a'
|
| 351 |
+
ambiguous = group is not None and sum(g[2] == groups[group][2] for g in groups.values()) > 1 and not source_primary
|
| 352 |
+
ambiguous = ambiguous or (label_counts[label] > 1 and not source_primary) or group is None
|
| 353 |
+
entity = f'pose_frame_{f}_{record_index}' if ambiguous else group
|
| 354 |
+
ensure_object(entity, locator(paths['annotations'], name, record=record_index),
|
| 355 |
+
groups[group][2] if group else None, frame=f if ambiguous else None, source_id=record.get('id'))
|
| 356 |
+
if ambiguous:
|
| 357 |
+
view.build['unresolved'].append({'component': entity, 'status': 'source_semantics_unverified',
|
| 358 |
+
'reason': 'Source pose retained with frame identity; no guessed association to same-class mask instances'})
|
| 359 |
+
label_key = (entity, label)
|
| 360 |
+
if label_key in per_frame:
|
| 361 |
+
raise ValueError(f'ambiguous repeated object label {label}; source identity must be resolved')
|
| 362 |
+
per_frame.add(label_key)
|
| 363 |
+
records.setdefault(label_key, {})[f] = (record, locator(paths['annotations'], name, record=record.get('id')))
|
| 364 |
+
if category == 2 and any(entity == 'a' for entity, _ in records):
|
| 365 |
+
view.build['validation'].append({'component': 'C2_source_pose_mask_identity',
|
| 366 |
+
'rule': 'Official ObjTracking process_data.py reads dataList[0] with semantic mask label 1',
|
| 367 |
+
'source_revision': 'afa7bf37b02b7e33cf245acd08b98c207ccc175c',
|
| 368 |
+
'source_pose_id': 1, 'mask_value': 1, 'matched_frames': sum(len(by_frame) for (entity, _), by_frame in records.items() if entity == 'a')})
|
| 369 |
+
for (entity, label), by_frame in records.items():
|
| 370 |
+
part_labels = [k[1] for k in records if k[0] == entity]
|
| 371 |
+
articulated = definition['cad'].startswith('articulated/') and entity == definition['groups'][0][0]
|
| 372 |
+
part = 'pose_' + re.sub(r'[^a-zA-Z0-9_]', '_', label) if articulated or len(part_labels) > 1 else None
|
| 373 |
+
base = f'annotation/object/{entity}'
|
| 374 |
+
if part:
|
| 375 |
+
base += '/parts/' + part
|
| 376 |
+
objects[entity].setdefault('parts', {})[part] = dict(part_id=part, parent_id=None,
|
| 377 |
+
has_model=False, mesh_ref=None, source_label=label)
|
| 378 |
+
poses, valid = np.full((n, 4, 4), np.nan, np.float32), np.zeros(n, bool)
|
| 379 |
+
dimensions = np.full((n, 3), np.nan, np.float32)
|
| 380 |
+
dv = np.zeros(n, bool)
|
| 381 |
+
for f, (record, _) in by_frame.items():
|
| 382 |
+
if all(k in record for k in ('rotation', 'center')):
|
| 383 |
+
poses[f] = np.eye(4)
|
| 384 |
+
poses[f, :3, :3] = Rotation.from_euler('XYZ', [record['rotation'][k] for k in ('x', 'y', 'z')]).as_matrix()
|
| 385 |
+
poses[f, :3, 3] = [record['center'][k] for k in ('x', 'y', 'z')]
|
| 386 |
+
valid[f] = True
|
| 387 |
+
if 'dimensions' in record:
|
| 388 |
+
dimensions[f] = [record['dimensions'][k] for k in ('length', 'width', 'height')]
|
| 389 |
+
dv[f] = True
|
| 390 |
+
key = entity + ('_' + part if part else '')
|
| 391 |
+
view.tensor('pose_' + key, 'transform/se3/v1' if part else 'object/rigid/v1', base + '/pose.pt', poses, valid,
|
| 392 |
+
['T', 'row', 'column'], loc, convention='T_camera_from_part' if part else 'T_camera_from_object',
|
| 393 |
+
unit='m', source_label=label, source_euler_order='XYZ',
|
| 394 |
+
definition='https://github.com/hoi4d/ObjTracking/blob/main/process_data.py')
|
| 395 |
+
if dv.any():
|
| 396 |
+
view.tensor('dimensions_' + key, 'object/dimensions/v1', base + '/dimensions.pt', dimensions, dv,
|
| 397 |
+
['T', 'dimension'], loc, dimensions_semantics='source_unspecified', unit='m', scale_applied_to_mesh=False)
|
| 398 |
+
if cadz:
|
| 399 |
+
primary = definition['groups'][0][0]
|
| 400 |
+
if category != 2 and sum(g[2] == category for g in groups.values()) > 1:
|
| 401 |
+
primary = 'source_cad_instance'
|
| 402 |
+
instance = int(re.search(r'/N(\d+)/', seq)[1])
|
| 403 |
+
mesh_prefix = f'HOI4D_CAD_Model_for_release/{definition["cad"]}/{instance:03d}'
|
| 404 |
+
candidates = [name for name in cadz.namelist() if not name.endswith('/') and
|
| 405 |
+
(name == mesh_prefix + '.obj' or name.startswith(mesh_prefix + '/'))]
|
| 406 |
+
if candidates:
|
| 407 |
+
# Retain OBJ material/texture dependencies beside their original names.
|
| 408 |
+
queue = list(candidates)
|
| 409 |
+
for name in queue:
|
| 410 |
+
if Path(name).suffix.lower() not in ('.obj', '.mtl'):
|
| 411 |
+
continue
|
| 412 |
+
for line in cadz.read(name).decode().splitlines():
|
| 413 |
+
fields = shlex.split(line, comments=True)
|
| 414 |
+
if not fields:
|
| 415 |
+
continue
|
| 416 |
+
refs = fields[1:] if fields[0] == 'mtllib' else ([fields[-1]] if
|
| 417 |
+
fields[0].startswith('map_') or fields[0] in ('bump', 'norm', 'disp', 'decal') else [])
|
| 418 |
+
for ref in refs:
|
| 419 |
+
dependency = posixpath.normpath(posixpath.join(posixpath.dirname(name), ref))
|
| 420 |
+
if dependency not in cadz.NameToInfo:
|
| 421 |
+
raise ValueError(f'missing CAD dependency: {dependency}')
|
| 422 |
+
if dependency not in candidates:
|
| 423 |
+
candidates.append(dependency)
|
| 424 |
+
queue.append(dependency)
|
| 425 |
+
ensure_object(primary, locator(paths['cad'], mesh_prefix), category)
|
| 426 |
+
asset_dir = view.path / f'annotation/object/{primary}/assets'
|
| 427 |
+
asset_refs = []
|
| 428 |
+
for name in candidates:
|
| 429 |
+
relative = posixpath.relpath(name, mesh_prefix if definition['cad'].startswith('articulated/') else posixpath.dirname(mesh_prefix))
|
| 430 |
+
dest = safe_member(asset_dir, relative)
|
| 431 |
+
dest.parent.mkdir(parents=True, exist_ok=True)
|
| 432 |
+
dest.write_bytes(cadz.read(name))
|
| 433 |
+
ref = dest.relative_to(view.path).as_posix()
|
| 434 |
+
if dest.suffix.lower() == '.obj':
|
| 435 |
+
asset_key = re.sub(r'[^a-zA-Z0-9_]', '_', relative)
|
| 436 |
+
view.component('mesh_' + primary + '_' + asset_key, 'mesh/obj/v1', ref, ['vertex'],
|
| 437 |
+
locator(paths['cad'], name), unit='m', valid=True,
|
| 438 |
+
scale_applied_to_mesh=False, dimensions_semantics='source_unspecified')
|
| 439 |
+
asset_refs.append(ref)
|
| 440 |
+
if definition['cad'].startswith('articulated/'):
|
| 441 |
+
part_id = 'asset_' + asset_key
|
| 442 |
+
objects[primary].setdefault('parts', {})[part_id] = dict(part_id=part_id,
|
| 443 |
+
parent_id=None, has_model=True, mesh_ref=ref, source_asset=relative,
|
| 444 |
+
note='Source asset; correspondence to motion part labels remains unverified')
|
| 445 |
+
for asset_ref in asset_refs:
|
| 446 |
+
mesh_check = check_mesh(view.path / asset_ref, asset_dir)
|
| 447 |
+
view.build['validation'].append({'component': asset_ref, **mesh_check,
|
| 448 |
+
'unit_basis': 'official ObjTracking loads source canonical CAD without scaling in metre camera coordinates',
|
| 449 |
+
'geometric_acceptance': 'physical dimensions-to-mesh relation remains source_unspecified'})
|
| 450 |
+
metadata_path = view.path / f'annotation/object/{primary}/metainfo.json'
|
| 451 |
+
metadata = json.loads(metadata_path.read_text())
|
| 452 |
+
metadata.update(has_model=bool(asset_refs), asset_refs=asset_refs)
|
| 453 |
+
if definition['cad'].startswith('rigid/') and len(asset_refs) == 1:
|
| 454 |
+
metadata['mesh_ref'] = asset_refs[0]
|
| 455 |
+
json_write(metadata_path, metadata)
|
| 456 |
+
if definition['cad'].startswith('articulated/'):
|
| 457 |
+
view.build['unresolved'].append({'component': 'object_part_asset_association',
|
| 458 |
+
'status': 'source_semantics_unverified',
|
| 459 |
+
'reason': 'All source assets and motion labels retained, but no guessed correspondence or joint_state'})
|
| 460 |
+
for entity, info in objects.items():
|
| 461 |
+
if 'parts' in info:
|
| 462 |
+
ref = f'annotation/object/{entity}/articulation.json'
|
| 463 |
+
json_write(view.path / ref, {'parts': list(info['parts'].values()), 'joints': [],
|
| 464 |
+
'hierarchy_semantics': 'semantic_containment',
|
| 465 |
+
'note': 'Unassociated source region, motion and asset nodes; original CAD trees retained in assets'})
|
| 466 |
+
view.component('articulation_' + entity, 'object/articulated/v1', ref, [], loc)
|
| 467 |
+
meta_path = view.path / f'annotation/object/{entity}/metainfo.json'
|
| 468 |
+
metadata = json.loads(meta_path.read_text())
|
| 469 |
+
metadata['articulation_ref'] = ref
|
| 470 |
+
json_write(meta_path, metadata)
|
| 471 |
+
if depth is not None:
|
| 472 |
+
dpath, dloc = depth
|
| 473 |
+
dmeta = probe(dpath)
|
| 474 |
+
if [dmeta['width'], dmeta['height']] != view.meta['camera']['image_size']:
|
| 475 |
+
raise ValueError('HOI4D depth grid differs from RGB')
|
| 476 |
+
if dmeta['pix_fmt'] != 'gray16le':
|
| 477 |
+
raise ValueError('unexpected HOI4D depth pixel format')
|
| 478 |
+
width, height = view.meta['camera']['image_size']
|
| 479 |
+
raw = work / 'depth.raw'
|
| 480 |
+
limits = ['-frames:v', str(n)] if args.max_frames else []
|
| 481 |
+
run(decode_args(dpath, 'gray16le') + limits + ['-y', str(raw)])
|
| 482 |
+
if raw.stat().st_size != n * width * height * 2:
|
| 483 |
+
raise ValueError('depth/RGB frame count or grid mismatch')
|
| 484 |
+
def depths():
|
| 485 |
+
with raw.open('rb') as inp:
|
| 486 |
+
for _ in range(n):
|
| 487 |
+
yield np.frombuffer(inp.read(width * height * 2), '<u2').reshape(height, width).astype(np.float32) / 1000
|
| 488 |
+
view.raster('depth', depths(), None, dloc | {'conversion': 'registered millimetre camera-Z to metres'})
|
| 489 |
+
else:
|
| 490 |
+
if find_file(args.root, 'DEPTH'):
|
| 491 |
+
raise ValueError('DEPTH source exists, but no matching depth video was found')
|
| 492 |
+
view.absent('depth', 'Depth source not downloaded', 'not_downloaded')
|
| 493 |
+
return view.finish()
|
| 494 |
+
|
| 495 |
+
|
| 496 |
+
def main(argv=None):
|
| 497 |
+
p = parser('HOI4D', __doc__)
|
| 498 |
+
p.set_defaults(release_id='shared-v1.0')
|
| 499 |
+
# Four workers reached 21 observed OS threads including timing; stay below the 24-thread budget.
|
| 500 |
+
p.add_argument('--workers', type=int, choices=range(1, 5), default=1,
|
| 501 |
+
help='Independent views in parallel, 1..4; codec/BLAS threads fixed at 1')
|
| 502 |
+
p.add_argument('--tasks', help='Comma-separated substrings of source sequence paths')
|
| 503 |
+
p.add_argument('--sessions', help='Comma-separated sessions')
|
| 504 |
+
p.add_argument('--categories', help='Comma-separated category numbers')
|
| 505 |
+
args = p.parse_args(argv)
|
| 506 |
+
if args.views and args.views != 'ego':
|
| 507 |
+
p.error('HOI4D source camera ID is ego')
|
| 508 |
+
paths = {key: find_file(args.root, name) for key, name in {
|
| 509 |
+
'release': 'HOI4D_release.zip', 'annotations': 'HOI4D_annotations.zip', 'hand': 'HOI4D_Hand_pose.zip',
|
| 510 |
+
'camera': 'camera_params.zip', 'cad': 'HOI4D_CAD_Model_for_release.zip'}.items()}
|
| 511 |
+
if not paths['release'] or not paths['annotations']:
|
| 512 |
+
p.error('HOI4D release and annotation ZIPs are required')
|
| 513 |
+
out = release(args, 'HOI4D')
|
| 514 |
+
mapping = Path(__file__).resolve().parent.parent / 'docs/hoi4d-RAW_TO_SHARED.md'
|
| 515 |
+
published_mapping = out / 'doc/RAW_TO_SHARED.md'
|
| 516 |
+
if published_mapping.exists() and published_mapping.read_bytes() != mapping.read_bytes():
|
| 517 |
+
raise ValueError('RAW_TO_SHARED.md changed; choose a new release-id')
|
| 518 |
+
if not published_mapping.exists():
|
| 519 |
+
shutil.copyfile(mapping, published_mapping)
|
| 520 |
+
torch.set_num_threads(1)
|
| 521 |
+
models = mano_models(args.mano_dir)
|
| 522 |
+
with ExitStack() as stack, tempfile.TemporaryDirectory(prefix='hoi4d-depth-') as wd:
|
| 523 |
+
archives = {key: stack.enter_context(zipfile.ZipFile(path)) if path else None for key, path in paths.items()}
|
| 524 |
+
sequences = sorted(name.removeprefix('HOI4D_release/').removesuffix('/align_rgb/image.mp4')
|
| 525 |
+
for name in archives['release'].namelist() if name.endswith('/align_rgb/image.mp4'))
|
| 526 |
+
if args.tasks:
|
| 527 |
+
sequences = [s for s in sequences if any(token in s for token in args.tasks.split(','))]
|
| 528 |
+
if args.sessions:
|
| 529 |
+
sequences = [s for s in sequences if s.split('/')[0] in args.sessions.split(',')]
|
| 530 |
+
if args.categories:
|
| 531 |
+
sequences = [s for s in sequences if re.search(r'/C(\d+)/', s)[1] in args.categories.split(',')]
|
| 532 |
+
if args.limit:
|
| 533 |
+
sequences = sequences[:args.limit]
|
| 534 |
+
if not sequences:
|
| 535 |
+
p.error('no matching source sequences')
|
| 536 |
+
depths, _ = extract_depths(args.root, sequences, Path(wd))
|
| 537 |
+
worker = threading.local()
|
| 538 |
+
worker_stacks = []
|
| 539 |
+
def init_worker():
|
| 540 |
+
owned = ExitStack()
|
| 541 |
+
try:
|
| 542 |
+
# ZipFile.read mutates a shared seek position: never share a handle across workers.
|
| 543 |
+
worker.archives = {key: owned.enter_context(zipfile.ZipFile(path)) if path else None
|
| 544 |
+
for key, path in paths.items()}
|
| 545 |
+
index_frames(worker.archives['annotations'])
|
| 546 |
+
if worker.archives['hand']:
|
| 547 |
+
index_frames(worker.archives['hand'])
|
| 548 |
+
except BaseException:
|
| 549 |
+
owned.close()
|
| 550 |
+
raise
|
| 551 |
+
worker_stacks.append(owned)
|
| 552 |
+
def convert_one(seq):
|
| 553 |
+
source = archives if args.workers == 1 else worker.archives
|
| 554 |
+
name = seq.replace('/', '_')
|
| 555 |
+
with sequence_dir(out, name) as target:
|
| 556 |
+
report = convert_sequence(seq, args, target / 'ego', source['release'], source['annotations'],
|
| 557 |
+
source['hand'], source['camera'], source['cad'], paths, models, depths.get(seq))
|
| 558 |
+
build_record(out, name, {'ego': report})
|
| 559 |
+
return seq
|
| 560 |
+
if args.workers == 1:
|
| 561 |
+
for seq in map(convert_one, sequences):
|
| 562 |
+
print(f'Converted {seq}', flush=True)
|
| 563 |
+
else:
|
| 564 |
+
try:
|
| 565 |
+
with ThreadPoolExecutor(max_workers=args.workers, initializer=init_worker) as pool:
|
| 566 |
+
for seq in pool.map(convert_one, sequences):
|
| 567 |
+
print(f'Converted {seq}', flush=True)
|
| 568 |
+
finally:
|
| 569 |
+
for owned in worker_stacks:
|
| 570 |
+
owned.close()
|
| 571 |
+
return 0
|
| 572 |
+
|
| 573 |
+
|
| 574 |
+
if __name__ == '__main__':
|
| 575 |
+
raise SystemExit(main())
|
| 576 |
+
|
| 577 |
+
# TODO(v2.0): 旧 bbox IoU 实例重分配属于推断,注释保留,不在 v1.0 执行。
|
| 578 |
+
# # 同类多实例(C8 双桶 / C2 双杯):2dBox 可用时按 IoU 复核归属
|
| 579 |
+
# cls = next(x[3] for x in cat["groups"] if x[0] == gk)
|
| 580 |
+
# sibs = [g for g in cat["groups"]
|
| 581 |
+
# if g[0] != gk and cls is not None and g[3] == cls]
|
| 582 |
+
# box = (d.get("2dBox") or {}).get("camera1")
|
| 583 |
+
# box = (box[0][0], box[0][1], box[1][0], box[1][1]) \
|
| 584 |
+
# if box and len(box) == 2 else None
|
| 585 |
+
# if box is not None and sibs:
|
| 586 |
+
# gvals = next(x[1] for x in cat["groups"] if x[0] == gk)
|
| 587 |
+
# best, best_iou = gk, box_iou(box, bbox_of(mask, gvals))
|
| 588 |
+
# for s in sibs:
|
| 589 |
+
# if ("obj", s[0]) not in tid_of_group:
|
| 590 |
+
# continue
|
| 591 |
+
# i = box_iou(box, bbox_of(mask, s[1]))
|
| 592 |
+
# if i > best_iou + 0.1 and i > 0.15:
|
| 593 |
+
# best, best_iou = s[0], i
|
| 594 |
+
# if best != gk:
|
| 595 |
+
# gk, iou_fixups = best, iou_fixups + 1
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/script/convert_visor_v1.0.py
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""VISOR source polygons and contact → CONTRACT.md v1.0, without rasterization or side inference."""
|
| 3 |
+
from collections import Counter
|
| 4 |
+
import hashlib
|
| 5 |
+
import json
|
| 6 |
+
import re
|
| 7 |
+
import shutil
|
| 8 |
+
import tempfile
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
import zipfile
|
| 11 |
+
|
| 12 |
+
import numpy as np
|
| 13 |
+
import torch
|
| 14 |
+
|
| 15 |
+
from warehouse_v1_0 import (View, build_record, find_file, jsonl_write, locator, parser,
|
| 16 |
+
release, roots, sequence_dir, source)
|
| 17 |
+
|
| 18 |
+
FRAME = re.compile(r'frame_(\d+)')
|
| 19 |
+
HAND = {300: 'left', 301: 'right'}
|
| 20 |
+
GLOVE = {303: 'left', 304: 'right'}
|
| 21 |
+
STATES = {'hand-not-in-contact': 'negative', 'glove-not-in-contact': 'negative',
|
| 22 |
+
'none-of-the-above': 'target_unannotated', 'inconclusive': 'unknown'}
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def hand_side(ann):
|
| 26 |
+
if ann['class_id'] in HAND:
|
| 27 |
+
return HAND[ann['class_id']]
|
| 28 |
+
if ann['class_id'] not in (60, 303, 304):
|
| 29 |
+
return None
|
| 30 |
+
raw = ann.get('on_which_hand')
|
| 31 |
+
raw = raw if isinstance(raw, list) else [raw]
|
| 32 |
+
sides = set()
|
| 33 |
+
for item in raw:
|
| 34 |
+
if item == 'left hand':
|
| 35 |
+
sides.add('left')
|
| 36 |
+
if item in ('right hand', 'rigth hand'):
|
| 37 |
+
sides.add('right')
|
| 38 |
+
if len(sides) == 1:
|
| 39 |
+
return next(iter(sides))
|
| 40 |
+
if not sides and ann['class_id'] in GLOVE:
|
| 41 |
+
return GLOVE[ann['class_id']]
|
| 42 |
+
return None
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def convert_video(video, split, annotation, ann_loc, rgb_zip, rgb_loc, mapping, args, target):
|
| 46 |
+
indexed = sorted(enumerate(annotation['video_annotations']), key=lambda row: int(FRAME.search(row[1]['image']['name'])[1]))
|
| 47 |
+
if args.max_frames:
|
| 48 |
+
indexed = indexed[:args.max_frames]
|
| 49 |
+
if len({row['image']['name'] for _, row in indexed}) != len(indexed):
|
| 50 |
+
raise ValueError('duplicate VISOR frame')
|
| 51 |
+
keys = lambda row, ann: (row['image']['subsequence'], ann['class_id'], ann['name'])
|
| 52 |
+
collisions = set()
|
| 53 |
+
for _, row in indexed:
|
| 54 |
+
collisions.update(key for key, number in Counter(keys(row, a) for a in row['annotations']).items() if number > 1)
|
| 55 |
+
frames, paths = [], []
|
| 56 |
+
with tempfile.TemporaryDirectory(prefix='visor-rgb-') as wd, zipfile.ZipFile(rgb_zip) as z:
|
| 57 |
+
work = Path(wd)
|
| 58 |
+
for original_index, row in indexed:
|
| 59 |
+
name = row['image']['name']
|
| 60 |
+
data = z.read(name)
|
| 61 |
+
path = work / Path(name).name
|
| 62 |
+
path.write_bytes(data)
|
| 63 |
+
paths.append(path)
|
| 64 |
+
loc = rgb_loc | {'nested_member': name, 'sha256': hashlib.sha256(data).hexdigest()}
|
| 65 |
+
frames.append(dict(source_frame_id=int(FRAME.search(name)[1]), source_locator=loc,
|
| 66 |
+
source_image=row['image'], original_frame_name=mapping.get(name),
|
| 67 |
+
annotation_matches={'segment': dict(source_frame_id=name, source_timestamp_ns=None,
|
| 68 |
+
clock_domain=None, match_method='index_map', delta_ns=None,
|
| 69 |
+
source_locator=ann_loc | {'record': f'video_annotations[{original_index}]'})}))
|
| 70 |
+
view = View(target, 'EPIC-KITCHENS-VISOR', args.release_id, video, 'ego', frames, sampling='sparse', split=split)
|
| 71 |
+
view.valid_rules = {
|
| 72 |
+
'segment': 'Selected sparse annotation frame present; all source polygons finite with at least three vertices and entity mapping valid',
|
| 73 |
+
'relations': 'At least one source in_contact_object value present; positive targets resolve in the same frame; unknown is an explicit usable status',
|
| 74 |
+
}
|
| 75 |
+
view.full_jpeg = getattr(args, 'jpeg_full_check', False)
|
| 76 |
+
view.meta.update(view_type='ego', split_scheme='VISOR_GroundTruth_SparseAnnotations', split_source_locator=ann_loc)
|
| 77 |
+
view.meta['sampling']['selection'] = {'representation': 'official sparse annotations', 'max_frames': args.max_frames}
|
| 78 |
+
view.rgb(paths, rgb_loc)
|
| 79 |
+
entities = {}
|
| 80 |
+
polygons, mappings, relations, relation_valid = [], [], [], []
|
| 81 |
+
for f, (original_index, row) in enumerate(indexed):
|
| 82 |
+
frame_loc = ann_loc | {'record': f'video_annotations[{original_index}]'}
|
| 83 |
+
id_map, labels, polys = {}, [], []
|
| 84 |
+
for code, ann in enumerate(row['annotations'], 1):
|
| 85 |
+
if code >= 65535:
|
| 86 |
+
raise ValueError('too many source instances')
|
| 87 |
+
sid = ann['id']
|
| 88 |
+
if sid in id_map:
|
| 89 |
+
raise ValueError('duplicate source instance ID within a frame')
|
| 90 |
+
side = hand_side(ann)
|
| 91 |
+
if side is not None:
|
| 92 |
+
entity = 'hand_' + side
|
| 93 |
+
else:
|
| 94 |
+
key = keys(row, ann)
|
| 95 |
+
identity = key + (sid, row['image']['name']) if key in collisions else key
|
| 96 |
+
entity = 'object_' + hashlib.sha256(json.dumps(identity).encode()).hexdigest()[:20]
|
| 97 |
+
if entity not in entities:
|
| 98 |
+
scope = 'frame' if key in collisions else 'subsequence'
|
| 99 |
+
scope_id = f'{video}:{row["image"]["name"]}' if scope == 'frame' else f'{video}:{key[0]}'
|
| 100 |
+
view.object(entity, frame_loc | {'source_instance_id': sid}, scope, scope_id,
|
| 101 |
+
category_id=ann['class_id'], name=ann['name'],
|
| 102 |
+
association_basis='source_frame_instance' if scope == 'frame' else 'official_subsequence_entity_name')
|
| 103 |
+
entities[entity] = True
|
| 104 |
+
id_map[sid] = entity
|
| 105 |
+
for polygon in ann.get('segments', []):
|
| 106 |
+
p = np.asarray(polygon)
|
| 107 |
+
if p.ndim != 2 or p.shape[1] != 2 or len(p) < 3 or not np.isfinite(p).all():
|
| 108 |
+
raise ValueError(f'invalid source polygon {sid}')
|
| 109 |
+
polys.append(dict(mask_value=code, polygons=ann.get('segments', [])))
|
| 110 |
+
labels.append(dict(mask_value=code, category_id=ann['class_id'], entity_id=entity,
|
| 111 |
+
part_id=None, source_instance_id=sid,
|
| 112 |
+
source_attributes={k: v for k, v in ann.items() if k != 'segments'}))
|
| 113 |
+
rr = []
|
| 114 |
+
provided = False
|
| 115 |
+
for ann in row['annotations']:
|
| 116 |
+
raw = ann.get('in_contact_object')
|
| 117 |
+
values = raw if isinstance(raw, list) else [raw]
|
| 118 |
+
for value in values:
|
| 119 |
+
if value is None:
|
| 120 |
+
continue
|
| 121 |
+
provided = True
|
| 122 |
+
status = STATES.get(value)
|
| 123 |
+
obj = None
|
| 124 |
+
if status is None:
|
| 125 |
+
if value not in id_map:
|
| 126 |
+
raise ValueError(f'unresolved source contact target {value} in {video} frame {f}')
|
| 127 |
+
status, obj = 'positive', id_map[value]
|
| 128 |
+
rr.append(dict(relation_type='contact', subject_id=id_map[ann['id']], object_id=obj,
|
| 129 |
+
status=status, source_value=value, source_locator=frame_loc | {'source_instance_id': ann['id']},
|
| 130 |
+
provenance=source('Resolve source contact ID against instances in this frame')))
|
| 131 |
+
polygons.append(dict(frame_index=f, instances=polys))
|
| 132 |
+
mappings.append(dict(frame_index=f, labels=labels))
|
| 133 |
+
relations.append(dict(frame_index=f, relations=rr))
|
| 134 |
+
relation_valid.append(provided)
|
| 135 |
+
jsonl_write(view.path / 'annotation/segment/polygons.jsonl', polygons)
|
| 136 |
+
jsonl_write(view.path / 'annotation/segment/instances.jsonl', mappings)
|
| 137 |
+
torch.save(torch.ones(len(frames), dtype=torch.bool, device='cpu'), view.path / 'annotation/segment/mask_valid.pt')
|
| 138 |
+
view.component('segment', 'segment/instance_polygons/v1', 'annotation/segment/polygons.jsonl', ['T'], ann_loc,
|
| 139 |
+
valid_ref='annotation/segment/mask_valid.pt', valid_axes=['T'], segmentation_type='instance',
|
| 140 |
+
mapping_ref='annotation/segment/instances.jsonl', coverage={'kind': 'unknown', 'exhaustive_ref': 'annotation/segment/instances.jsonl'})
|
| 141 |
+
view.relations(relations, relation_valid, ann_loc)
|
| 142 |
+
for component in ('depth', 'mano', 'keypoints_uv', 'keypoints_xyz', 'intrinsic', 'extrinsic'):
|
| 143 |
+
view.absent(component, 'Not provided by VISOR sparse source annotations')
|
| 144 |
+
return view.finish()
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
def main(argv=None):
|
| 148 |
+
p = parser('EPIC-KITCHENS-VISOR', __doc__)
|
| 149 |
+
p.add_argument('--videos', help='Comma-separated video names')
|
| 150 |
+
p.add_argument('--splits', default='train,val')
|
| 151 |
+
args = p.parse_args(argv)
|
| 152 |
+
wanted = set(args.videos.split(',')) if args.videos else None
|
| 153 |
+
splits = set(args.splits.split(','))
|
| 154 |
+
if not splits <= {'train', 'val'}:
|
| 155 |
+
p.error('only annotated train/val splits are available')
|
| 156 |
+
out = release(args, 'EPIC-KITCHENS-VISOR')
|
| 157 |
+
archive = find_file(args.root, 'EPIC-KITCHENS VISOR.zip')
|
| 158 |
+
with tempfile.TemporaryDirectory(prefix='visor-source-') as wd:
|
| 159 |
+
work = Path(wd)
|
| 160 |
+
if archive:
|
| 161 |
+
with zipfile.ZipFile(archive) as z:
|
| 162 |
+
suffix = 'GroundTruth-SparseAnnotations/annotations/'
|
| 163 |
+
members = [n for n in z.namelist() if suffix in n and n.endswith('.json')]
|
| 164 |
+
prefix = members[0].split(suffix)[0]
|
| 165 |
+
fm = json.loads(z.read(prefix + 'frame_mapping.json'))
|
| 166 |
+
done = 0
|
| 167 |
+
for member in sorted(members):
|
| 168 |
+
split, filename = member.split(suffix)[1].split('/')
|
| 169 |
+
video = Path(filename).stem
|
| 170 |
+
if split not in splits or wanted and video not in wanted:
|
| 171 |
+
continue
|
| 172 |
+
data = z.read(member)
|
| 173 |
+
rgb_member = prefix + f'GroundTruth-SparseAnnotations/rgb_frames/{split}/{video.split("_")[0]}/{video}.zip'
|
| 174 |
+
rgb_zip = work / (video + '.zip')
|
| 175 |
+
with z.open(rgb_member) as inp, rgb_zip.open('wb') as dest:
|
| 176 |
+
shutil.copyfileobj(inp, dest)
|
| 177 |
+
with sequence_dir(out, video) as dest:
|
| 178 |
+
report = convert_video(video, split, json.loads(data), locator(archive, member, data),
|
| 179 |
+
rgb_zip, locator(archive, rgb_member), fm.get(video, {}), args, dest / 'ego')
|
| 180 |
+
build_record(out, video, {'ego': report})
|
| 181 |
+
rgb_zip.unlink()
|
| 182 |
+
done += 1
|
| 183 |
+
print(f'Converted {video}', flush=True)
|
| 184 |
+
if args.limit and done >= args.limit:
|
| 185 |
+
break
|
| 186 |
+
else:
|
| 187 |
+
root = next((r for r in roots(args.root) if (r / 'GroundTruth-SparseAnnotations').is_dir()), None)
|
| 188 |
+
if root is None:
|
| 189 |
+
p.error('VISOR outer ZIP or extracted source directory not found')
|
| 190 |
+
fm = json.loads((root / 'frame_mapping.json').read_text()) if (root / 'frame_mapping.json').exists() else {}
|
| 191 |
+
done = 0
|
| 192 |
+
for split in sorted(splits):
|
| 193 |
+
for ann in sorted((root / 'GroundTruth-SparseAnnotations/annotations' / split).glob('*.json')):
|
| 194 |
+
video = ann.stem
|
| 195 |
+
if wanted and video not in wanted:
|
| 196 |
+
continue
|
| 197 |
+
rgb = root / f'GroundTruth-SparseAnnotations/rgb_frames/{split}/{video.split("_")[0]}/{video}.zip'
|
| 198 |
+
with sequence_dir(out, video) as dest:
|
| 199 |
+
report = convert_video(video, split, json.loads(ann.read_text()), locator(ann), rgb,
|
| 200 |
+
locator(rgb), fm.get(video, {}), args, dest / 'ego')
|
| 201 |
+
build_record(out, video, {'ego': report})
|
| 202 |
+
done += 1
|
| 203 |
+
if args.limit and done >= args.limit:
|
| 204 |
+
return 0
|
| 205 |
+
if not done:
|
| 206 |
+
p.error('no matching annotated videos found')
|
| 207 |
+
return 0
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
if __name__ == '__main__':
|
| 211 |
+
raise SystemExit(main())
|
| 212 |
+
|
| 213 |
+
# TODO(v2.0): 旧距离猜侧和单层掩码生成仅注释保留;v1.0 不执行。
|
| 214 |
+
# if side is None and len(frame_hands) == 1:
|
| 215 |
+
# # 空间门槛:脱下放在远处的手套不并入(实测双峰 0..25px / ≥44px)
|
| 216 |
+
# hb = frame_hands[0][1]
|
| 217 |
+
# gb = _bbox_of(polys)
|
| 218 |
+
# if hb and gb and _bbox_dist(gb, hb) <= GLOVE60_MERGE_BBOX_DIST:
|
| 219 |
+
# side = frame_hands[0][0]
|
| 220 |
+
# stats["glove60_merged_into_sole_hand"] += 1
|
| 221 |
+
# if side is None:
|
| 222 |
+
# stats["dropped_glove60_unresolved"] += 1
|
| 223 |
+
# id_disp[mid] = ("dropped", "glove60")
|
| 224 |
+
# continue
|
| 225 |
+
# def rasterize_and_encode(vdir, frames, frame_draw, zip_path, n, stats):
|
| 226 |
+
# """流式读 zip 内 jpg + 光栅化多边形 → rgb.mkv / mask.mkv;返回 (w, h)。"""
|
| 227 |
+
# from PIL import Image, ImageDraw
|
| 228 |
+
#
|
| 229 |
+
# with zipfile.ZipFile(zip_path) as zf:
|
| 230 |
+
# member_of = {}
|
| 231 |
+
# for nm in zf.namelist():
|
| 232 |
+
# member_of[os.path.basename(nm)] = nm
|
| 233 |
+
# names = [im["name"] for im in frames]
|
| 234 |
+
# missing = [nm for nm in names if nm not in member_of]
|
| 235 |
+
# if missing:
|
| 236 |
+
# raise RuntimeError(f"{len(missing)} annotated frames missing in zip, "
|
| 237 |
+
# f"e.g. {missing[:3]}")
|
| 238 |
+
# stats["zip_extra_members"] = len(member_of) - len(names)
|
| 239 |
+
#
|
| 240 |
+
# # 首帧定分辨率(官方 1920×1080,实测每帧校验)
|
| 241 |
+
# img0 = Image.open(io.BytesIO(zf.read(member_of[names[0]]))).convert("RGB")
|
| 242 |
+
# w, h = img0.size
|
| 243 |
+
#
|
| 244 |
+
# bin_img = Image.new("L", (w, h), 0)
|
| 245 |
+
# bin_draw = ImageDraw.Draw(bin_img)
|
| 246 |
+
# canvas = np.zeros((h, w), np.uint16)
|
| 247 |
+
# with VideoPipe(vdir / "mask.mkv", w, h, FPS, "mask") as mw, \
|
| 248 |
+
# VideoPipe(vdir / "rgb.mkv", w, h, FPS, "rgb") as rw:
|
| 249 |
+
# for f in range(n):
|
| 250 |
+
# canvas[:] = 0
|
| 251 |
+
# for pid, polys in frame_draw[f]:
|
| 252 |
+
# bin_draw.rectangle((0, 0, w, h), fill=0)
|
| 253 |
+
# for poly in polys:
|
| 254 |
+
# bin_draw.polygon([(float(x), float(y)) for x, y in poly], fill=255)
|
| 255 |
+
# arr = np.asarray(bin_img)
|
| 256 |
+
# canvas[arr > 0] = pid # 后画覆盖先画:物体→手(modal)
|
| 257 |
+
# mw.write(canvas)
|
| 258 |
+
# img = img0 if f == 0 else Image.open(
|
| 259 |
+
# io.BytesIO(zf.read(member_of[names[f]]))).convert("RGB")
|
| 260 |
+
# if img.size != (w, h):
|
| 261 |
+
# raise RuntimeError(f"frame {names[f]}: size {img.size} != {(w, h)}")
|
| 262 |
+
# rw.write(np.asarray(img))
|
| 263 |
+
# n_mask, n_rgb = mw.n, rw.n
|
| 264 |
+
# if (n_rgb, n_mask) != (n, n):
|
| 265 |
+
# raise RuntimeError(f"wrote rgb={n_rgb} mask={n_mask} != {n}")
|
| 266 |
+
# got = (count_frames(vdir / "rgb.mkv"), count_frames(vdir / "mask.mkv"))
|
| 267 |
+
# if got != (n, n):
|
| 268 |
+
# raise RuntimeError(f"encoded rgb={got[0]} mask={got[1]} != {n} (decode verify)")
|
| 269 |
+
# return w, h
|
| 270 |
+
#
|
| 271 |
+
#
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/script/provenance/operations/h2o-benchmark-decode.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Benchmark full FFV1 decodes, PNG RGB decodes, and source depth PNG loading; preserve every byte."""
|
| 2 |
+
import hashlib
|
| 3 |
+
import json
|
| 4 |
+
import os
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
import statistics
|
| 7 |
+
import subprocess
|
| 8 |
+
import time
|
| 9 |
+
from concurrent.futures import ThreadPoolExecutor
|
| 10 |
+
import numpy as np
|
| 11 |
+
from PIL import Image
|
| 12 |
+
|
| 13 |
+
old = Path('/data/xuzhefeng/Datasets/uni-hoi-h2o-full-20260930-w4-c10')
|
| 14 |
+
bench = Path('/data/xuzhefeng/Datasets/uni-hoi-h2o-decode-bench-20260930')
|
| 15 |
+
bench.mkdir(exist_ok=True)
|
| 16 |
+
media = next((old / 'H2O/shared-v1.0/data').glob('subject4_h1_0*/cam0/observation/rgb.mkv')).parent
|
| 17 |
+
inputs = bench / 'inputs'
|
| 18 |
+
inputs.mkdir(exist_ok=True)
|
| 19 |
+
for name in ('rgb.mkv', 'depth.mkv', 'depth_valid.mkv'):
|
| 20 |
+
dest = inputs / name
|
| 21 |
+
if not dest.exists():
|
| 22 |
+
os.link(media / name, dest)
|
| 23 |
+
source = next((old / 'scratch').glob('h2o-source-*/subject4/h1/0/cam0/rgb')).parent
|
| 24 |
+
for kind in ('rgb', 'depth'):
|
| 25 |
+
dest = inputs / kind
|
| 26 |
+
dest.mkdir(exist_ok=True)
|
| 27 |
+
for frame in sorted((source / kind).glob('*.png'))[:100]:
|
| 28 |
+
if not (dest / frame.name).exists():
|
| 29 |
+
os.link(frame, dest / frame.name)
|
| 30 |
+
records = []
|
| 31 |
+
expected = {}
|
| 32 |
+
def record(stage, threads, digest, size, seconds):
|
| 33 |
+
assert expected.setdefault(stage, (digest, size)) == (digest, size), stage
|
| 34 |
+
row = dict(stage=stage, threads=threads, seconds=seconds, sha256=digest, bytes=size)
|
| 35 |
+
records.append(row)
|
| 36 |
+
print(json.dumps(row), flush=True)
|
| 37 |
+
(bench / 'report.json').write_text(json.dumps(records, indent=2) + '\n')
|
| 38 |
+
def decode(stage, arguments, threads, pix_fmt):
|
| 39 |
+
cmd = ['ffmpeg','-v','error','-nostdin','-filter_threads',str(threads),'-threads',str(threads),
|
| 40 |
+
'-noautorotate',*arguments,'-map','0:v:0','-vsync','0','-threads',str(threads),
|
| 41 |
+
'-f','rawvideo','-pix_fmt',pix_fmt,'pipe:1']
|
| 42 |
+
digest = hashlib.sha256()
|
| 43 |
+
size = 0
|
| 44 |
+
start = time.monotonic()
|
| 45 |
+
with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc:
|
| 46 |
+
while chunk := proc.stdout.read(1024*1024):
|
| 47 |
+
digest.update(chunk)
|
| 48 |
+
size += len(chunk)
|
| 49 |
+
stderr = proc.stderr.read()
|
| 50 |
+
assert proc.wait() == 0, stderr.decode()
|
| 51 |
+
record(stage, threads, digest.hexdigest(), size, time.monotonic()-start)
|
| 52 |
+
for threads in (1,10,10,1):
|
| 53 |
+
for name, pix in (('rgb','rgb24'),('depth','gray16le'),('depth_valid','gray')):
|
| 54 |
+
decode('ffv1_'+name, ['-i',str(inputs/(name+'.mkv'))], threads, pix)
|
| 55 |
+
decode('source_rgb_png_100', ['-framerate','30','-i',str(inputs/'rgb/%06d.png')], threads, 'rgb24')
|
| 56 |
+
files = sorted((inputs/'depth').glob('*.png'))
|
| 57 |
+
def read(path):
|
| 58 |
+
with Image.open(path) as im:
|
| 59 |
+
return np.asarray(im).astype(np.float32)/1000.0
|
| 60 |
+
for depth_threads in (1,2,4):
|
| 61 |
+
digest = hashlib.sha256()
|
| 62 |
+
start = time.monotonic()
|
| 63 |
+
size = 0
|
| 64 |
+
with ThreadPoolExecutor(max_workers=depth_threads) as pool:
|
| 65 |
+
# Bound decoded arrays to one small batch, as the production candidate would.
|
| 66 |
+
for begin in range(0,len(files),depth_threads):
|
| 67 |
+
for arr in pool.map(read,files[begin:begin+depth_threads]):
|
| 68 |
+
digest.update(arr.tobytes())
|
| 69 |
+
size += arr.nbytes
|
| 70 |
+
record('source_depth_png_100', depth_threads, digest.hexdigest(), size, time.monotonic()-start)
|
| 71 |
+
print('MEDIANS',flush=True)
|
| 72 |
+
for stage in expected:
|
| 73 |
+
for threads in sorted({r['threads'] for r in records if r['stage']==stage}):
|
| 74 |
+
print(stage,threads,statistics.median(r['seconds'] for r in records if r['stage']==stage and r['threads']==threads),flush=True)
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/script/provenance/operations/h2o-prepare-d10.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Reuse only atomically published sequences; preserve previous runtime provenance."""
|
| 2 |
+
import datetime
|
| 3 |
+
import json
|
| 4 |
+
import os
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
import shutil
|
| 7 |
+
|
| 8 |
+
old = Path('/data/xuzhefeng/Datasets/uni-hoi-h2o-full-20260930-w4-c10')
|
| 9 |
+
new = Path('/data/xuzhefeng/Datasets/uni-hoi-h2o-full-20260930-w4-c10-d10')
|
| 10 |
+
snapshot = Path('/tmp/h2o-w4-c10-d10-recovery')
|
| 11 |
+
new.mkdir()
|
| 12 |
+
shutil.copytree(snapshot, new / 'frozen-code')
|
| 13 |
+
release = new / 'H2O/shared-v1.0'
|
| 14 |
+
for directory in ('data', 'doc/validation', 'script/provenance/previous-run', 'script/provenance/operations'):
|
| 15 |
+
(release / directory).mkdir(parents=True, exist_ok=True)
|
| 16 |
+
history = release / 'script/provenance/previous-run'
|
| 17 |
+
shutil.copytree(old / 'H2O/shared-v1.0/script', history / 'script')
|
| 18 |
+
shutil.copytree(old / 'frozen-code/docs', history / 'docs')
|
| 19 |
+
for name in ('full.log', 'full.status', 'run-full.sh'):
|
| 20 |
+
shutil.copy2(old / name, history / name)
|
| 21 |
+
records = []
|
| 22 |
+
for record in sorted((old / 'H2O/shared-v1.0/doc').glob('*.build.json')):
|
| 23 |
+
build = json.loads(record.read_text())
|
| 24 |
+
seq = build['sequence_id']
|
| 25 |
+
assert Path(seq).name == seq and seq not in ('.', '..')
|
| 26 |
+
assert set(build['views']) == {f'cam{i}' for i in range(5)}, seq
|
| 27 |
+
data = old / 'H2O/shared-v1.0/data' / seq
|
| 28 |
+
frames = {}
|
| 29 |
+
for cam in build['views']:
|
| 30 |
+
json.loads((data / cam / 'metainfo.json').read_text())
|
| 31 |
+
frames[cam] = sum(1 for _ in (data / cam / 'camera/frames.jsonl').open())
|
| 32 |
+
assert frames[cam] > 0
|
| 33 |
+
shutil.copytree(data, release / 'data' / seq, copy_function=os.link)
|
| 34 |
+
shutil.copy2(record, release / 'doc' / record.name)
|
| 35 |
+
records.append({'sequence_id': seq, 'frames_by_camera': frames,
|
| 36 |
+
'original_script_sha256': build['scripts']})
|
| 37 |
+
manifest = {'time': datetime.datetime.now().astimezone().isoformat(),
|
| 38 |
+
'source_run': str(old), 'destination_run': str(new),
|
| 39 |
+
'configuration': {'workers': 4, 'codec_threads': 10, 'decode_threads': 10,
|
| 40 |
+
'depth_threads': 4, 'cpu_limit': None},
|
| 41 |
+
'reuse': 'Hard-linked immutable completed views; source timeline/SHA256 still rechecked without staging published source frames',
|
| 42 |
+
'excluded': 'Unpublished .tmp directories; historical 62-sequence output',
|
| 43 |
+
'original_runtime_provenance': 'script/provenance/previous-run', 'sequences': records}
|
| 44 |
+
(release / 'doc/RESTART_PROVENANCE.json').write_text(json.dumps(manifest, indent=2) + '\n')
|
| 45 |
+
operations = release / 'script/provenance/operations'
|
| 46 |
+
for name in ('h2o-prepare-d10.py', 'h2o-switch-d10.sh', 'h2o-benchmark-decode.py'):
|
| 47 |
+
shutil.copy2(Path('/tmp') / name, operations / name)
|
| 48 |
+
for src, dest in (('/tmp/h2o-run-d10.sh', new / 'run-full.sh'),
|
| 49 |
+
('/tmp/h2o-run-d10.sh', release / 'script/run-full.sh'),
|
| 50 |
+
('/tmp/h2o-decode-bench.log', release / 'doc/validation/DECODE_THREAD_BENCHMARK.log'),
|
| 51 |
+
('/data/xuzhefeng/Datasets/uni-hoi-h2o-decode-bench-20260930/report.json', release / 'doc/validation/DECODE_THREAD_BENCHMARK.json'),
|
| 52 |
+
('/tmp/h2o-d10-final-tests.log', operations / 'worker4-encode10-decode10-depth4-regression.log'),
|
| 53 |
+
('/tmp/h2o-io-sample.log', release / 'doc/validation/IO_SAMPLE.log')):
|
| 54 |
+
shutil.copy2(src, dest)
|
| 55 |
+
print(f'REUSED_SEQUENCES={len(records)} REUSED_VIEWS={sum(len(r["frames_by_camera"]) for r in records)}', flush=True)
|
H2O/shared-v1.1/script/v1_0_snapshot/script/provenance/previous-run/script/provenance/operations/h2o-switch-d10.sh
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -euo pipefail
|
| 3 |
+
cd /home/xuzhefeng/Projects/uni-hoi-dataset
|
| 4 |
+
test "$(cat /tmp/h2o-d10-final-tests.exit)" = 0
|
| 5 |
+
test "$(cat /tmp/h2o-decode-bench.exit)" = 0
|
| 6 |
+
test ! -e /data/xuzhefeng/Datasets/uni-hoi-h2o-full-20260930-w4-c10-d10
|
| 7 |
+
old=/data/xuzhefeng/Datasets/uni-hoi-h2o-full-20260930-w4-c10
|
| 8 |
+
# Let the already nearly complete fifth camera publish, instead of discarding four completed cameras.
|
| 9 |
+
while test ! -s "$old/H2O/shared-v1.0/doc/subject4_h1_0.build.json"; do
|
| 10 |
+
test "$(systemctl --user show --no-pager h2o-full-w4c10-r2-20260930.scope -p ActiveState --value)" = active
|
| 11 |
+
sleep 20
|
| 12 |
+
done
|
| 13 |
+
printf '\nRECONFIGURE=%s REASON=decoder10_depth4_no_resume_png_writes\n' "$(date -Is)" >> "$old/full.status"
|
| 14 |
+
systemctl --user stop h2o-full-w4c10-r2-20260930.scope
|
| 15 |
+
.venv/bin/python /tmp/h2o-prepare-d10.py
|
| 16 |
+
systemd-run --user --scope --unit=h2o-full-d10-20260930 -p CPUAccounting=yes /bin/bash /data/xuzhefeng/Datasets/uni-hoi-h2o-full-20260930-w4-c10-d10/run-full.sh
|