Moyun: A Diffusion-Based Model for Style-Specific Chinese Calligraphy Generation

Kaiyuan Liu, Jiahao Mei, Hengyu Zhang, Yihuai Zhang, Daoguo Dong, Liang He

TL;DR

Moyun is a novel diffusion-based generation model designed to produce highly controllable, style-specific Chinese calligraphy. By replacing the traditional UNet backbone with a Vision Mamba architecture (optimized via Mamba2) and introducing a lightweight "TripleLabel" conditioning mechanism, Moyun achieves state-of-the-art stroke fidelity and enables zero-shot generation of characters in styles a calligrapher never actually wrote.

What Problem Does This Paper Address?

Generating authentic Chinese calligraphy using AI is exceptionally challenging due to the intricate topological relationships between brushstrokes (such as the "flying white" dry-brush effect and complex cursive spacing) and the vast diversity of historical styles.

Prior approaches face two major bottlenecks:

  1. Backbone Limitations: Most diffusion models rely on UNet architectures. However, the local receptive fields of standard convolutions struggle to capture long-range structural and aesthetic relationships across a character's strokes.
  2. Conditioning Inefficiency: Models like Calliffusion use heavy, pre-trained text encoders (like BERT) to process prompts containing the character, font, and calligrapher. These text encoders often fail to grasp domain-specific calligraphy terms, split historical names into nonsensical tokens, and introduce unnecessary computational overhead.

Furthermore, existing datasets are either small, proprietary, or severely degraded by noise from historical stone inscriptions and worn paper.

Methods

The architecture of the Moyun model, featuring patchified latent noise and the TripleLabel conditioning mechanism integrated into a Mamba2-backed Vision Mamba block.

Moyun addresses these challenges through a clean, three-stage hierarchical architecture:

  • Vision Mamba Backbone: The authors discard UNet in favor of a Vision Mamba block powered by Mamba2. The input image is converted into a sequence of patches. By utilizing State Space Models (SSMs), Moyun models long-range pixel dependencies linearly and efficiently, capturing the global layout and stroke dynamics far better than local convolutions.
  • TripleLabel Control Mechanism: Instead of using a text encoder, Moyun maps the calligrapher, font, and character to independent class labels. These labels pass through three separate trainable embedding tables. Because Euclidean spaces possess additive properties, the final conditioning vector is simply the linear superposition of the three embeddings: $$e_{total} = e_{calli} + e_{font} + e_{char}$$ This combined embedding modulates the diffusion process via a scale-shift mechanism similar to Diffusion Transformers (DiT), drastically lowering computational costs.

Datasets

The authors introduced Mobao, a massive, newly collected dataset containing 1,929,393 single-character images. It spans 6 major script types (regular, running, cursive, clerical, seal, and seal carving), features works from 2,681 distinct calligraphers, and covers 4,660 unique Chinese characters.

To clean the highly noisy raw images, the authors designed an automated binarization pipeline using the Segment Anything Model (SAM). They applied Gaussian-filtered Otsu binarization to find connected components, filtered out noise spots under 100 pixels, and used $k$-means clustering to automatically generate positive and negative point prompts to guide SAM in extracting clean character masks.

Key Insights and Ideas

  • Linear Superposition for Zero-Shot Style Transfer: Disentangling the conditioning factors into independent, additive embeddings allows the model to perform combinatorial generalization. For example, if the model has never seen the character "bai" written by Wang Xizhi in regular script, it can still synthesize it perfectly by summing the vectors for "Wang Xizhi", "regular script", and "bai".
  • SSMs for Structural Art: Calligraphy is defined by the spatial harmony and continuous flow of the brush. The bidirectional sequence modeling of Vision Mamba naturally aligns with the sequential, multi-scale nature of human brushstrokes, outperforming the local window constraints of CNNs.

Key Results

Visual comparison of character generation. The top row displays Moyun's zero-shot generations for unseen character-style combinations, while the bottom row shows the corresponding ground truth.
  • Image Quality Metrics: Moyun significantly outperformed existing models like CalliGAN, ZiGAN, and Zipeng Zhao, achieving a Peak Signal-to-Noise Ratio (PSNR) of 32.0727 and a superior Intersection over Union (IoU) score of 0.260.
  • OCR Legibility: The generated characters were evaluated using Tencent’s handwritten Optical Character Recognition (OCR) API. Moyun achieved high recognition success rates on widely used scripts (regular and running script), proving that the generated characters maintain structurally correct, legible forms.
  • Human Evaluation: In a blind style-matching test presented to 9 calligraphy enthusiasts and art students, participants correctly identified the intended calligrapher's style 53.3% of the time out of four choices—well above the 25% random guessing baseline.

Limitations and Future Work

Despite its strong performance, Moyun inherits challenges from the long-tail distribution of the Mobao dataset, as many historical calligraphers have very few surviving works. Additionally, the OCR recognition rates drop significantly for highly stylized or ancient scripts (cursive, clerical, and seal script). This is primarily due to the vast structural divergence between these ancient scripts and modern simplified Chinese characters, an area the authors plan to address in future evaluations using more specialized structural metrics.

Summary updated

BibTeX
@misc{liu2024moyun,
  author = {Kaiyuan Liu and Jiahao Mei and Hengyu Zhang and Yihuai Zhang and Daoguo Dong and Liang He},
  title = {{Moyun: A Diffusion-Based Model for Style-Specific Chinese Calligraphy Generation}},
  year = {2024},
  eprint = {2410.07618},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.07618},
}
Figure