Download src/image3d_student/demo.py from Lucasgitguy-co/forma3d-tiny: direct link, hf CLI and curl.
- Browser
- Download file 1.41 kB
-
https://huggingface.co/Lucasgitguy-co/forma3d-tiny/resolve/main/src/image3d_student/demo.py
- Command line
-
hf download hf://Lucasgitguy-co/forma3d-tiny/src/image3d_student/demo.py
-
curl -L -o demo.py https://huggingface.co/Lucasgitguy-co/forma3d-tiny/resolve/main/src/image3d_student/demo.py
1.41 kB
| # SPDX-License-Identifier: Apache-2.0 | |
| # Copyright 2026 Lucasgitguy-co | |
| from pathlib import Path | |
| import numpy as np | |
| from .data import cache_sample | |
| from .splats import Splats, preview | |
| def create_demo(root, count=12, grid=8): | |
| """Procedural ellipsoids only. Never presented as outputs of any real teacher.""" | |
| if count < 4: | |
| raise ValueError("Use at least four fixtures") | |
| root = Path(root) | |
| root.mkdir(parents=True, exist_ok=True) | |
| rng = np.random.default_rng(17) | |
| phi, theta = np.meshgrid(np.linspace(.06, np.pi-.06, 14), np.linspace(0, 2*np.pi, 28, endpoint=False)) | |
| unit = np.stack([np.sin(phi)*np.cos(theta), np.cos(phi), np.sin(phi)*np.sin(theta)], axis=-1).reshape(-1, 3) | |
| for i in range(count): | |
| radii = rng.uniform(.17, .36, 3) | |
| xyz = (unit * radii).astype(np.float32) | |
| colour = rng.uniform(.2, .95, 3) | |
| rgb = np.clip(colour[None] * (.8 + .2 * unit[:, 1:2]), 0, 1) | |
| splats = Splats(xyz, rgb, np.full_like(xyz, .035), np.tile([1,0,0,0], (len(xyz),1)), np.full((len(xyz),1), .9)) | |
| image_path = root / f"fixture-{i:03}.png" | |
| preview(splats, size=128).save(image_path) | |
| cache_sample(root, f"fixture-{i:03}", image_path, splats, grid, source="synthetic", | |
| extra={"purpose": "code verification only", "object_id": f"fixture-{i:03}"}) | |
| image_path.unlink() | |
| return root / "manifest.jsonl" | |