Abstract
AnyText2 is a state-of-the-art framework designed to address the challenges of precision and integration in visual text generation. By decoupling text rendering from image generation through a novel WriteNet+AttnX architecture, AnyText2 achieves a 19.8% boost in inference speed and superior control over specific text attributes like font and color. This paper details the architectural innovations, including specialized encoders for font and color, and demonstrates superior performance in multilingual text rendering and seamless scene integration.
Introduction
While recent text-to-image (T2I) models like DALL·E 3 and FLUX.1 have made significant strides in rendering legible text, they often struggle with two major issues: precision and integration. Users frequently lack the means to specify granular attributes such as font or color through text prompts alone. Furthermore, many existing models produce text that appears as a flat overlay rather than being naturally embedded into the scene's geometry and texture. AnyText2 addresses these gaps, providing a robust toolset for professional-grade design and realistic natural scene generation.
Methodology
WriteNet and AttnX Architecture
A key innovation in AnyText2 is the decoupling of text rendering from the main image generation process. Traditional methods often utilize a ControlNet-like module that operates at every denoising timestep, which is computationally expensive. AnyText2 introduces WriteNet, a module dedicated to learning text rendering. WriteNet generates intermediate text features only once per inference, which are then fused into the main U-Net via AttnX layers (trainable self-attention and cross-attention blocks). This architectural shift is responsible for the model's increased speed and improved realism.
Multi-Attribute Text Encoding
To provide users with precise control over text appearance, AnyText2 employs four specialized encoders:
- Glyph Encoder: Utilizes a pre-trained PP-OCRv3 to capture character shapes.
- Position Encoder: Employs convolutional layers to provide spatial awareness for accurate 2D placement.
- Font Encoder: An OCR-based module that extracts font styles from reference images or user-provided files.
- Color Encoder: A non-learning module that uses clustering and morphological analysis to extract dominant RGB values for precise color matching.
Data and Training
The model was trained on AnyWord-3M, a large-scale multilingual dataset containing 3.53 million images. A critical component of the training process was caption enhancement. The authors found that original BLIP-2 captions were insufficiently detailed (averaging 8 words). By using QWen-VL to generate more descriptive captions (averaging 47 words), the model's ability to follow complex prompts and render text accurately within context was significantly improved. Evaluation was conducted using the AnyText-benchmark, consisting of 2,000 images from Wukong and LAION-400M.
Results and Discussion
AnyText2 shows marked improvements over its predecessors and contemporary models. It achieves a 19.8% faster inference speed compared to the original AnyText. In terms of accuracy, the model improved English Sentence Accuracy (Sen.ACC) by 9.3% and Chinese by 3.3% on the AnyText-benchmark.
Beyond quantitative metrics, AnyText2 excels in attribute steering and scene integration. The model can successfully mimic fonts from reference images and match specific color inputs. Crucially, the text is rendered to follow the underlying texture and lighting of the scene, such as being carved into a mooncake or appearing within the foam of a coffee cup.
Conclusion and Limitations
AnyText2 represents a significant advancement in controllable visual text generation. By decoupling rendering and enhancing caption quality, it achieves high precision and efficiency. However, limitations remain; the color encoder is a non-learning method, which may struggle with extreme lighting or complex gradients. Future work will explore expanding these controls to more languages and integrating the WriteNet+AttnX architecture with advanced transformer-based backbones.
Summary updated