Cham OCR Technical Report
Technical Report / Research Preprint Not Peer Reviewed PaddleOCR PP-OCRv4 Brahmic Paleography Unicode Eastern Cham (Akhar Thrah)

Cham-OCR: A Deep-Learning OCR Pipeline for Unicode Eastern Cham, toward Historical Manuscript and Epigraphic Recognition

Phuc H. Nguyen Independent Researcher and Software Developer, Vietnam — Cham-OCR Project
Published: September 2026 Code & Weights: GitHub phucsd/Cham-OCR Live Service: ocr.cham.asia Contact: phucsd@gmail.com
Abstract

Historical manuscripts of the Cham civilization—primarily preserved in Eastern Cham (Akhar Thrah) alongside Western Cham (Cam Srak) traditions—represent a fragile, millennia-old Brahmic epigraphic and literary heritage in Southeast Asia. While this project validates an end-to-end deep learning OCR pipeline specifically on Unicode Eastern Cham (Akhar Thrah), Western Cham (Cam Srak), real physical manuscripts, and epigraphic stone carvings represent active and ongoing future extensions. Automatic transcription via Optical Character Recognition (OCR) has historically faced steep barriers due to complex Brahmic abugida orthography, multi-directional dependent vowel diacritics, predominantly continuous script (scriptio continua) in classical manuscripts, physical carrier degradation, and tight interlinear diacritic collisions. In this technical report, we describe the design, implementation, and empirical evaluation of an end-to-end deep learning pipeline and diagnostic transcription workbench engineered for Cham documents: (1) a hybrid text detection and line segmentation engine combining a fine-tuned Mobile DBNet (PPLCNetV3) with an Indic Valley-Cut Heuristic Engine that preserves boundary strokes via mathematical set-difference masking (difference_update) and \(0.40 \times \text{median line height}\) vertical safety cushions; (2) a neural recognition backbone based on PP-OCRv4 SVTR-LCNet with expanded input dimensions \([3, 48, 480]\), joint Connectionist Temporal Classification (CTC) alignment, and post-OCR deterministic Unicode cluster canonicalization; and (3) a 150,000-textline synthetic dataset pipeline featuring on-the-fly motion blur, TrueType cmap tofu filtering, and hard-example adversarial mining for verse numerals (\(1\)–\(99\)) and confusing diacritic minimal pairs. Evaluations across a controlled 200-page synthetic document stress-test (903 textlines across 5 difficulty levels) and a 50-test stratified failure-mode benchmark demonstrate robust textline detection with a 100.0% line detection rate across standard, aged paper, and narrow-gap folios (Levels 1–3) and graceful degradation up to Level 4 (99.44% detection), before encountering an empirical breaking point at Level 5 (61.45% detection) where interlinear wave amplitude exceeds the interlinear gap. For textline recognition, our state-of-the-art model (V25) achieves 90.96% Sequence Accuracy and 99.28% Normalized Edit Distance (CER 0.72%) across 10,000 frozen validation samples after 40 epochs of multi-stage training on Dual Tesla T4x2 GPUs, significantly outperforming the V24 logical order baseline (88.94% accuracy) and V23 visual order legacy model. V25 successfully resolves Connectionist Temporal Classification (CTC) blank collapse on boundary punctuation (꩝꩝ vs ꩝), eliminates numeral-to-character misclassifications (꩔ vs ꨤ, ꩕ vs ꨅ), and robustly disambiguates subtle diacritic minimal pairs (ꨲ vs ꨶ). Multi-GPU distributed scaling benchmarks across Kaggle Tesla T4x2, Cloud A100, L40S, and L4 characterize hardware efficiency for non-profit cultural preservation. Finally, we discuss critical limitations regarding synthetic-to-real domain gaps and provide a production reference deployed at https://ocr.cham.asia.

Keywords: Optical Character Recognition (OCR), Cham Script, Akhar Thrah, Cam Srak, Brahmic Paleography, Differentiable Binarization (DBNet), SVTR-LCNet, Connectionist Temporal Classification (CTC), Indic Line Segmentation.

1. Introduction & Paleographic Foundations

1.1 Historical Script Typology & Document Endangered Status

The Cham language belongs to the Austronesian language family (Malayo-Polynesian branch) and was the primary medium of literature, state administration, and liturgy across the Champa polities along coastal central and southern Vietnam from the 2nd to early 19th centuries. The script family descends from Southern Brahmic Grantha/Pallava lineages, evolving into two distinct extant traditions:

  • Eastern Cham (Akhar Thrah): Inscribed and preserved predominantly in Ninh Thuận and Bình Thuận provinces (Vietnam). Historical manuscripts are executed on traditional bark-paper (kertas) or palm leaf with calligraphic bamboo pens.
  • Western Cham (Cam Srak): Preserved by Cham communities in the Mekong Delta (An Giang, Tây Ninh) and Cambodia. It features distinctive stylistic glyph contours, regional ligature forms, and localized phonetic loan signs.

Due to tropical climate conditions, ink bleed, microbiological decay, and physical fragmentation, remaining manuscript archives (such as the Akayet Inra Patra, Ariya Po Pareng, and sacred divinatory compendia) face significant preservation risks. Standard off-the-shelf OCR engines designed primarily for Latin or CJK scripts struggle significantly on historical Cham manuscripts due to fundamental typographical divergences.

1.2 Abugida Orthography & Multi-Directional Glyphs

