SpatialGuard: Harness-Guided Verifiable Spatial Reasoning for Text-to-Image Generation

Ziyun Qian, Zizhi Chen, Yizhou Liu, Mingyang Sun, Dingkang Yang, Lihua ZhangarXiv 2026

TL;DR

SpatialGuard is a training-free, agentic framework that brings structural verification to text-to-image generation by treating 3D layouts as an editable, persistent state. By introducing a "Layout Harness," the system iteratively plans, synthesizes, validates, and repairs complex multi-object scenes, preventing the spatial "forgetting" and constraint decay common in traditional diffusion models.

What Problem Does This Paper Address?

While modern text-to-image (T2I) models excel at generating visually stunning and semantically rich images, they notoriously struggle with complex 3D spatial reasoning. Prompts specifying precise arrangements—such as "a cat front-left of the sofa, a dog front-right, and a lamp to the left"—often result in missing objects, incorrect positioning, or physically impossible overlaps.

Existing layout-conditioned or multi-agent methods attempt to solve this by generating a layout first, but they treat it as a static, one-shot input. When a scene requires multiple rounds of generation, evaluation, and correction, large models suffer from constraint decay—fixing one object often causes the model to forget or distort spatial constraints established in earlier steps. The field lacks an optimizable, verifiable spatial intermediary that remains stable across iterative generation loops.

Methods

SpatialGuard addresses this by transforming text-to-image generation from an implicit prompt-following task into a verifiable, closed-loop engineering process.

Overview of the SpatialGuard framework, illustrating the iterative loop between the Spatial Layout Architect, Visual Realizer, Visual Alignment Critic, and the Layout Harness.

The framework consists of three collaborative modules operating around a shared, editable layout state managed by a Layout Harness:

  1. Spatial Layout Architect: Uses a Large Language Model (GPT-5) to parse the input text into an explicit 3D structured layout containing object categories, 3D positions, sizes, orientations (azimuth), and camera parameters.
  2. Visual Realizer: Renders this 3D layout into 2D instance masks and token-aligned conditions, passing them to a base image generator (FLUX.1-dev) to synthesize a candidate image.
  3. Visual Alignment Critic: A Vision-Language Model (VLM) evaluates the candidate image against the original text constraints. Crucially, instead of returning a vague scalar score, it localizes failures to specific fields (e.g., pointing out a specific object's incorrect depth or occlusion status).

The core novelty is the Layout Harness, which stabilizes the multi-round interaction using four mechanisms:

  • Rule Constraints: Translates linguistic spatial relations into checkable geometric boundaries.
  • Tool Invocation: Executes discrete layout adjustments (e.g., Object Move Tool, Scale Down, Adjust Camera Elevation) based on the critic's feedback.
  • Shared Knowledge: Acts as a persistent memory buffer tracking layout versions, validation records, and repair trajectories across rounds.
  • Feedback Loops: Re-injects localized errors back into the Architect for targeted layout modifications, ensuring previously validated constraints aren't broken during repairs.

Datasets

The authors evaluated SpatialGuard using a fixed, comprehensive prompt set specifically designed to test complex 3D spatial relationships. The prompts evaluate seven distinct dimensions: object presence, directional position, atomic/compound relations, depth ordering (occlusion), relative scale, physical support, and camera framing.

To ensure an unbiased evaluation, the authors implemented a blind protocol using three state-of-the-art VLMs as independent judges: Gemini 2.5 Pro, Qwen3-VL, and Grok 4.

Key Insights and Ideas

  • Layout as Code/State: Treating a spatial layout as an editable, stateful data structure—rather than a static conditioning image—allows the system to perform deterministic debugging and targeted repairs, much like a software compiler.
  • Mitigating Context Drift via the Harness: Large models naturally suffer from memory decay in long-chain conversations. Externalizing the state and memory into a structured agent harness prevents the model from drifting away from the original prompt's constraints during multi-round edits.
  • Localized Criticism: Global image rewards are too noisy for fine-grained editing. Breaking down criticism into structured, object-level validation records allows the system to invoke precise, localized tools without disrupting the rest of the scene.

Key Results

In quantitative evaluations judged across the three VLMs, SpatialGuard achieved state-of-the-art performance, outperforming strong baselines like HunyuanImage-2.1, SD-3.5-Large, and vanilla FLUX.1-dev.

  • Overall Score: SpatialGuard achieved an overall spatial faithfulness score of 9.37 out of 10, creating a massive 1.47-point gap over the strongest baseline (HunyuanImage-2.1 at 7.90).
  • Dimension Gains: The framework showed its most significant improvements in complex geometric dimensions: Depth (+2.18), Support (+1.81), Scale (+1.48), and Relation (+1.42).
  • Ablation Studies: Removing the Layout Harness caused a noticeable drop in performance (falling to 9.01), confirming that cross-round constraint enforcement is vital for maintaining scene composition during edits.
Qualitative examples demonstrating SpatialGuard's ability to preserve multi-object spatial relations and directional constraints across diverse scenes.

Limitations and Future Work

  • Scope of Prompts: SpatialGuard relies on explicit, spatially grounded descriptions. It struggles with highly abstract artistic intent or intentionally ambiguous phrasing that cannot be easily mapped to bounding boxes and 3D coordinates.
  • Inference Cost: Because the framework runs an iterative loop of planning, rendering, VLM validation, and repair (up to 4 rounds), its computational overhead and latency are significantly higher than a single-pass text-to-image model call.
  • Generator Dependency: While SpatialGuard controls the layout geometry, the final visual quality, texture, and photorealism remain strictly bounded by the capabilities of the underlying image generator (FLUX.1-dev).

The authors suggest that future work will focus on expanding the tool library to handle finer physical interactions (like soft-body contact or complex lighting) and developing lighter validation strategies to reduce inference latency.

Summary updated

BibTeX
@misc{qian2026spatialguard,
  author = {Ziyun Qian and Zizhi Chen and Yizhou Liu and Mingyang Sun and Dingkang Yang and Lihua Zhang},
  title = {{SpatialGuard: Harness-Guided Verifiable Spatial Reasoning for Text-to-Image Generation}},
  year = {2026},
  eprint = {2609.01582},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2609.01582},
}
Figure