Skip to content

hylo.codeagents.replay_tools

Package: hylo-code-agents · Core contracts

replay_tools

The perception and rendering tools the replay workflow calls, behind one small interface.

RealTools runs the hylo-tools workers (each in its own uv environment, on the CPU): segment (SAM 3), depth (MoGe-2, a persistent worker for whole videos), gravity (GeoCalib), mesh (SAM 3D Objects when access is granted, else depth carving), convex (CoACD + MJCF), hands (WiLoR, else MediaPipe) and render (Blender Cycles or MuJoCo offscreen). StubTools gives the same interface without workers (tests, and runs that must not start models): masks from a callback or the recording's segmentation, the recording's own depth, convex hulls for meshes.

RealTools

RealTools(threads: int | None = None, log: Callable[[str], None] | None = None, render_backend: str = 'mujoco')

name class-attribute instance-attribute

name = 'hylo-tools'

render_backend instance-attribute

render_backend = render_backend

calls instance-attribute

calls: list[dict[str, Any]] = []

mesh_backend instance-attribute

mesh_backend = 'auto'

segment

segment(rgb: ndarray, labels: Sequence[str], threshold: float = 0.5) -> list[tuple[str, np.ndarray, float]]

depth

depth(frames: ndarray, log_every: int = 20) -> dict[str, Any]

Metric depth for every frame (one persistent MoGe-2 worker; the field of view of frame 0 is reused).

gravity

gravity(rgb: ndarray) -> dict[str, Any]

mesh

mesh(rgb: ndarray, mask: ndarray, depth: ndarray, K: ndarray, T_world_cam: ndarray, name: str, out_dir: Path) -> dict[str, Any]

convex

convex(mesh_obj: str | Path, name: str, mass: float) -> dict[str, Any]

hands

hands(frames: ndarray, K: ndarray | None) -> dict[str, Any]

render

render(scene: str | Path, qpos: ndarray, times: ndarray, *, camera: str, width: int, height: int, fps: float) -> dict[str, Any]

close

close() -> None

StubTools

StubTools(segmenter: Callable[[ndarray, Sequence[str]], list[tuple[str, ndarray, float]]] | None = None, depth_fn: Callable[[ndarray], dict[str, Any]] | None = None, render_fn: Callable[..., dict[str, Any]] | None = None, table_z: float = 0.0)

No workers: deterministic stand-ins with the same interface (tests; dry runs).

name class-attribute instance-attribute

name = 'stub'

table_z instance-attribute

table_z = table_z

calls instance-attribute

calls: list[dict[str, Any]] = []

segment

segment(rgb: ndarray, labels: Sequence[str], threshold: float = 0.5) -> list[tuple[str, np.ndarray, float]]

depth

depth(frames: ndarray, log_every: int = 20) -> dict[str, Any]

gravity

gravity(rgb: ndarray) -> dict[str, Any]

mesh

mesh(rgb: ndarray, mask: ndarray, depth: ndarray, K: ndarray, T_world_cam: ndarray, name: str, out_dir: Path) -> dict[str, Any]

convex

convex(mesh_obj: str | Path, name: str, mass: float) -> dict[str, Any]

hands

hands(frames: ndarray, K: ndarray | None) -> dict[str, Any]

render

render(scene: str | Path, qpos: ndarray, times: ndarray, **kw: Any) -> dict[str, Any]

close

close() -> None

gt_segmenter

gt_segmenter(seg0: ndarray, segments: dict[str, str]) -> Callable[[np.ndarray, Sequence[str]], list]

A segmenter from a ground-truth instance image: each label gets the instance whose name contains its words.