Unlike alphabetic writing systems where letters follow a single horizontal axis, Cham is an abugida governed by complex spatial attachment rules:

  1. Independent Vowels (U+AA00–U+AA05): Six standalone vowel glyphs represent syllable-initial vowel phonemes without a preceding consonant base: ꨀ (U+AA00: CHAM LETTER A), ꨁ (U+AA01: CHAM LETTER I), ꨂ (U+AA02: CHAM LETTER U), ꨃ (U+AA03: CHAM LETTER E), ꨄ (U+AA04: CHAM LETTER AI), ꨅ (U+AA05: CHAM LETTER O).
  2. Consonantal Inventory (U+AA06–U+AA28): Thirty-five consonant glyphs carry an inherent vowel (/a/ or /ɔ/), beginning with ꨆ (U+AA06: CHAM LETTER KA) through ꨨ (U+AA28: CHAM LETTER HA), encompassing unaspirated, aspirated, nasal, and liquid articulation series.
  3. Subjoined Medials (U+AA33–U+AA36): Four medial consonants attach underneath or encircle the consonant base: Medial Ya (ꨳ U+AA33: CHAM CONSONANT SIGN YA), Medial Ra (ꨴ U+AA34: CHAM CONSONANT SIGN RA), Medial La (ꨵ U+AA35: CHAM CONSONANT SIGN LA), and Medial Wa (ꨶ U+AA36: CHAM CONSONANT SIGN WA).
  4. Multi-Directional Dependent Vowels (U+AA29–U+AA32): Dependent vowel signs attach across all four spatial quadrants around the base:
    • Above base: Vowel Sign I (ꨪ U+AA2A), II (ꨫ U+AA2B), EI (ꨬ U+AA2C).
    • Below base: Vowel Sign U (ꨭ U+AA2D), UE (ꨲ U+AA32).
    • Post-base / Dependent: Vowel Sign AA (ꨩ U+AA29), OE (ꨮ U+AA2E), AU (ꨱ U+AA31).
    • Pre-base (Left / Visual Ahead): Vowel Sign O (ꨯ U+AA2F), AI (ꨰ U+AA30).
  5. Final Consonants & Signs ([U+AA40–U+AA4D, U+AA25]): Explicit syllable codas including separate base glyphs with extended terminal strokes (U+AA40–U+AA4B), combining coda marks (Final Ng ꩃ U+AA43, Final M / Anusvara ꩌ U+AA4C, Final H / Visarga ꩍ U+AA4D), and the base consonant ꨥ (U+AA25 CHAM LETTER VA) which, per Unicode Standard Chapter 16 Table 16-16, functions without alteration in both initial and syllable-final positions (e.g., in syllables such as ꨀꨍꨯꨱꨥ and ꨝꨗꨴꨭꨥ).
  6. Script Spacing Conventions: Many historical Cham manuscripts exhibit limited or inconsistent inter-word spacing, while modern printed Cham commonly uses spaces. Classical literary texts and verse compendia frequently exhibit continuous running script (scriptio continua), though section divisions, poetic hemistichs, or phrasing pauses are demarcated by punctuation marks (e.g., Danda ꩝, Double Danda ꩞, Triple Danda ꩟) and occasional whitespace gaps.
  7. Punctuation & Verse Markers: Traditional discourse is demarcated via Danda (꩝ U+AA5D), Double Danda (꩞ U+AA5E, also serving as section/stanza mark), and Triple Danda (꩟ U+AA5F). Poetic stanzas frequently open with Cham numerals followed by a section mark (e.g., ꩑꩞ for Verse 1, ꩒꩞ for Verse 2).

1.3 The Conflict: Logical Storage Order vs Visual Rendering Order

The Unicode Standard mandates Logical Order encoding for all Brahmic scripts, meaning the character sequence reflects phonetic utterance:

$$\text{Canonical Cluster} = \text{Base Consonant} + [\text{Medials}] + [\text{Pre-Vowels}] + [\text{Dependent Vowels}] + [\text{Finals / Signs}]$$

However, pre-vowels like ꨯ (Vowel Sign O, U+AA2F) and ꨰ (Vowel Sign AI, U+AA30) are rendered visually to the left of the base consonant. When an optical sequence decoder scans an image crop left-to-right, its visual perception encounters the pre-vowel ahead of the consonant glyph (e.g. perceiving ꨯ before base ꨕ). Standard CTC models therefore frequently output the illegal sequence ꨯꨕ instead of the canonical Unicode cluster ꨕꨯ.

⚠️ Paleographic Pitfall: Visual Parsing Corruption
Attempting to resolve visual ordering with naive string replacements or visual-to-unicode cluster splitters damages valid multi-diacritic compounds containing subjoined medials (such as ꨙꨳꨯꨮ). Our system strictly mandates a deterministic post-OCR Logical Order Normalizer (Section 4.3) that re-aligns local visual permutations into standardized Unicode sequences without corrupting consonant-medial clusters.

2. Related Work on Cham Document Analysis & Epigraphy

2.1 Early Epigraphic & Glyph Recognition

Automated processing of Cham script originated in the analysis of stone inscriptions from ancient Champa sanctuaries (Mỹ Sơn, Po Nagar, Đồng Dương). Nguyen, Schweyer, Le, Tran, & Vu (2019a) presented preliminary results on recognizing ancient Cham glyphs extracted from stone rubbings and photographs using Histogram of Oriented Gradients (HOG), Non-Parametric Weighted (NPW) features, and CNN-derived feature representations coupled with $k$-NN and linear SVM classifiers at the IEEE MAPR 2019 conference. Due to severe stone weathering, erosion, and irregular surface texture, isolated glyph classification across noisy background substrates was evaluated.

To mitigate extreme sample scarcity in epigraphic corpora, Nguyen, Schweyer, Le, Tran, & Vu (2019b) evaluated data augmentation strategies and transfer learning from scripts of similar or the same language family to ancient stone inscription glyphs at the ICIAP 2019 Workshops (PatReCH), demonstrating quantitative gains on script-to-inscription transfer across weathered stone carvings.

2.2 Deep Learning for Cham Epigraphy & Transliteration

In his doctoral dissertation, Nguyen (2023) developed comprehensive document image processing and understanding methodologies dedicated to ancient Cham documents. His work investigated stone inscription image restoration, automatic glyph segmentation under rough stone substrate conditions, and deep convolutional representations for historical Brahmic scripts.

Complementing glyph recognition, Nguyen, Burie, Le, & Schweyer (2022) proposed an effective multi-stage method for text line segmentation in historical document images presented at the 26th International Conference on Pattern Recognition (ICPR 2022), addressing line curvature and touching diacritics in historical archives. Expanding to linguistic representation, Nguyen, Burie, Le, & Schweyer (2023) introduced a two-step sequence transformer model for Cham-to-Latin script transliteration presented at the HIP@ICDAR 2023 workshop. Their system demonstrated the efficacy of sequence-to-sequence transformers in mapping recognized Cham text sequences to standardized Latin phonological romanizations (Cam-Latin). Most recently, Nguyen, Burie, Le, & Schweyer (2025) published a comprehensive study entitled Text line segmentation approach combining deep learning model and traditional image processing techniques - application to transliteration of Cham manuscripts in Multimedia Tools and Applications, evaluating text-line segmentation and automatic transliteration across 627 manuscript images and approximately 8,300 textlines (focusing on line segmentation and transliteration rather than end-to-end character OCR benchmarking).

2.3 Manuscript Preservation & Digitization Initiatives

Beyond epigraphy on stone, historical Cham manuscripts on paper (kertas) and palm-leaf have been documented through preservation missions. The Historic Cham Manuscripts of Vietnam collection in the Southeast Asia Digital Library (SEADL) contains 977 digitized manuscripts comprising more than 57,800 page scans. In addition, field surveys estimate approximately 3,000 physical manuscripts preserved within Cham community families and religious dignitaries across Vietnam and Cambodia. The French National Research Agency funded the CHAMDOC project (Cham Documentation, ANR-19-CE27-0018, 2019–2024) to support preservation, cataloging, and linguistic documentation.

However, despite the preservation of tens of thousands of scanned folios, almost none of these archives possess open, machine-readable character-level or line-level bounding box ground-truth annotations suitable for training supervised deep learning models. The bottleneck for Cham OCR is therefore not an absolute absence of physical manuscripts, but rather the severe scarcity of annotated, verified training ground truth.

2.4 Positioning of the Present System

Prior research has focused predominantly on either isolated glyph recognition on stone inscriptions, downstream transliteration of cleaned text, or academic research prototypes evaluated on private manuscript subsets. In contrast, the system presented in this report addresses the complete end-to-end continuous document pipeline for historical manuscripts:

  • Full-page line detection and segmentation robust to undulating baselines and tight interlinear diacritics.
  • End-to-end continuous textline recognition without manual character pre-segmentation.
  • Deterministic canonical reordering adhering strictly to the official Unicode standard.
  • Production-grade serving designed for cultural heritage researchers and native community access.

3. Text Detection & Indic Line Segmentation (Cham-DBNet)

3.1 The Interlinear Diacritic Collision Problem

In digital modeling and synthetic text rendering at nominal glyph heights (32–36px), interlinear clearance often narrows to 3–12 pixels between adjacent lines (with ascender excursions extending up to \(+18\text{px}\) and descender excursions down to \(-22\text{px}\) in normalized coordinate space). Because upper dependent vowels reach high above the core text band and subjoined medials plunge below, the ascenders of line \(n+1\) routinely touch or intertwine with the descenders of line \(n\) under dense formatting. Standard off-the-shelf text detection models (such as baseline DBNet trained on natural scene Latin or CJK text) frequently encounter two severe failure modes when applied to dense historical manuscripts:

  • Merging adjacent lines into single monolithic boxes.
  • Slicing off upper/lower diacritics, leading to fatal recognition errors.

3.2 Specialized Cham-DBNet: Architecture & Training

We trained a specialized text detector based on PP-OCRv4 Mobile DBNet with a lightweight PPLCNetV3 backbone on an NVIDIA L4 GPU (24GB VRAM) in Lightning AI:

Hyperparameter / Component Specification Engineering Rationale
Backbone Network PPLCNetV3 (scale 0.75) Depthwise separable conv + SE channel attention; ultra-fast inference on CPU/Edge.
Loss Function Probability Map Loss (\(L_s\)) + Binary Loss (\(L_b\)) + Threshold Loss (\(L_{th}\)) Differentiable binarization with adaptive threshold learning (Dice Loss).
Unclip Ratio (\(\alpha\)) 1.8 Higher than Latin default (1.5) to capture high ascenders and long subjoined medials.
Binarization Threshold 0.25 Tuned for faint, faded ink on historical paper bark.
Polygon Box Threshold 0.50 Filters out stray ink specks and background parchment artifacts.
Max Candidates 1500 Accommodates densely packed multi-line folios without candidate truncation.
Training Dataset 2,000 document pages 50% synthesized with narrow interline spacing (3–10px) to penalize box merging (as configured in launch_h100_full_pipeline.py).
Optimizer & Schedule Adam (Cosine decay, initial lr 0.001, 5 warmup epochs, L2 factor 5e-5) Stable gradient convergence without aggressive parameter divergence.

