Download scripts/run_scene.py from Jinxin-Ai/GraftRay: direct link, hf CLI and curl.
- Browser
- Download file 3.25 kB
-
https://huggingface.co/datasets/Jinxin-Ai/GraftRay/resolve/main/scripts/run_scene.py
- Command line
-
hf download hf://datasets/Jinxin-Ai/GraftRay/scripts/run_scene.py
-
curl -L -o run_scene.py https://huggingface.co/datasets/Jinxin-Ai/GraftRay/resolve/main/scripts/run_scene.py
3.25 kB
| #!/usr/bin/env python | |
| """Re-render one benchmark scene with the GraftRay code release (github.com/ASH30KW/GraftRay). | |
| python scripts/run_scene.py FIPT_01_bathroom_mx rgbx --graftray /path/to/GraftRay --out /path/to/out | |
| Runs, from the dataset root (object paths in objects.json are relative to it): | |
| 1. scripts/render_video.py without objects (linear HDR stills at the evaluation views of views.json) | |
| 2. scripts/render_video.py with objects | |
| 3. scripts/composite.py differential composite over the 3DGS render | |
| --dry-run prints the three commands instead. --spp overrides the paper setting stored in scene.json. | |
| """ | |
| import argparse, json, shlex, subprocess, sys | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| def main(): | |
| ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) | |
| ap.add_argument('scene'); ap.add_argument('variant', choices=['rgbx', 'dr']) | |
| ap.add_argument('--graftray', required=True, help='checkout of the GraftRay code') | |
| ap.add_argument('--out', default=None); ap.add_argument('--spp', type=int, default=None) | |
| ap.add_argument('--backend', default='optix'); ap.add_argument('--passes', nargs='+', default=['without', 'with', 'comp']) | |
| ap.add_argument('--dry-run', action='store_true') | |
| a = ap.parse_args() | |
| sc = json.load(open(ROOT / 'scenes' / a.scene / 'scene.json')) | |
| v = sc['variants'][a.variant] | |
| vj = json.load(open(ROOT / sc['views'])) | |
| out = Path(a.out or ROOT / 'outputs' / a.scene / f'ours_{a.variant}').resolve() | |
| flat = lambda rows: [str(x) for r in rows for x in r] | |
| cam = ['--camera-waypoints', *flat(vj['eyes']), '--camera-lookat', *flat(vj['looks'])] | |
| size = ['--render-size', *map(str, sc['render_size']), '--fov-deg', str(sc['fov_deg'])] | |
| common = ['--ply', sc['ply'], '--dataset', sc['dataset'], '--materials-dir', v['materials'], '--normals-pt', v['normals'], | |
| '--light', v['light'], '--emitter-pt', v['emitter'], '--clear-emitter-slab', str(sc['clear_emitter_slab']), | |
| '--albedo-scale', str(v['albedo_scale']), *cam, '--camera-stills', *size, '--backend', a.backend, | |
| '--spp', str(a.spp or sc['spp']), '--save-hdr', '--object-perpixel', *sc['tracer_args']] | |
| g = Path(a.graftray).resolve() | |
| cmds = { | |
| 'without': [sys.executable, str(g / 'scripts/render_video.py'), *common, '--out', str(out / 'without')], | |
| 'with': [sys.executable, str(g / 'scripts/render_video.py'), *common, '--glb-json', sc['objects'], '--out', str(out / 'with')], | |
| 'comp': [sys.executable, str(g / 'scripts/composite.py'), '--ply', sc['ply'], '--materials-dir', v['materials'], | |
| '--hdr-with', str(out / 'with'), '--hdr-without', str(out / 'without'), '--glb-json', sc['objects'], *cam, | |
| '--world-up', *map(str, sc['composite_world_up']), *size, '--frame', '0', '--frame-end', str(len(vj['eyes'])), | |
| '--frame-step', '1', '--out', str(out / 'comp')], | |
| } | |
| for p in a.passes: | |
| print('+ (cd %s) %s' % (ROOT, ' '.join(shlex.quote(c) for c in cmds[p])), flush=True) | |
| if not a.dry_run: | |
| subprocess.run(cmds[p], cwd=ROOT, check=True) | |
| if __name__ == '__main__': | |
| main() | |