Abstract
Style-guided text image generation tries to synthesize text image by imitating reference image's appearance while keeping text content unaltered. In this paper, we focus on transferring style image's background and foreground color patterns to the content image to generate photo-realistic text image. To achieve this goal, we propose 1) a content-style cross attention based pixel sampling approach to roughly mimicking the style text image's background; 2) a pixel-wise style modulation technique to transfer varying color patterns of the style image to the content image spatial-adaptively; 3) a cross attention based multi-scale style fusion approach to solving text foreground misalignment issue between style and content images; 4) an image patch shuffling strategy to create style, content and ground truth image tuples for training. Experimental results on Chinese handwriting text image synthesis with SCUT-HCCDoc and CASIA-OLHWDB datasets demonstrate that the proposed method can improve the quality of synthetic text images and make them more photo-realistic.
Introduction
Generating synthetic text images that mimic real-world photographs is a major challenge for training Optical Character Recognition (OCR) systems. While existing methods can transfer basic styles, they often struggle with the inherent "messiness" of real-world documents, such as complex textures, lighting gradients, and spatial variations in ink or paper. These limitations typically result in blurry backgrounds or uniform, unrealistic styles. APRNet addresses these hurdles by precisely transferring spatially-varying styles from a reference image to new text content, overcoming the limitations of previous GAN-based approaches.
Methodology
The APRNet architecture employs a two-stage rendering process to disentangle background and foreground generation, as illustrated in the overview below.
Key Components
- Attention-based Pixel Sampling (AttnPixamp): Instead of regressing RGB values, which often leads to blur, this module uses cross-attention to sample actual pixels directly from the style reference. This preserves the sharp, high-frequency textures of the original paper.
- Pixel-wise Style Modulation (PixyMod): Inspired by StyleGANv2, this module replaces global style vectors with spatial style tensors. This allows the network to apply different style parameters to different parts of the image, capturing local variations in lighting and color.
- Attention-based Multi-scale Style Fusion (AttnMuSF): To solve the misalignment problem between style and content images, this module uses Spatial Pyramid Pooling (SPP) to find appropriate color patterns across multiple scales.
Training Strategy: Single Crop Strategy
Training these models usually requires triplets of (Content, Style, and Ground Truth), which are difficult to obtain. The authors developed a self-supervised "Single Crop Strategy" to create synthetic training data from single real images by shuffling and rotating patches to create a style reference.
Experimental Results
The researchers evaluated APRNet on Chinese handwriting datasets, SCUT-HCCDoc and CASIA-OLHWDB. APRNet significantly outperformed previous state-of-the-art models like SC-GAN and StyleGANv2-based baselines.
Quantitative Performance on SCUT-HCCDoc: * APRNet: PSNR of 27.09, SSIM of 0.892 * SC-GAN: PSNR of 22.03, SSIM of 0.826
Qualitative results show that APRNet successfully eliminates "water droplet" artifacts common in GANs and can handle highly complex backgrounds, such as wrinkled paper or colored ink, that often result in visual artifacts in other models.
Conclusion and Future Work
APRNet sets a new bar for synthetic handwriting generation by combining pixel-sampling attention mechanisms with pixel-wise style modulation. While highly effective, the authors note that the model is memory-intensive due to its pixel-wise operations. Future research will focus on optimizing memory usage, improving the rendering of sharp background edges, and extending the model to handle typographic style variations in addition to color and texture.
Summary updated