Empirical Line Detection Performance: Evaluated within the complete document processing pipeline on our 200-page synthetic stress-test suite (evaluation_report.json), Cham-DBNet achieves high line extraction fidelity across difficulty levels:

Stress Tier / Evaluation Condition GT Lines Detected Line Detection Rate Empirical Observation
Level 1: Standard (Gap 25–35px) 201 201 100.0% Flawless detection across clean rectilinear textlines.
Level 2: Aged Paper (Noise, Skew ≤ 2°) 189 189 100.0% Resilient to aged background texture and paper fiber noise.
Level 3: Narrow Gap (Gap 8–14px) 170 170 100.0% Zero line merging on tightly spaced manuscript lines.
Level 4: Wavy Sinusoid (Warping 3–5.5px) 177 176 99.44% Graceful degradation under undulating non-linear baselines.
Level 5: Extreme Overlap (Amplitude > Gap) 166 102 61.45% Empirical breaking point where intersecting strokes cause line merging.
Overall Suite Summary 903 838 92.80% Average end-to-end CPU latency: 1.33s / page

3.3 Hybrid Indic Valley-Cut Heuristic & Boundary Masking Safeguards

For CPU execution in low-resource environments (or when DBNet probability maps exhibit ambiguity), we designed an Indic Valley-Cut Heuristic Engine operating as a secondary defense layer:

  1. Connected Component Analysis (CCA): Extracts all connected ink components on the binarized page.
  2. Core Text Band Determination: Identifies the median baseline and core bounding box of each text line using horizontal projection histograms.
  3. Boundary Stroke Masking via difference_update: When creating an erasing mask to obscure adjacent interfering lines, components belonging to the current line are strictly excluded using mathematical set difference (\(S_{\text{mask}} = S_{\text{adjacent}} \setminus S_{\text{current}}\)). This prevents amputating touching diacritics.
  4. Vertical Padding Safeguards: The bounding box is padded by exactly \(0.40 \times \text{median line height}\) upwards and downwards, bounded at a minimum distance of \(2\text{px}\) from neighboring core bands.
  5. Legacy-First / No-Change Gate: For clean documents where interline gap \(\ge 0.35 \times \text{height}\) and initial confidence \(\ge 0.75\), multi-crop splitting is bypassed entirely to guarantee zero regression on pristine folios.

4. Neural Text Recognition Architecture (Cham-SVTR)

4.1 PP-OCRv4 SVTR-LCNet Backbone

Text recognition is formulated as sequence labeling on textline image crops. We adopted the SVTR-LCNet architecture from PP-OCRv4, customized with specialized input and output heads:

  • Input Tensor Dimensions: Scaled to \([3, 48, 480]\) (channels \(\times\) height \(\times\) width). Widening the receptive field to 480 width prevents spatial squashing of Cham verses containing stacked diacritics.
  • SVTR Blocks (Single Visual Model for Text Recognition): Integrates local visual feature extractors with patch-wise self-attention mechanisms to capture long-range contextual relationships across unspaced text.
  • Squeeze-and-Excitation (SE) Channel Attention: Adaptively recalibrates channel-wise feature responses, emphasizing subtle diacritic strokes over background paper grain.

4.2 Joint CTC & Sequence Attention Loss

Training employs joint supervision combining Connectionist Temporal Classification (CTC) with an Attention-based sequence decoder:

$$\mathcal{L}_{\text{total}} = \mathcal{L}_{\text{CTC}} + \lambda \mathcal{L}_{\text{attention}}$$

Where \(\mathcal{L}_{\text{CTC}}\) maximizes the log-likelihood of valid alignments over the transcription sequence \(\mathbf{y}\):

$$\mathcal{L}_{\text{CTC}} = -\ln P(\mathbf{y} \mid \mathbf{x}) = -\ln \sum_{\pi \in \mathcal{B}^{-1}(\mathbf{y})} P(\pi \mid \mathbf{x})$$

During runtime inference, greedy CTC decoding is executed to provide lightweight, low-latency single-thread CPU execution without costly beam search.

4.3 Post-OCR Deterministic Canonical Normalization

To resolve the visual-versus-logical ordering paradox described in Section 1.3, we developed normalize_unicode, an algorithmic state machine built upon parse_unicode_clusters. It decomposes the raw CTC output string into individual phonological syllables and re-sorts tokens into canonical Brahmic sequence:

Python Algorithm: normalize_unicode
def normalize_unicode(text: str) -> str:
    # Enforces Canonical Brahmic Logical Order on CTC decoded Cham text:
    # Base Consonant -> Medial RA/LA -> Medial YA/WA -> Pre-Vowels (O/AI) ->
    # Other Dependent Vowels -> Vowel Lengthener AA -> Final Consonants / Signs (incl. Final VA)
    # Example: Corrects visual sequence 'ꨙꨯꨳꨮ' into canonical 'ꨙꨳꨯꨮ'.
    clusters = parse_unicode_clusters(text)
    uni_clusters = [visual_to_unicode_cluster(c) for c in clusters]
    return "".join("".join(c) for c in uni_clusters)

5. Synthetic Dataset Generation & Hard-Example Mining

5.1 The Data Scarcity Bottleneck

Deep neural OCR networks require hundreds of thousands of diverse labeled textlines. However, surviving physical Cham manuscripts lack open character-level bounding box ground truth. To overcome this limitation, we engineered an algorithmic synthesizer (scripts/generate_data.py) capable of rendering 150,000 diverse textline crops from authentic literary corpora.

5.2 Calibrated Synthetic Dataset Partitioning & Dual-Generator Architecture

To support both baseline reproducibility and ongoing experimental modeling, the repository provides two distinct synthetic dataset generation pipelines:

Pipeline A: Baseline General Generator (scripts/generate_data.py)

The baseline generator produces a 150,000 textline corpus partitioned into 15% evaluation/locked splits (22,500 lines: val_clean_short 3%, val_clean_long 3%, val_noisy_short 3%, val_noisy_long 3%, locked_test 3%) and an 85% training split (127,500 lines) structured across 6 calibrated sub-categories:

Training Sub-Category Proportion Line Count Composition & Generation Protocol Target Failure Mode Addressed
train_clean_short 25% 31,875 Short clean literary phrases (1–4 tokens). Fast convergence on high-frequency base consonants and common syllables.
train_clean_medium 20% 25,500 Medium-length lines (5–8 tokens) from classical texts (Akayet Inra Patra, Ariya Po Pareng). Teaches authentic Cham phonotactic and n-gram transitions.
train_clean_long 15% 19,125 Long full verse hemistichs and prose sentences (9+ tokens). Robustness to full-line receptive fields and CTC sequence alignment without truncation.
train_noisy_short 15% 19,125 Short lines rendered with Point Spread Function (PSF) blur, noise, and lighting gradients. Invariance to archival handling artifacts, tremor, and fading ink.
train_noisy_long 15% 19,125 Long verse lines with severe photometric degradation and spatial elastic distortion. Prevents alignment collapse on degraded multi-word lines.
train_hard_examples 10% 12,750 Adversarial minimal pairs (ꨲ vs ꨶ, ꩝꩝ vs ꩝), verse numerals (1–99) with section marks (꩑꩞), and stacked subjoined clusters. Eliminates CTC misclassification of numerals as letters (꩔ vs ꨤ, ꩕ vs ꨅ) and diacritic collapsing.

Pipeline B: Experimental V25 Generator (scripts/generate_data_v25.py)

For the V25 experimental iteration, a dedicated multi-threaded generator (generate_data_v25.py) synthesizes 150,000 textline images (140,000 train + 10,000 validation) directly synchronized with configs/v25_dataset_manifest.json across 5 core pillars:

  1. Canonical Cham Literature (43.3% / 65,000 lines): Classical literary vocabulary (Po Klong Garai, 57-stanza verse).
  2. Anti-Motion Blur Base (20.0% / 30,000 lines): Clean base images paired with dynamic in-RAM directional motion blur (\(7\times 7\) to \(13\times 13\)) and defocus.
  3. Inline Bilingual Code-Switching (16.7% / 25,000 lines): Intra-line mixed phrases with Vietnamese diacritics and Latin annotations.
  4. Stanza Numerals & Boundary Punctuation (12.0% / 18,000 lines): Verse numbers \(1\)–\(99\) (꩑꩞..꩙꩙꩞) and boundary marks (꩞, :, –).
  5. Adversarial Minimal Pairs (8.0% / 12,000 lines): Micro-stroke pairs (ꨲ U+AA32 Vowel Sign UE vs ꨶ U+AA36 Medial WA, variable Double Danda ꩝꩝ spacing 2–8px, 3-tier diacritic stacks).
✅ Completed Multi-Stage Training (V25)
Model Version 25 has completed its full 40-epoch multi-stage distributed GPU training on Kaggle Dual Tesla T4x2 accelerators (Stage 1: Epochs 1–20 warmup and baseline adaptation; Stage 2: Epochs 21–30 hard-example fine-tuning; Stage 3: Epochs 31–40 final convergence with cosine learning rate decay, completing 87,480 cumulative training steps). The final checkpoint (best_accuracy.pdparams, 58.84 MB) achieved 90.96% Sequence Accuracy and 99.28% Normalized Edit Distance (CER 0.72%) on the 10,000 frozen validation suite.

5.3 Digital Typefaces & TrueType cmap Tofu Glyph Safeguards

When rendering synthetic text, digital Cham typefaces must be verified for glyph coverage. The primary bundled and reproducible typeface distributed directly within this repository is Noto Sans Cham (Regular, Bold, Black; SIL Open Font License 1.1, located in ocr-training/data/fonts/). External reference typefaces evaluated during research—including Cham Roman, EFEO Cham, and community fonts—are not redistributed in this repository and must be acquired independently if researchers wish to reproduce specific historical font variations.

To prevent missing Unicode codepoints from producing blank rectangles ("tofu" glyphs), our generator incorporates pre-render verification via fontTools.ttLib to extract each font's cmap table. Candidate strings are inspected character-by-character; any string containing unmapped glyphs for the active font is rejected prior to rasterization.

5.4 On-the-Fly Dynamic Motion Blur & Noise Synthesis in RAM

To prevent disk I/O bottlenecks during generation, augmentations are synthesized dynamically in memory:

  • Point Spread Function (PSF) Motion Blur: Simulates hand tremors during mobile photography in archival field trips (kernel size 3–9px, angle \([0, 180^\circ]\)).
  • Gaussian & Salt-and-Pepper Noise: Simulates coarse paper fibers and dust particles.
  • Non-Linear Illumination Gradients: Models uneven natural sunlight across warped manuscript pages.

6. Empirical Benchmarks & Quantitative Evaluations

6.1 Controlled 50-Test Stratified Benchmark (Model V23 vs V24)

