Abstract
Current text-to-image diffusion models often struggle with rendering accurate, multilingual text, particularly in non-Latin scripts. We present RepText, a framework that treats text rendering as a structural replication task. By initializing the diffusion process with noisy glyph latents and employing regional masking, RepText enables precise control over font, color, and character accuracy across various languages without requiring extensive semantic retraining.
Introduction
Despite significant advancements in image synthesis, rendering legible and accurate text remains a formidable challenge for state-of-the-art models like Stable Diffusion and FLUX. These models frequently exhibit spelling errors and fail significantly when tasked with non-Latin scripts such as Chinese, Korean, or Arabic. This failure stems from a reliance on text encoders (e.g., T5, CLIP) that prioritize semantic understanding over structural representation. Furthermore, the scarcity of multilingual training data makes retraining these models prohibitively expensive.
Methodology
RepText operates on the principle that text understanding is sufficient but not necessary for accurate rendering. By mimicking a "copybook" approach, the model replicates visual templates rather than interpreting linguistic meaning.
Glyph Latent Replication
The core innovation of RepText is Glyph Latent Replication. Instead of initiating the diffusion process from pure Gaussian noise, the model initializes text-designated regions with a noisy version of the target glyphs, encoded via a Variational Autoencoder (VAE). This provides a structural "blueprint" that guides the model from the first denoising step.
Regional Masking and Control
To maintain background integrity, RepText utilizes a dedicated ControlNet-like branch to process Canny edges and position masks. Crucially, a binary regional mask restricts feature injection to the text area, preventing the control signals from distorting the surrounding scene.
Training and Loss Functions
The model is trained in two stages: pre-training on the Anytext-3M dataset and fine-tuning on a curated set of 10,000 high-quality natural images (e.g., storefronts, billboards). To ensure character fidelity, a Text Perceptual Loss is implemented using a pre-trained OCR model (PP-OCRv3), penalizing deviations from the ground-truth feature maps.
Key Results
RepText achieves state-of-the-art performance in controllable text rendering. It successfully handles diverse scripts, including Chinese, Japanese, Korean, Vietnamese, and Russian, which typically pose significant difficulties for English-centric models.
The framework offers superior control over font style and color. By replicating a visual template, the model naturally harmonizes the specified text into the scene's aesthetic. Qualitative comparisons indicate that RepText matches or exceeds the performance of closed-source models like GPT-4o in terms of spatial and font controllability.
Discussion and Limitations
While RepText represents a significant step forward, certain challenges remain. The rendered text can occasionally appear "pasted on," lacking perfect integration with the scene's lighting and texture. Intricate scripts or extremely small fonts may suffer from VAE-induced blurriness. Additionally, the model currently struggles with complex 3D perspectives, such as warping text onto curved surfaces. Future work may involve integrating Multilingual Large Language Models (MLLMs) to improve contextual harmony and scene integration.
Code and models are available at: https://github.com/Shakker-Labs/RepText
Summary updated