Abstract
Visual text rendering poses a fundamental challenge for contemporary text-to-image generation models, with the core problem lying in text encoder deficiencies. To achieve accurate text rendering, we identify two crucial requirements for text encoders: character awareness and alignment with glyphs. Our solution involves crafting a series of customized text encoder, Glyph-ByT5, by fine-tuning the character-aware ByT5 encoder using a meticulously curated paired glyph-text dataset. We present an effective method for integrating Glyph-ByT5 with SDXL, resulting in the creation of the Glyph-SDXL model for design image generation. This significantly enhances text rendering accuracy, improving it from less than $20\%$ to nearly $90\%$ on our design image benchmark. Noteworthy is Glyph-SDXL's newfound ability for text paragraph rendering, achieving high spelling accuracy for tens to hundreds of characters with automated multi-line layouts. Finally, through fine-tuning Glyph-SDXL with a small set of high-quality, photorealistic images featuring visual text, we showcase a substantial improvement in scene text rendering capabilities in open-domain real images. These compelling outcomes aim to encourage further exploration in designing customized text encoders for diverse and challenging tasks.
Introduction
State-of-the-art image generators like DALL-E 3 or Stable Diffusion often struggle with a "spelling bee" problem. When asked to create a poster with a specific sentence, "Hello World" frequently becomes "Helle Wold" or a string of unreadable runes. This research identifies the bottleneck not in the image decoder, but in the text encoder.
Most current models rely on CLIP, which excels at semantic understanding (knowing a "dog" is a furry animal) but fails at character awareness (knowing "dog" consists of 'd', 'o', and 'g'). While models using T5 have better language understanding, they lack "glyph alignment"—the knowledge of how characters appear visually when rendered. Glyph-ByT5 addresses these gaps by providing a character-aware, glyph-aligned encoder specifically designed for accurate and aesthetically pleasing visual text rendering.
Methodology
The researchers introduced a two-step solution to bridge the gap between text and pixels:
- Glyph-ByT5 Encoder: Starting with ByT5, a byte-level model that processes text character-by-character, the team fine-tuned the encoder using a box-level contrastive loss. This allows the model to align specific text strings with their corresponding visual "glyphs" within a bounding box. They further employed glyph augmentation—intentionally introducing typos during training—to increase the encoder's robustness against input variations.
- Glyph-SDXL Integration: To leverage this encoder, it was integrated into Stable Diffusion XL (SDXL) via a region-wise multi-head cross-attention mechanism. This architecture allows the model to use original CLIP encoders for background scenery while delegating text-heavy regions to Glyph-ByT5. A lightweight "ByT5-to-SDXL mapper" bridges the embedding spaces between the two models.
Datasets
Training and evaluation were supported by several new, high-quality datasets:
- Glyph-Text Dataset: 1 million synthetic pairs of text and rendered glyphs.
- Paragraph-Glyph-Text Dataset: 100,000 pairs designed for multi-line, dense text (up to 400 characters).
- VisualParagraphy Benchmark: 1,000 prompts ranging from short phrases to long paragraphs to test scaling capabilities.
- Design-to-Scene Alignment Dataset: 12,000 images used to fine-tune the model for "scene text" (text appearing naturally on objects like signs or clothing).
Key Results and Insights
Massive Accuracy Gains in Design
On the design image benchmark, Glyph-SDXL improved text rendering accuracy from less than 20% (standard SDXL) to nearly 90%. The model excels at creating commercial-style graphics with varied fonts and layouts.
Paragraph Power and Spelling Accuracy
One of the most significant breakthroughs is the model's ability to render hundreds of characters across multiple lines. In head-to-head comparisons on the VisualParagraphy benchmark, Glyph-SDXL significantly outperformed both DALL-E 3 and DeepFloyd-IF in spelling accuracy, particularly as character counts increased.
Character Awareness and Region-Wise Attention
The shift to character-based encoding is fundamental: if the encoder cannot "see" the letters, the generator cannot draw them. Furthermore, by using region-wise attention, the authors prevented "language drift," ensuring the model remains excellent at drawing general imagery (faces, landscapes) while mastering text in specific zones.
Conclusion and Future Work
Glyph-ByT5 demonstrates that customized text encoders can solve long-standing deficiencies in generative models. While the current iteration relies on external layout planning (like manual bounding boxes or GPT-4 prompts), future work aims to integrate automated layout planning directly into the diffusion process. Additionally, while this study focused on English/Latin characters, subsequent versions have begun expanding into multilingual support to broaden the model's global utility.
Summary updated