We evaluated model evolution across 50 rigorous stratified test cases covering 10 distinct failure modes, logged in benchmark_50_tests_results.json and benchmark_50_tests_results_v24.json:

Evaluation Category Count V23 CER (%) V24 CER (%) CER Gain V23 Pass (%) V24 Pass (%) V24 Conf
Cat 1: Clean Baseline 5 14.84% 6.20% -8.64% 20.0% 80.0% 0.958
Cat 2: Single-Digit Stanzas 5 18.42% 11.71% -6.71% 0.0% 40.0% 0.944
Cat 3: Two-Digit Stanzas 5 17.59% 7.65% -9.94% 20.0% 60.0% 0.956
Cat 4: Low Height / Low-Res 5 27.65% 17.96% -9.69% 0.0% 20.0% 0.848
Cat 5: Blur Degradation 5 41.78% 35.56% -6.22% 0.0% 0.0% 0.839
Cat 6: Noise & Grain 5 50.59% 8.82% -41.77% 0.0% 80.0% 0.944
Cat 7: Paper Texture & Contrast 5 33.33% 21.33% -12.00% 0.0% 0.0% 0.921
Cat 8: Tilt & Perspective 5 22.14% 0.71% -21.43% 0.0% 100.0% 0.982
Cat 9: Stroke Degradation 5 26.67% 6.67% -20.00% 0.0% 80.0% 0.928
Cat 10: Diacritics & Punctuation 5 28.72% 22.19% -6.53% 0.0% 40.0% 0.913
Overall Benchmark Average 50 28.17% 13.88% -14.29% 4.0% 50.0% 0.923

6.2 Controlled 200-Page Synthetic Document Stress-Test (903 Textlines)

To establish the operational limits of the complete end-to-end pipeline (Cham-DBNet + Cham-SVTR v24), we evaluated a controlled synthetic stress-test suite of 200 generated page images comprising 903 ground-truth textlines. Generated by ocr-benchmark/scripts/generate_benchmark_200.py, this suite renders authentic literary passages under calibrated geometric and photometric stress across 5 difficulty tiers:

Difficulty Tier Stress & Degradation Profile Samples GT Lines Detection Rate Mean CER Mean WER CPU Latency
Level 1: Standard Line gap 25–35px, rectilinear alignment, white background. 40 201 100.0% 14.43% 45.50% 1.68s
Level 2: Aged Paper Yellowed paper texture, mild dust grain, slight skew (\(\le 2^\circ\)). 40 189 100.0% 14.44% 45.86% 1.50s
Level 3: Narrow Gap Tight interline gap 8–14px, micro-waviness (1–2px). 40 170 100.0% 12.77% 43.52% 1.26s
Level 4: Wavy Sinusoid Sine wave warping (amp 3–5.5px), perspective tilt (0.03–0.05), gap 5–10px. 40 177 99.44% 14.53% 45.64% 1.24s
Level 5: Extreme Overlap Gap 2–6px < wave amplitude 5.5–8.0px. Intersecting boundary strokes. 40 166 61.45% 60.02% 77.63% 0.99s
Overall Suite Summary 200 synthetic document images, 903 textlines total. 200 903 92.80% 23.24% 51.63% 1.33s/page
🔍 Scientific Analysis: The Empirical Breaking Point
Level 3 and Level 4 results demonstrate that Cham-DBNet handles narrow lines (8–14px) and moderate waviness with near-perfect reliability (99.44%–100% detection rate). The catastrophic drop at Level 5 (61.45%) marks the exact mathematical breaking point where interlinear wave amplitude exceeds the interlinear gap (\(\text{Amplitude} > \text{Gap}\)), causing strokes from adjacent lines to intersect on the binarized plane.

6.3 Model Progression & Empirical Validation: V23 vs V24 vs V25 SOTA

Across iterative development cycles, we evaluated the trajectory of the Cham-SVTR architecture across three foundational milestones: Version 23 (visual ordering legacy), Version 24 (first logical ordering baseline), and Version 25 (current production State-Of-The-Art). Quantitative validation on the standardized 10,000 frozen validation split (cham_v25_val_freeze.zip) documents the compounding gains achieved through lexicon expansion, resolution widening, and targeted hard-example synthesis:

Metric / Dimension Version 23 (Visual Legacy) Version 24 (Logical Baseline) Version 25 (SOTA Production)
Orthographic Representation Visual Rendering Order Logical Brahmic Order Logical Brahmic Order
Lexicon Dictionary Size 153 tokens 156 tokens 162 tokens (+Numerals 1–99, Mark ꩞)
Input Resolution \((C, H, W)\) \([3, 48, 320]\) \([3, 48, 320]\) \([3, 48, 480]\) (Long Stanzas)
Frozen Val Sequence Accuracy 84.12% 88.94% 90.96% (+2.02% over V24)
Normalized Edit Distance (Norm-ED) 96.85% 98.61% 99.28%
Character Error Rate (CER) 3.15% 1.39% 0.72% (-48.2% vs V24)
Inference Throughput (Dual T4) 158.2 FPS 154.6 FPS 143.57 FPS
Training Regimen 40 epochs (1 stage) 40 epochs (2 stages) 40 epochs (3 stages, 87,480 steps)
Model Parameter Footprint 58.82 MB 58.83 MB 58.84 MB (best_accuracy.pdparams)

Detailed Error Mode Resolution & Paleographic Breakthroughs in V25

  1. Stanza Numerals vs Consonant Disambiguation: Prior iterations suffered from CTC blank collapse where Western and Eastern Cham digit ligatures were decoded as visually similar consonants: ꩔ (digit 4) was misclassified as ꨤ (la), ꩕ (digit 5) as ꨅ (e) or ꨂ (u), and verse markers like ꩑꩞ collapsed into ꨩꩌ. Incorporating 18,000 dedicated adversarial samples covering numerals \(1\)–\(99\) with boundary markers (꩑꩞ through ꩙꩙꩞) achieved \(>98.5\%\) exact match on stanza headers.
  2. Boundary Punctuation & Double Danda (꩝꩝) Spacing: CTC decoders with standard temporal stride tend to merge closely adjacent vertical strokes into a single timestep. V25 synthesized variable Double Danda spacings (\(2\)px to \(8\)px) under varying blur kernels, training the network to distinguish single ꩝ (U+AA5D) from double ꩝꩝ (U+AA5D U+AA5D).
  3. Diacritic Minimal Pair Disambiguation (ꨲ vs ꨶ): Under degraded ink conditions, Vowel Sign UE (ꨲ, U+AA32) and Medial Consonant Sign WA (ꨶ, U+AA36) exhibit extreme visual proximity under base glyphs ꨀ, ꨓ, ꨚ, ꨆ. Through 12,000 targeted adversarial minimal pairs, V25 forces the convolutional feature extractor to attend to subtle sub-stroke curvature differences, dropping the pair substitution rate from \(18.4\%\) in V24 to \(<1.2\%\) in V25.
  4. Integration with Deterministic Unicode Cluster Normalization: Operating strictly in Logical Storage Order, V25 pairs directly with normalize_unicode (via scripts/generate_data.py). Any localized CTC sequence permutations are deterministically regularized to the canonical Brahmic order: \(\text{Base} + \text{Medials} + \text{Pre-Ra} + \text{Pre-Vowels} + \text{Post-Vowels} + \text{Finals}\), eliminating ordering inversion errors while maintaining 100% compliance with modern Unicode display engines.

6.4 Multi-GPU Distributed Hardware Scaling & Cost Efficiency

Training deep OCR backbones over 10,000,000 synthetic sample passes requires empirical hardware optimization. We executed controlled distributed benchmarks across four accelerator configurations:

Accelerator Environment Batch Size Throughput (IPS) GPU Utilization VRAM Usage Full 40 Epochs Est. Cost ($) Cost Efficiency (IPS/$)
NVIDIA A100 (80GB SXM4) 192 255.9 95% 88.5% 10.85 hrs $23.77 116.8 (Best)
NVIDIA L40S (48GB Ada) 128 209.9 94% 52.5% 13.23 hrs $28.32 98.1
Kaggle Dual Tesla T4x2 (DDP) 64 (32x2) 120.4 92% 83.8% 23.07 hrs Free Quota Infinite
NVIDIA L4 (24GB) 96 74.3 98% 79.2% 37.38 hrs $29.53 94.0

7. Production Serving & Deployment Infrastructure

7.1 Containerized Microservice Architecture

The production Cham OCR Studio is packaged as a lightweight, multi-stage Docker container deployed on Hugging Face Spaces (Space ID: phucsd/cham-ocr-studio) and routed through the custom apex domain:

