Abstract
Recent progress in text-to-image generation has greatly advanced visual fidelity and creativity, but it has also imposed higher demands on prompt complexity—particularly in encoding intricate spatial relationships. In such cases, achieving satisfactory results often requires multiple sampling attempts. To address this challenge, we introduce a novel method that strengthens the spatial understanding of current image generation models. We first construct the SpatialReward-Dataset with over 80k preference pairs. Building on this dataset, we build SpatialScore, a reward model designed to evaluate the accuracy of spatial relationships in text-to-image generation, achieving performance that even surpasses leading proprietary models on spatial evaluation. We further demonstrate that this reward model effectively enables online reinforcement learning for the complex spatial generation. Extensive experiments across multiple benchmarks show that our specialized reward model yields significant and consistent gains in spatial understanding for image generation.
Introduction
While modern text-to-image (T2I) models excel at generating high-fidelity textures and artistic styles, they frequently struggle with precise spatial reasoning. Prompts requiring specific object positioning—such as "a coffee cup to the right of the laptop, aligned with its front edge"—often result in layouts that ignore or misinterpret these geometric constraints.
This "spatial illiteracy" stems from two primary issues. First, existing reward models used in training prioritize aesthetic appeal or general "vibe" over geometric accuracy. Second, there is a significant evaluation gap; rule-based systems often fail in complex or occluded scenes, while proprietary Visual Language Models (VLMs) are computationally prohibitive for the high-frequency feedback loops required in reinforcement learning (RL).
Methodology
To address these limitations, we propose a three-pillar framework designed to enhance spatial understanding:
1. The SpatialScore Reward Model
We developed SpatialScore, a reward model based on the Qwen2.5-VL-7B architecture. Unlike traditional models that output a single scalar value, SpatialScore represents rewards as a Gaussian distribution (mean and standard deviation). This probabilistic approach enables more robust ranking and stable training signals.
2. Online Reinforcement Learning with Flow-GRPO
We fine-tuned the Flux.1-dev generative model using a variant of Group Relative Policy Optimization (GRPO). This method evaluates groups of images generated from identical prompts, rewarding those that best adhere to spatial instructions.
3. Top-k Filtering Strategy
A critical technical innovation is the Top-k Filtering strategy. Standard RL can suffer from "advantage bias" when prompts are too simple, leading to noisy gradients. By calculating advantages based only on the top and bottom $k$ samples in a group, we stabilize the optimization process and accelerate convergence.
Data Construction
Central to our approach is the SpatialReward-Dataset, comprising 80,000 adversarial preference pairs. We utilized GPT-5 to generate complex spatial prompts and created "perturbed" versions (e.g., swapping "left" for "right"). Images were generated using state-of-the-art models and underwent rigorous human verification to ensure the ground truth accurately reflected the spatial intent.
Results and Key Insights
Our experiments demonstrate that specialized spatial training can outperform general-purpose models. SpatialScore achieved a pairwise accuracy of 95.8%, surpassing both GPT-5 (89.0%) and Gemini 2.5 Pro (95.1%) on spatial evaluation tasks.
Key findings include:
- Benchmark Performance: On the DPG-Bench (Relation-Spatial dimension), our RL-tuned model improved scores from 0.871 to 0.932.
- In-Domain Improvement: On the SpatialScore evaluation suite, the base Flux model's score increased from 2.18 to 7.81 following RL training.
- Qualitative Gains: Visual analysis confirms that the fine-tuned model successfully places objects in exact configurations where the base model often fails or swaps positions.
Conclusion and Future Work
This work demonstrates that spatial reasoning is a distinct skill that can be significantly improved through targeted reward modeling and reinforcement learning. While currently focused on static images, future research will explore temporal spatial understanding for video generation. These advancements are a prerequisite for the development of embodied AI, where accurate spatial generation is essential for understanding and interacting with physical environments.
Summary updated