Drag & drop manuscript image or click Upload Manuscript Image to begin
Supports direct clipboard image pasting (Ctrl+V)
Drag & drop manuscript image or click Upload Manuscript Image to begin
Supports direct clipboard image pasting (Ctrl+V)
Cham OCR Studio is an open-source, specialized paleographic transcription and diagnostic platform engineered specifically for the digitized preservation and optical character recognition of historical Cham manuscripts (comprising traditional Akhar Thrah of Eastern Cham and Cam Srak of Western Cham).
The Cham script belongs to the Brahmic family of Southern Indic scripts (descended historically from the Grantha and Pallava writing systems of ancient Champa). As an abugida, its visual and computational representation poses significant challenges:
U+AA00–U+AA5F) specifies 6 independent vowels (U+AA00–U+AA05: A, I, U, E, AI, O) and 35 consonants (U+AA06–U+AA28) possessing an inherent vowel (/a/ or /ɔ/), structured into low-tone (Dom) and high-tone (Dal) series.ꨳ (U+AA33: Medial Ya), ꨴ (U+AA34: Medial Ra), ꨵ (U+AA35: Medial La), and ꨶ (U+AA36: Medial Wa).ꨪ, ꨫ, ꨬ), below (ꨭ U, ꨲ UE), post-base right (ꨩ AA, ꨮ OE, ꨱ AU), or pre-base left (ꨯ O, ꨰ AI).U+AA40–U+AA4D, U+AA25]): Explicit codas with extended terminal strokes, combining coda marks (ꩃ Final Ng, ꩌ Final M, ꩍ Final H), and base consonant ꨥ (U+AA25: VA) serving as syllable-final consonant per Unicode Table 16-16.꩝ U+AA5D), Double Danda (꩞ U+AA5E), or Triple Danda (꩟ U+AA5F). Modern printed Cham publications frequently introduce word-level spacing.
Encoded in Unicode Standard 5.1 within the range U+AA00–U+AA5F, Cham text processing requires strict differentiation between visual rendering order and Brahmic Logical Order. The canonical storage sequence enforced in Cham OCR Studio is:
Historical palm-leaf and handmade paper manuscripts frequently exhibit undulating line trajectories, uneven inter-line spacing, and ink bleed-through. Cham OCR Studio employs a two-tier hybrid segmentation architecture:
Operates with an adaptive unclip ratio of 1.8. DBNet predicts a continuous probability map and adaptive threshold surface, outputting polygon boundaries that conform snugly to curvilinear text baselines while encompassing ascenders and descenders.
When deep detection yields ambiguous boundaries, a horizontal projection profile is generated across adaptive sliding windows. Valleys in projection intensity indicate candidate baseline cutpoints, combined with Connected Component Analysis (CCA) to prevent cutting across intersecting glyph stems.
difference_update): When establishing an erasing mask for neighboring lines, components belonging to the current textline are strictly excluded, eliminating stroke truncation.0.40 × median_line_height above and below the core band, clipped at 2px from adjacent textbands.0.35 × median_line_height and initial recognition confidence ≥ 0.75 bypass multi-pass deformation to prevent regression.The recognition engine leverages a customized SVTR-LCNet backbone optimized for high-density historical scripts:
[3, 48, 480] (expanded from 320px) to prevent spatial compression of dense character clusters and bilingual verses.Sequence prediction employs dual-head multi-task learning:
To resolve local model hallucinations where visual rendering order flips adjacent diacritics, the system applies an algorithmic Unicode cluster re-ordering stage (normalize_unicode):
Due to the extreme scarcity of annotated historical Cham ground truth, training data is synthetically synthesized with strict quality controls via scripts/generate_data.py:
| Dataset Bucket | Volume | Share | Target Paleographic Focus |
|---|---|---|---|
| Bucket 1: Classical Corpus | 70,000 | 50.0% | Po Klong Garai chronicles, epic poetry, palm-leaf folk literature |
| Bucket 2: Multilingual Code-Switching | 25,000 | 17.9% | Inline mixed Cham, Vietnamese, and Latin glosses/dates |
| Bucket 3: Verse Numerals & Section Marks | 25,000 | 17.9% | Numeral sequences 1–99 (꩑꩞..꩙꩙꩞), boundary punctuation (꩞, :, –) |
| Bucket 4: Adversarial Minimal Pairs | 20,000 | 14.3% | Hard pairs: ꨲ (U+AA32 UE) vs ꨶ (U+AA36 WA); variable-gap Double Danda ꩝꩝ |
fontTools inspects character maps before generation, discarding unsupported glyphs to prevent square placeholder (tofu) corruptions.surgery_v25_weights.py): Re-maps neural projection heads across expanding lexicons without shape mismatch.Performance quantitatively validated across a 50-test stratified benchmark and a controlled 200-page synthetic stress-test suite (903 textlines):
| Evaluation Category | V23 CER | V24 CER | Gain | V23 Pass | V24 Pass | V24 Conf |
|---|---|---|---|---|---|---|
| Cat 1: Clean Baseline | 14.84% | 6.20% | -8.64% | 20.0% | 80.0% | 0.958 |
| Cat 2: Single-Digit Stanzas | 18.42% | 11.71% | -6.71% | 0.0% | 40.0% | 0.944 |
| Cat 3: Two-Digit Stanzas | 17.59% | 7.65% | -9.94% | 20.0% | 60.0% | 0.956 |
| Cat 5: Blur Degradation | 41.78% | 35.56% | -6.22% | 0.0% | 0.0% | 0.839 |
| Cat 6: Noise & Grain | 50.59% | 8.82% | -41.77% | 0.0% | 80.0% | 0.944 |
| Cat 8: Tilt & Perspective | 22.14% | 0.71% | -21.43% | 0.0% | 100.0% | 0.982 |
| Overall Benchmark Average (50 Tests) | 28.17% | 13.88% | -14.29% | 4.0% | 50.0% | 0.923 |
| Difficulty Tier | Degradation Profile | Lines | Det Rate | Mean CER | Mean WER |
|---|---|---|---|---|---|
| Level 1: Standard | Rectilinear, standard gap 25–35px | 201 | 100.0% | 14.43% | 45.50% |
| Level 2: Aged Paper | Yellowed paper texture, mild noise | 189 | 100.0% | 14.44% | 45.86% |
| Level 3: Narrow Gap | Tight line spacing 8–14px, waviness | 170 | 100.0% | 12.77% | 43.52% |
| Level 4: Wavy Sinusoid | Sine wave amp 3–5.5px, gap 5–10px | 177 | 99.44% | 14.53% | 45.64% |
| Level 5: Extreme Overlap | Gap 2–6px < wave amp 5.5–8px (Breaking Point) | 166 | 61.45% | 60.02% | 77.63% |
| Total Suite Summary | 200 synthetic document images | 903 | 92.80% | 23.24% | 51.63% |
Evaluation across 10,000 frozen validation samples establishes Version 25 as the new production SOTA model (Sequence Accuracy 90.96%, Normalized Edit Distance 99.28%, CER 0.72%) following 40 epochs of multi-stage training on Dual Tesla T4x2 GPUs. Version 24 serves as the logical order baseline (Accuracy 88.94%), while Version 23 is maintained for legacy visual order comparison.
Character Error Rate (CER) computed as normalized Levenshtein edit distance: CER = (Substitutions + Deletions + Insertions) / Total Ground-Truth Characters.
Cham OCR Studio is architected for zero-latency, high-availability public access:
Packaged via a multi-stage Docker container deployed directly on Hugging Face Spaces (phucsd/cham-ocr-studio) and routed through Cloudflare to the official production domain: https://ocr.cham.asia.
np.sctypes, np.bool, and np.typeDict ensuring seamless operation under modern Python 3.13+ environments.All source code, training notebooks, synthetic generators, evaluation scripts, and model weights are publicly accessible under the MIT License: