Download planner_example.py from SicoreAI/halo-planner-v9: direct link, hf CLI and curl.
- Browser
- Download file 1.89 kB
-
https://huggingface.co/SicoreAI/halo-planner-v9/resolve/main/planner_example.py
- Command line
-
hf download hf://SicoreAI/halo-planner-v9/planner_example.py
-
curl -L -o planner_example.py https://huggingface.co/SicoreAI/halo-planner-v9/resolve/main/planner_example.py
1.89 kB
| #!/usr/bin/env python3 | |
| """Minimal HALO-v9 planner call (onnxruntime + numpy). | |
| pip install onnxruntime numpy | |
| python planner_example.py --model halo_gen_ema.onnx | |
| This validates the interface and shapes. Real plan quality needs the frozen | |
| Qwen3.5-2B tokens (text tokens + 64 egocentric-scene image tokens per frame); | |
| with zero tokens the output is not a meaningful plan. | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| import numpy as np | |
| import onnxruntime as ort | |
| def main() -> int: | |
| p = argparse.ArgumentParser() | |
| p.add_argument("--model", default="halo_gen_ema.onnx") | |
| p.add_argument("--tokens", type=int, default=80, help="text + 64 image tokens") | |
| p.add_argument("--steps", type=int, default=60, help="plan horizon") | |
| args = p.parse_args() | |
| sess = ort.InferenceSession(args.model, providers=["CPUExecutionProvider"]) | |
| names = [i.name for i in sess.get_inputs()] | |
| print("inputs ", [(i.name, i.shape) for i in sess.get_inputs()]) | |
| print("outputs", [(o.name, o.shape) for o in sess.get_outputs()]) | |
| rng = np.random.default_rng(0) | |
| T, H = args.tokens, args.steps | |
| feeds = { | |
| "goal": np.zeros((1, 16), np.float32), | |
| "proprio": np.zeros((1, 8), np.float32), | |
| "prefix_vals": np.zeros((1, H, 8), np.float32), | |
| "prefix_mask": np.zeros((1, H), np.float32), | |
| "noise": rng.normal(0, 1, (1, H, 8)).astype(np.float32), | |
| "tokens": np.zeros((1, T, 2048), np.float32), | |
| "tok_mask": np.ones((1, T), np.float32), | |
| } | |
| if "image" in names: # unused on the token path | |
| feeds["image"] = np.zeros((1, 1, 120, 160), np.float32) | |
| plan = sess.run(None, {k: feeds[k] for k in names})[0] | |
| print("plan", plan.shape, "range", float(plan.min()), float(plan.max())) | |
| print("PLANNER_EXAMPLE_OK", plan.shape == (1, H, 8)) | |
| return 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |