File size: 1,890 Bytes
4ca47cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/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())