A Practical Investigation of Spatially-Controlled Image Generation with Transformers

Guoxuan Xia, Harleen Hanspal, Petru-Daniel Tudosiu, Shifeng Zhang, Sarah Parisot · DOI

Introduction

The rapid evolution of generative AI has seen a decisive shift from U-Net-based diffusion models to more scalable Transformer architectures. However, while text-to-image synthesis has reached remarkable heights, providing precise spatial control—such as following a specific edge map or depth profile—remains a fragmented area of research. Current methods often conflate architectural changes, dataset variations, and training heuristics, making it difficult to identify the true drivers of performance.

This paper presents a systematic, "back-to-basics" investigation into spatially-controlled image generation within Transformer frameworks. By isolating specific variables, the authors evaluate how simple architectural baselines and inference-time optimizations can match or exceed the performance of complex, specialized models.

Methodological Framework

The study focuses on two primary Transformer paradigms: Scalable Interpolant Transformers (SiT), representing the continuous-time diffusion and flow-matching family, and Visual Autoregressive (VAR) models, which generate images in a multi-scale, coarse-to-fine manner.

Control Token Prefilling

A central contribution of this work is the establishment of a "prefilling" baseline. Rather than designing intricate adapter networks, the authors convert the spatial control map (e.g., an edge map) into tokens and feed them into the Transformer as a prefix. The subsequent image tokens then attend to these control tokens via the standard self-attention mechanism. This approach treats spatial control as a conditioning problem similar to prompt engineering in language models.

Inference-Time Enhancements

The authors identify several "knobs" that can be tuned during the sampling process to improve adherence to spatial constraints without requiring model retraining:

  • Control Guidance (ctrl-G): An extension of Classifier-Free Guidance (CFG) specifically designed for spatial maps. It amplifies the influence of the control signal during the denoising or generation process.
  • Softmax Truncation (top-p): Applied to autoregressive models, this technique prunes the "long tail" of the probability distribution, significantly improving both image quality and structural consistency.
  • Projected Guidance (proj-G): A technique used to mitigate the oversaturation and contrast artifacts that typically occur when high guidance scales are applied in diffusion models.

Experimental Setup

To ensure a rigorous comparison, the authors utilize ImageNet (1.2M samples) at a 256x256 resolution. Control signals are derived using Canny Edge Detection to provide structural outlines and DPT-Hybrid Depth Estimation to provide 3D spatial context.

Furthermore, to investigate the phenomenon of "catastrophic forgetting," the authors created a semantically pruned version of ImageNet. By removing all "organism" classes (animals and plants) from the control-tuning phase, they could measure how different training strategies impact the model's ability to retain pre-existing knowledge.

Key Insights and Results

The investigation yielded several critical takeaways for the design of controllable Transformers:

1. The Efficacy of Prefilling

The simple prefilling strategy proved to be a remarkably strong baseline, often outperforming more complex, published architectures like ControlVAR and ControlAR in terms of Fréchet Inception Distance (FID). This suggests that Transformers are inherently capable of processing spatial conditioning if the information is presented efficiently as a prefix.

2. Sampling Math Matters

A significant portion of control performance can be recovered or enhanced at inference time. For autoregressive models, top-p sampling was found to be essential for maintaining consistency with the input map. Similarly, while ctrl-G increases computational cost by approximately 50%, it provides a powerful mechanism for strictly enforcing spatial constraints without retraining the model.

3. The Adapter Trade-off

The study clarifies the role of "Adapters" (e.g., ControlNet-style modules). While full fine-tuning generally results in better spatial adherence, it leads to catastrophic forgetting if the control dataset is limited. In the "no-organism" experiment, fully fine-tuned models lost the ability to generate animals, whereas adapter-based models successfully combined their pre-trained knowledge with the new spatial controls.

4. Quantization Bottlenecks

In VAR models, the authors observed that quantizing the control map into discrete tokens—a common practice in some AR pipelines—actually degrades performance. Maintaining the control information in a continuous or "raw" format allows the model to better capture the nuances of the spatial map.

Conclusion

This research demonstrates that sophisticated spatial control in Transformers does not always require complex architectural overhead. By leveraging simple prefilling and optimizing inference-time sampling, researchers can achieve high-fidelity, controllable image generation. While the current study focuses on class-conditioned ImageNet models, the principles established here provide a roadmap for enhancing massive text-to-image foundation models. Future work will involve scaling these techniques to models like Flux and Sora to determine their effectiveness in open-domain synthesis.

Summary updated

BibTeX
@article{xia2025practical,
  author = {Guoxuan Xia and Harleen Hanspal and Petru-Daniel Tudosiu and Shifeng Zhang and Sarah Parisot},
  title = {{A Practical Investigation of Spatially-Controlled Image Generation with Transformers}},
  journal = {Accepted by TMLR},
  year = {2025},
  url = {https://openreview.net/forum?id=loT6xhgLYK},
}
Figure