Abstract
TextDiffuser is a two-stage framework designed to resolve the persistent issue of illegible text generation in AI image synthesis. By utilizing a Transformer to plan text layouts and a diffusion model to render them, TextDiffuser achieves unprecedented accuracy. Alongside the model, the authors introduce MARIO-10M, a comprehensive dataset of 10 million image-text pairs with fine-grained OCR annotations, establishing a new standard for controllable text-in-image synthesis.
Introduction: The Text Generation Problem
Standard diffusion models like Stable Diffusion or DALL-E 2 excel at capturing artistic styles and complex textures but frequently fail when asked to generate specific text, often producing illegible characters. The core issue is that most models treat text as just another visual texture rather than structured information. They lack a mechanism to plan where text should go and how characters should be formed. Existing attempts to fix this often lack flexibility, struggling with multiple lines or failing to harmonize the text with the image background.
Methodology: A Two-Stage Approach
The authors propose a "divide and conquer" strategy called TextDiffuser, which splits the task into two distinct stages:
- Stage 1: Layout Generation: A Layout Transformer acts as a digital typesetter. Given a text prompt, it identifies keywords (usually words enclosed in quotes) and predicts their spatial coordinates via bounding boxes. These boxes are then rendered into character-level segmentation masks, providing a pixel-perfect map of where every letter should be placed.
- Stage 2: Image Generation: A latent diffusion model, fine-tuned from Stable Diffusion, takes over. It is conditioned on both the original text prompt and the segmentation masks generated in Stage 1.
To ensure the model accurately renders the letters, the authors introduce a character-aware loss. They pre-trained a separate U-Net to recognize characters and used its feedback to guide the diffusion process toward generating sharper, more accurate letterforms.
Crucially, TextDiffuser is highly versatile. It supports text-to-image generation from a prompt, text-to-image with templates (using a user-provided image or sketch as a layout guide), and text inpainting to modify or add text to an existing image.
Datasets: MARIO-10M and MARIO-Eval
To train and evaluate TextDiffuser, the paper introduces two major resources for the research community:
- MARIO-10M: A massive dataset of 10 million image-text pairs built from LAION-400M (general images), TMDB (movie posters), and OpenLibrary (book covers). Unlike previous datasets, every image features comprehensive annotations, including OCR detection, recognition, and character-level segmentation.
- MARIO-Eval: A rigorous benchmark consisting of over 5,000 prompts across various categories to test how well models render text in diverse contexts.
Key Insights
- Explicit Layout Planning: The researchers realized that expecting a diffusion model to handle both global composition and local character structure simultaneously is highly inefficient. By forcing the model to follow a pre-planned layout, they removed the spatial guesswork from the generation process.
- Template Flexibility: By allowing the model to start from a "template"—such as a handwritten note or a specific font layout—TextDiffuser becomes a practical tool for design applications, extending beyond simple prompt-based generation.
- Character-Level Guidance: Utilizing segmentation masks instead of standard bounding boxes allows the model to understand the precise shape of the letters. This enables TextDiffuser to handle different fonts and styles while maintaining strict legibility.
Results and Performance
TextDiffuser significantly outperforms previous state-of-the-art models in text accuracy and visual coherence.
- OCR Accuracy: On the MARIO-Eval benchmark, TextDiffuser achieved an OCR F-measure of 0.7824, drastically outperforming Stable Diffusion (0.0214) and the more advanced DeepFloyd IF (0.1762).
- Human Preference: In user studies, participants consistently chose TextDiffuser’s results for having the "best text rendering quality" and "best image-text matching" by a wide margin over competitors like DALL-E 2, Midjourney, and ControlNet.
- Efficiency: Despite the two-stage process, the model only adds approximately 3% more parameters to the base Stable Diffusion architecture, making it relatively lightweight and easy to deploy.
Limitations and Future Work
Despite its success, TextDiffuser has a few limitations:
- The VAE Bottleneck: Because the model operates in a compressed "latent space" via a Variational Autoencoder (VAE), very small characters can degrade during compression. Moving to a more powerful backbone like Stable Diffusion 2.1 or using OCR-specific priors (like OCR-VQGAN) could mitigate this.
- Text Overload: When a prompt contains an excessively large number of keywords, the Layout Transformer can occasionally produce overlapping or disordered bounding boxes.
- Language Support: The current iteration is primarily focused on English. Expanding the framework to handle non-Latin scripts, such as Chinese or Arabic, remains a key objective for future development.
Summary updated