Zero-Shot Styled Text Image Generation, but Make It Autoregressive

Vittorio Pippi, Fabio Quattrini, Silvia Cascianelli, Alessio Tonioni, Rita Cucchiara

Introduction

Styled Handwritten Text Generation (HTG) is the task of creating images of a target text string while mimicking the visual style of a provided reference sample. While applications range from personalized digital content to graphic design, existing methods—primarily based on Generative Adversarial Networks (GANs) and Diffusion models—often struggle with generalization to unseen styles and the constraints of fixed-size output canvases.

Emuru is a novel framework that reimagines HTG by applying the principles of autoregressive Transformers to visual text. By treating text images as sequences of continuous embeddings rather than static pixels, Emuru achieves state-of-the-art zero-shot generalization and the ability to generate text lines of arbitrary length.

The Challenges of Traditional HTG

Despite recent progress, three major hurdles have limited the utility of previous HTG models:

  1. Generalization Gap: Models often fail to mimic styles that differ significantly from their training distribution, particularly when moving from synthetic fonts to human handwriting.
  2. Fixed-Length Constraints: Most architectures are bound by a maximum output length or a fixed "canvas" size. This leads to "squishing" or "stretching" artifacts when attempting to generate long sentences.
  3. Background Entanglement: Many models inadvertently capture the noise, paper texture, or artifacts from the style reference, resulting in messy outputs that are difficult to use in professional design contexts.

The Emuru Framework

Emuru addresses these issues through a two-stage architecture that separates visual representation from sequence generation.

1. The VAE: Stripping the Background

Instead of operating directly on raw pixels, Emuru utilizes a Variational Autoencoder (VAE). The VAE is trained to map vertical slices of text images into a dense latent space. Crucially, the VAE is optimized to reconstruct only the text, effectively "stripping" away background noise and paper textures. Auxiliary losses, including a text recognition loss, ensure that the resulting latent vectors preserve both the stylistic nuances of the writer and the legibility of the characters.

2. The Autoregressive Transformer

Inspired by Large Language Models (LLMs), Emuru employs a Transformer Encoder-Decoder architecture.

  • Encoder: Processes the desired text string (the "content").
  • Decoder: Iteratively predicts the next "visual token" (latent vector) based on the style reference and the sequence generated thus far.

Because the model is autoregressive, it can generate text lines of any length. It learns an implicit "end-of-sequence" by emitting padding embeddings (representing white space) once the text is complete, allowing the system to stop generation dynamically.

Training on Synthetic Diversity

One of the paper's most significant findings is that real human handwriting is not strictly necessary for training a high-performing handwriting generator. Emuru was trained on a massive synthetic dataset of 2.2 million images rendered using over 100,000 distinct fonts. This extreme diversity allows the model to learn the underlying "grammar" of style, enabling it to generalize to human handwriting in a zero-shot manner.

Benchmarking and Results

The authors evaluated Emuru against standard benchmarks (IAM, CVL, and RIMES) and introduced a new dataset called Karaoke. Karaoke consists of song lyrics rendered in 100 distinct fonts (50 calligraphy, 50 typewritten) on clean backgrounds, specifically designed to test style imitation without background interference.

Key Performance Metrics

  • Zero-Shot Dominance: Emuru significantly outperformed previous state-of-the-art (SOTA) models. On the CVL dataset, Emuru achieved a Fréchet Inception Distance (FID) of 14.39, nearly halving the score of the previous best model, HWT (31.22).
  • Style Fidelity: In the Karaoke benchmark, Emuru achieved the highest scores for style consistency (HWD) and image realism (FID/KID) across both handwritten and typewritten categories.
  • Clean Outputs: Unlike Diffusion-based models that often produce noisy backgrounds, Emuru generates clean text on white backgrounds, making it immediately viable for digital document editing and graphic design.

Limitations and Future Work

While Emuru represents a leap forward, the authors identified specific areas for improvement:

  • Long-Sequence Decay: Performance in terms of readability and style consistency tends to degrade on sequences exceeding 75 characters.
  • Readability vs. Style Trade-off: The model occasionally produces "typos" in the generated images because it lacks a hard constraint to ensure every character is perfectly rendered.
  • Incremental Generation: To mitigate long-sequence issues, the authors suggest an "incremental" approach—generating one word at a time using the previous word as a style reference—though this increases computational overhead.

Conclusion

By reframing styled text generation as an autoregressive sequence task, Emuru overcomes the rigid constraints of previous pixel-based models. Its ability to generalize to unseen styles using only synthetic training data suggests a new path forward for zero-shot visual generation, where diversity of data and architectural flexibility take precedence over specialized human-labeled datasets.

Summary updated

BibTeX
@inproceedings{pippi2025zero,
  author = {Vittorio Pippi and Fabio Quattrini and Silvia Cascianelli and Alessio Tonioni and Rita Cucchiara},
  title = {{Zero-Shot Styled Text Image Generation, but Make It Autoregressive}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  doi = {10.1109/cvpr52734.2025.00741},
}
Figure