scene_service.scene_graph.relations

Edge candidate generation and LLM-based relation inference.

Functions

compute_geometry_hint(a, b)

generate_edge_candidates(nodes, *[, ...])

Return candidate pairs with precomputed geometry hints.

Classes

RelationInferer(llm_client)

Infer the spatial relation between two objects via LLM.

class scene_service.scene_graph.relations.RelationInferer(llm_client: SceneGraphLLMClient)[source]

Bases: object

Infer the spatial relation between two objects via LLM.

async infer_relation(source: SceneGraphNode, target: SceneGraphNode, hint: GeometryHint) SceneGraphEdge[source]

Call LLM to infer the relation from source to target.

Returns a SceneGraphEdge. On LLM failure the edge has relation="unknown" and method="llm_fail".

scene_service.scene_graph.relations.compute_geometry_hint(a: SceneGraphNode, b: SceneGraphNode) GeometryHint[source]
scene_service.scene_graph.relations.generate_edge_candidates(nodes: list[SceneGraphNode], *, max_distance: float = 2.0, min_xy_overlap: float = 0.15, max_candidates: int = 200) list[tuple[SceneGraphNode, SceneGraphNode, GeometryHint]][source]

Return candidate pairs with precomputed geometry hints.

A pair is a candidate if any of these hold:
  • center distance < max_distance

  • XY overlap ratio > min_xy_overlap

  • one bbox contains the other