Download tests/test_render.py from hkblockchaintechnology/VLM-all-inclusive: direct link, hf CLI and curl.
- Browser
- Download file 1.12 kB
-
https://huggingface.co/hkblockchaintechnology/VLM-all-inclusive/resolve/main/tests/test_render.py
- Command line
-
hf download hf://hkblockchaintechnology/VLM-all-inclusive/tests/test_render.py
-
curl -L -o test_render.py https://huggingface.co/hkblockchaintechnology/VLM-all-inclusive/resolve/main/tests/test_render.py
1.12 kB
| """The GPU rasteriser must agree with the reference numpy renderer, otherwise the | |
| model would be trained on a different world than the one the notebook shows.""" | |
| import numpy as np | |
| import pytest | |
| import omni.scenes as scenes | |
| from conftest import CUDA | |
| def test_gpu_rasteriser_matches_numpy_reference(device): | |
| import omni.render as render | |
| spec = scenes.spec_batch(list(range(8)), seed=1, px=64) | |
| gpu = render.render_specs(spec, px=64, device=device, ss=2).permute(0, 2, 3, 1).cpu().numpy() | |
| for i in range(8): | |
| ref = scenes.render_scene(spec["scenes"][i], px=64, ss=2).astype(np.float32) / 255.0 | |
| assert np.abs(ref - gpu[i]).mean() < 0.02, f"scene {i} diverges from the reference" | |
| def test_render_is_differentiable_and_finite(device): | |
| import torch | |
| import omni.render as render | |
| spec = scenes.spec_batch(list(range(4)), seed=2, px=32) | |
| for k in ("cx", "cy", "r"): | |
| spec[k] = spec[k].astype(np.float32) | |
| imgs = render.render_specs(spec, px=32, device=device, ss=1) | |
| assert torch.isfinite(imgs).all() | |
| assert imgs.min() >= 0 and imgs.max() <= 1 | |