HWD: A Novel Evaluation Score for Styled Handwritten Text Generation

Vittorio Pippi, Fabio Quattrini, Silvia Cascianelli, Rita Cucchiara

Abstract

Styled Handwritten Text Generation (HTG) requires evaluation metrics that accurately capture the nuances of individual handwriting styles, such as slant, stroke thickness, and character ligatures. While the Fréchet Inception Distance (FID) is the standard metric for generative models in computer vision, it is poorly suited for the handwriting domain due to its reliance on natural image backbones and its requirement for large, square-cropped datasets. This paper introduces Handwriting Distance (HWD), a domain-aware metric designed specifically for HTG. HWD utilizes a VGG16 backbone pretrained on a massive calligraphic dataset, supports variable-length inputs, and demonstrates superior stability and style discrimination compared to FID. Experimental results across multiple languages and historical scripts show that HWD aligns more closely with human perception and provides a more reliable benchmark for state-of-the-art HTG models.

Introduction

Generating realistic handwriting is a complex task where an AI must mimic a specific person's unique calligraphic style while producing arbitrary new text. Evaluating the success of these models is critical for progress in the field. Historically, researchers have relied on the Fréchet Inception Distance (FID). However, FID presents three major flaws when applied to handwriting:

  1. Domain Mismatch: FID relies on an Inception-v3 backbone trained on ImageNet. Features optimized for identifying cats or cars do not effectively capture the subtle nuances of pen strokes.
  2. The "Square" Problem: FID requires square inputs. Because text lines are typically long and thin, researchers often crop only the beginning of a word, discarding significant stylistic information.
  3. Sample Hunger: FID is notoriously unstable and biased when calculated with small sample sizes, which is a common constraint in handwriting research involving historical or rare scripts.

The HWD Framework

To address these limitations, the authors propose Handwriting Distance (HWD). The metric is built upon three architectural pillars designed to prioritize stylistic fidelity over generic image features.

1. Domain-Specific Backbone

Instead of ImageNet, HWD utilizes a VGG16 network pretrained on Font², a synthetic dataset containing 100 million samples across 10,400 different calligraphic fonts. This pretraining ensures the model is sensitive to handwriting-specific features like ligatures, spacing, and stroke curvature. Interestingly, the researchers found that VGG16 outperforms deeper networks like ResNet for this task, as the "skip connections" in deeper architectures can inadvertently wash out the subtle style representations necessary for handwriting analysis.

2. Variable-Length Processing

HWD is designed to process the entire image regardless of its width. By extracting feature maps from the last convolutional block, the metric generates a set of feature vectors that represent the whole text line. This eliminates the need for arbitrary cropping and preserves the global context of the writing style.

3. Perceptual Distance Calculation

Rather than comparing complex probability distributions (as in the Fréchet distance), HWD calculates the Euclidean distance between the mean feature vectors of the real and generated image sets. This approach makes the score more representative of how humans perceive style similarity and contributes to the metric's overall stability.

Experimental Validation

The authors validated HWD across a diverse array of datasets covering multiple languages, eras, and scripts:

  • Multi-author (Style Separation): IAM (English), RIMES (French), CVL (English/German), KHATT (Arabic), BanglaWriting (Bengali), and NorHand (Norwegian).
  • Single-author (Stability/Historical): Saint Gall (Latin/Gothic), Washington (English/George Washington), Rodrigo (Spanish), ICFHR14 (English/Jeremy Bentham), Leopardi (Italian), and LAM (Italian/Lodovico Muratori).

Key Insights and Results

Style Discrimination and Sensitivity

In style verification tests—distinguishing whether two sets of writing belong to the same individual—HWD achieved an Equal Error Rate (EER) of 0.3% on the IAM dataset. In contrast, FID recorded a significantly higher EER of 13.6%. Furthermore, HWD shows a near-linear response to physical changes in handwriting, such as increasing slant (shear) or stroke thickness (dilation/erosion), whereas FID is often distracted by background textures or image noise.

Numerical Stability

A significant advantage of HWD is its stability at scale. While FID scores fluctuate wildly and require thousands of samples to reach a reliable estimate, HWD reaches a stable plateau with as few as 100 samples. This makes it an ideal metric for evaluating models trained on limited historical data.

Benchmarking and Efficiency

When testing state-of-the-art models like VATr and HWT, HWD provided a clearer ranking that aligned better with qualitative visual results than traditional metrics. Additionally, HWD is computationally efficient; for a dataset of approximately 25,000 images, HWD feature extraction and calculation took roughly 135 seconds, compared to over 435 seconds for FID.

Conclusion and Future Work

HWD represents a significant step forward in the evaluation of styled handwriting generation. By moving away from generic computer vision metrics and toward domain-specific feature extraction, HWD provides researchers with a more accurate, stable, and efficient yardstick. While HWD is not a "true" mathematical distance metric in the strictest sense (as two different images with identical styles could result in a zero distance), this property is actually a benefit for style evaluation. Future research may focus on refining the backbone for extremely degraded historical documents or expanding the metric to evaluate multi-line paragraph generation.

Summary updated

Abstract

Abstract
BibTeX
@inproceedings{pippi2023hwd,
  author = {Vittorio Pippi and Fabio Quattrini and Silvia Cascianelli and Rita Cucchiara},
  title = {{HWD: A Novel Evaluation Score for Styled Handwritten Text Generation}},
  booktitle = {BMVC},
  year = {2023},
  url = {https://openreview.net/forum?id=UfxOt6Hm3B},
}
Figure