Download benchmark_pipeline.py from junaid-simamdigital/Simam3DZeroGPU: direct link, hf CLI and curl.
- Browser
- Download file 2.44 kB
-
https://huggingface.co/spaces/junaid-simamdigital/Simam3DZeroGPU/resolve/main/benchmark_pipeline.py
- Command line
-
hf download hf://spaces/junaid-simamdigital/Simam3DZeroGPU/benchmark_pipeline.py
-
curl -L -o benchmark_pipeline.py https://huggingface.co/spaces/junaid-simamdigital/Simam3DZeroGPU/resolve/main/benchmark_pipeline.py
2.44 kB
| """Measure deterministic Simam3D fusion stability on small CPU fixtures. | |
| This is a regression harness, not a reconstruction-quality benchmark: it uses | |
| synthetic views so it can run without model weights, CUDA, or network access. | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| import hashlib | |
| import json | |
| from pathlib import Path | |
| import numpy as np | |
| from demo_pipeline import build_demo_views | |
| from simam3d_core import fuse_point_views, fusion_metrics | |
| def _result_signature(result) -> str: | |
| digest = hashlib.sha256() | |
| for array in (result.points, result.colors, result.weights, result.source_views, result.source_masks): | |
| digest.update(np.ascontiguousarray(array).tobytes()) | |
| return digest.hexdigest() | |
| def run_benchmark(output_dir: str | Path, sizes=(32, 48, 64), repeats: int = 2) -> dict: | |
| """Run repeatability checks and write one machine-readable report.""" | |
| if repeats < 2: | |
| raise ValueError("repeats must be at least 2 to measure repeatability") | |
| rows = [] | |
| for size in sizes: | |
| results = [ | |
| fuse_point_views(build_demo_views(size), voxel_size=0.03, max_points=20_000) | |
| for _ in range(repeats) | |
| ] | |
| signatures = [_result_signature(result) for result in results] | |
| metrics = fusion_metrics(results[0]) | |
| rows.append({ | |
| "size": int(size), | |
| "repeat_count": int(repeats), | |
| "deterministic": len(set(signatures)) == 1, | |
| "signature": signatures[0], | |
| "metrics": metrics, | |
| }) | |
| report = { | |
| "project": "Simam3D", | |
| "mode": "deterministic_cpu_regression", | |
| "scope": "synthetic fusion/export fixture; not a learned reconstruction benchmark", | |
| "all_deterministic": all(row["deterministic"] for row in rows), | |
| "rows": rows, | |
| } | |
| output_dir = Path(output_dir) | |
| output_dir.mkdir(parents=True, exist_ok=True) | |
| path = output_dir / "simam3d_deterministic_benchmark.json" | |
| path.write_text(json.dumps(report, indent=2), encoding="utf-8") | |
| report["report"] = str(path) | |
| return report | |
| def main(argv: list[str] | None = None) -> int: | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("--output", type=Path, default=Path("benchmark_output")) | |
| args = parser.parse_args(argv) | |
| print(json.dumps(run_benchmark(args.output), indent=2)) | |
| return 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |