Abstract
Text-to-image diffusion models often struggle with generating accurate and legible visual text, a phenomenon largely attributed to sub-optimal tokenization and weak cross-attention mechanisms. This paper introduces a framework that enhances backbone models like SDXL through Mixed Granularity Input and Glyph-Aware Training. By incorporating glyph-centric representations and specialized loss functions, including OCR-based feedback, the proposed method significantly improves text rendering accuracy in both English and Chinese without compromising artistic image quality.
Introduction
While contemporary diffusion models excel at artistic composition, they frequently fail at the "spelling bee" of visual text generation. Prompts requiring specific text often result in illegible or misspelled characters. This research identifies two core issues: the fragmentation of words caused by Byte Pair Encoding (BPE) tokenization and the inability of cross-attention mechanisms to precisely bind text tokens to spatial regions.
Methodology
The proposed framework addresses these limitations through a two-pronged approach designed to augment existing backbone architectures.
Mixed Granularity Input
To move beyond fragmented BPE tokens, the authors implement a "glyph-centric" representation. Words intended for the image are rendered as simple glyphs and processed through a pre-trained OCR model to extract visual features. These features are then fused with standard text embeddings, providing the model with a visual template for character formation.
Glyph-Aware Training
The training process is augmented with three specialized loss functions:
- Attention Alignment Loss ($L_{attn}$): Synchronizes internal attention maps with the intended spatial location of the text.
- Local MSE Loss ($L_{loc}$): Enhances pixel-level detail within text regions to prevent blurring.
- OCR Recognition Loss ($L_{ocr}$): Utilizes a pre-trained OCR model as a discriminator to penalize illegible text generation.
Datasets and Implementation
The model was trained on a curated English dataset of 240,000 high-quality image-caption pairs and a synthetic Chinese dataset of 50,000 samples. The use of visual glyph features allows the method to scale effectively to logographic languages like Chinese, where traditional tokenization is particularly ineffective.
Results
Experimental results on SDXL and SDXL-Turbo demonstrate substantial gains. On the ChineseDrawText benchmark, the enhanced model achieved an OCR F1 score of 0.606, compared to the baseline's 0.284. Human evaluations also favored the proposed model across text aesthetics, accuracy, and semantic relevance. Importantly, the model maintains high image realism, as evidenced by stable FID scores.
Conclusion
By integrating mixed granularity inputs and glyph-aware training, this framework effectively bridges the gap between linguistic prompts and visual text generation. Future work will focus on expanding font diversity and applying these techniques to image-to-image editing tasks.
Summary updated