Datasets:
Download code/evaluation-code/v0.2-0c2690ae/embodied_pipeline/rendering/check.py from VEHwang/cocogni4d: direct link, hf CLI and curl.
- Browser
- Download file 1.84 kB
-
https://huggingface.co/datasets/VEHwang/cocogni4d/resolve/main/code/evaluation-code/v0.2-0c2690ae/embodied_pipeline/rendering/check.py
- Command line
-
hf download hf://datasets/VEHwang/cocogni4d/code/evaluation-code/v0.2-0c2690ae/embodied_pipeline/rendering/check.py
-
curl -L -o check.py https://huggingface.co/datasets/VEHwang/cocogni4d/resolve/main/code/evaluation-code/v0.2-0c2690ae/embodied_pipeline/rendering/check.py
1.84 kB
| """Render-contract self-check: load a written segment with the renderer's own validators (no second set of rules). | |
| python -m embodied_pipeline.rendering.check OUT_DIR (every gen-* segment; exit 1 if any fails or none are found) | |
| """ | |
| import json | |
| import sys | |
| from pathlib import Path | |
| from ..gen import appearance | |
| from . import validate_release_spec | |
| def contract(seg): | |
| from ..domain.contracts import CameraMount, RenderInputs, RenderSpec, validate_spec | |
| seg = Path(seg); script = json.loads((seg/'script.json').read_text()) | |
| inputs = RenderInputs.load(seg, Path(script['generator']['house'])/'capability.json') | |
| data = json.loads((seg/'spec.json').read_text()) | |
| data['mounts'] = {k: CameraMount(**v) for k, v in data['mounts'].items()} | |
| spec = RenderSpec(**data); validate_release_spec(spec); validate_spec(inputs, spec) | |
| bind = json.loads((seg/'assets.json').read_text()) | |
| need = {a['id'] for a in inputs.script['actors'] if a['kind'] != 'observer_virtual'} # render_scene's rule | |
| if set(bind) != need: raise ValueError('assets.json bodies differ from rendered bodies') | |
| appearance.audit(inputs.script['actors'], bind) # Textured, distinct looks, at most eight humanoids. | |
| for b in bind.values(): | |
| for key in ('bundle_dir', 'urdf'): | |
| if key in b and not Path(b[key]).exists(): raise FileNotFoundError(b[key]) | |
| return len(inputs.curves.t), len(need) | |
| def main(): | |
| segments = sorted(Path(sys.argv[1]).glob('gen-*')) | |
| bad = processed = 0 | |
| for seg in segments: | |
| try: print('OK ', seg.name, *contract(seg)) | |
| except Exception as e: bad += 1; print('FAIL', seg.name, repr(e)) | |
| processed += 1 | |
| print(f'checked {processed}/{len(segments)} segments; failed {bad}') | |
| sys.exit(1 if not segments or bad else 0) | |
| if __name__ == '__main__': main() | |