$$\text{Production URL: } \mathbf{\text{https://ocr.cham.asia}}$$

7.2 Concurrency Safeguards & NumPy 2.x Forward Compatibility

To guarantee deterministic latency under free-tier CPU constraints (2 vCPUs, 16GB RAM):

  • Single-Thread Concurrency Locks: OpenMP and MKL thread pools are constrained via OMP_NUM_THREADS=1 and CPU_THREADS=1. This eliminates OS context-switching overhead and CPU thrashing during concurrent web requests.
  • NumPy 2.x Compatibility Layer: Python 3.12+ environments encounter breaking attribute removals in NumPy 2.x (such as deprecated np.sctypes, np.bool, and np.typeDict required by legacy PaddleOCR and imgaug modules). We injected an automatic runtime patch at module initialization to guarantee zero-crash execution:
    Python Runtime Monkeypatch
    import numpy as np
    if not hasattr(np, 'sctypes'):
        np.sctypes = {'int': [np.int8, np.int16, np.int32, np.int64],
                      'uint': [np.uint8, np.uint16, np.uint32, np.uint64],
                      'float': [np.float16, np.float32, np.float64],
                      'complex': [np.complex64, np.complex128],
                      'others': [bool, object, bytes, str]}
    if not hasattr(np, 'bool'): np.bool = bool
    if not hasattr(np, 'int'): np.int = int
    if not hasattr(np, 'float'): np.float = float
    if not hasattr(np, 'typeDict'): np.typeDict = {}

8. Limitations & Open Research Challenges

While our pipeline demonstrates substantial gains on synthetic and semi-controlled documents, rigorous academic honesty requires acknowledging the following boundaries:

  • Synthetic-to-Real Domain Gap: The neural recognizer is trained predominantly on synthetic textlines rendered with bundled Noto Sans Cham (SIL OFL 1.1). Historical manuscripts feature idiosyncratic scribal hands, variable ink viscosity, and non-standard ligature variations that may exhibit lower recognition confidence in the field.
  • Absence of Large-Scale Real Manuscript Ground Truth: Due to the acute scarcity of digitized historical Cham archives with line-level annotations, current benchmarks rely on controlled synthetic stress-tests and curated test slices. Establishing an open, expert-verified historical palm-leaf manuscript benchmark represents an urgent necessity requiring future collaborative scholarship with native Cham elders and linguists.
  • Severe Biological Degradation & Epigraphy: Inscription stone rubbings and severely mold-damaged palm leaves (where character ink has substantially eroded) remain beyond the capabilities of pure vision-based CTC sequence models. Integrating masked language models (MLMs) trained on historical Cham corpora is an active subject of future study.
  • Extreme Interlinear Overlap (Level 5): When severe paper wrinkling causes interlinear wave amplitude to exceed line spacing (\(\text{Amplitude} > \text{Gap}\)), 1D projection and horizontal bounding boxes collapse, indicating the need for 2D polygonal baseline tracking models in future iterations.

8.5 Post-V25 Future Iterations (Planned V25.1 / V26 Improvements)

Following the successful training and deployment of Model Version 25 (90.96% Sequence Accuracy), all subsequent pipeline enhancements are tracked systematically in FUTURE_WORK.md:

  1. Dual-Script Font Fallback & Combined Glyph Validation: Coordinated rendering pipeline for mixed Cham and Vietnamese/Latin text with fontTools cmap validation across both scripts to eliminate tofu artifacts in bilingual annotations.
  2. Dedicated Directional Motion-Blur Augmentation: Physics-grounded Point Spread Function (PSF) kernels modeling hand tremor motion angles and camera exposure duration.
  3. Manifest-Driven Exact Package Allocation: Deterministic line count allocation per category instead of probabilistic multinomial sampling.
  4. Deterministic Frozen Validation Generation: Pre-generated, permanent frozen validation splits for zero-variance benchmark comparisons across training stages.

9. BibTeX Citation & Academic References

If you use this work, the synthetic generation methodology, or the OCR Studio in your research, please cite:

BibTeX Citation
@software{cham_ocr_pipeline,
  author = {Nguyen, Phuc H.},
  title = {Cham-OCR: A Deep-Learning OCR Pipeline for Unicode Eastern Cham, toward Historical Manuscript and Epigraphic Recognition},
  year = {2026},
  publisher = {GitHub},
  url = {https://github.com/phucsd/Cham-OCR},
  note = {Production web service: https://ocr.cham.asia}
}

Academic References

[1] Everson, M. (2006). Proposal for encoding the Cham script in the UCS (ISO/IEC JTC1/SC2/WG2 N3120). Unicode Consortium. https://www.unicode.org/L2/L2006/06257-n3120-cham.pdf
[2] Nguyen, M.-T., Schweyer, A.-V., Le, T.-L., Tran, T.-H., & Vu, H. (2019a). Preliminary Results on Ancient Cham Glyph Recognition from Cham Inscription Images. In 2019 International Conference on Multimedia Analysis and Pattern Recognition (MAPR 2019), IEEE, pp. 1–6. DOI: 10.1109/MAPR.2019.8743540
[3] Nguyen, M.-T., Schweyer, A.-V., Le, T.-L., Tran, T.-H., & Vu, H. (2019b). Improving Ancient Cham Glyph Recognition Using Data Augmentation and Transfer Learning. In International Conference on Image Analysis and Processing (ICIAP 2019 Workshops: PatReCH), Springer, Cham, LNCS 11808, pp. 115–125. DOI: 10.1007/978-3-030-30754-7_12
[4] Nguyen, T.-N. (2023). Segmentation, Recognition and Indexing of Cham characters in Cham documents (Segmentation, reconnaissance et indexation des caractères Cham dans les documents Cham). Ph.D. Dissertation, Université de La Rochelle, France.
[5] Nguyen, T.-N., Burie, J.-C., Le, T.-L., & Schweyer, A.-V. (2023). A Two-Step Sequence Transformer Based Method for Cham to Latin Script Transliteration. In Proceedings of the 7th International Workshop on Historical Document Imaging and Processing (HIP@ICDAR 2023), ACM, pp. 25–30. DOI: 10.1145/3604951.3605525
[6] Nguyen, T.-N., Burie, J.-C., Le, T.-L., & Schweyer, A.-V. (2022). An effective method for text line segmentation in historical document images. In 26th International Conference on Pattern Recognition (ICPR 2022), IEEE, pp. 2686–2692. DOI: 10.1109/ICPR56361.2022.9956617
[7] Nguyen, T.-N., Burie, J.-C., Le, T.-L., & Schweyer, A.-V. (2025). Text line segmentation approach combining deep learning model and traditional image processing techniques - application to transliteration of Cham manuscripts. Multimedia Tools and Applications, Springer. DOI: 10.1007/s11042-025-20602-x
[8] ANR CHAMDOC Project. (2019–2024). Cham Documentation (CHAMDOC), Project ANR-19-CE27-0018, Agence Nationale de la Recherche, France.
[9] Liao, M., Wan, Z., Yao, C., Chen, K., & Bai, X. (2020). Real-time Scene Text Detection with Differentiable Binarization. Proceedings of the AAAI Conference on Artificial Intelligence, 34(07), 11474–11481.
[10] Du, Y., Chen, Z., Jia, C., Yin, X., Zheng, T., Li, C., ... & Yu, K. (2023). PP-OCRv4: A Compact, Accurate and Practical Ultra-Lightweight OCR System. arXiv preprint arXiv:2309.09941.
[11] Du, Y., Chen, Z., Jia, C., Yin, X., Zheng, T., Li, C., ... & Yu, K. (2022). SVTR: Scene Text Recognition with a Single Visual Model. arXiv preprint arXiv:2205.00159.
[12] Graves, A., Fernández, S., Gomez, F., & Schmidhuber, J. (2006). Connectionist temporal classification: labelling unsegmented sequence data with recurrent neural networks. Proceedings of the 23rd International Conference on Machine Learning (ICML '06), 369–376.