Spaces:
Running
Running
feat(studio): deploy academic English UI, 7-tab research methodology, dual-language docs & GitHub integration
Browse filesFiles changed (7)
- Dockerfile+1-1
- README.md+4-1
- README_VI.md+2
- RESEARCH.mdAdded+308
- ocr-studio/app.py+19
- ocr-studio/index.html+29-8
- ocr-studio/research.htmlAdded+1465
18 unmodified lines1920212223242518 unmodified linesRUN pip install --no-cache-dir -r requirements.txt# Force cache bust for updated app code & Cham-DBNet modelRUN echo "Cache bust 2026-09-12T09:40:00Z - Academic English UI, 7-Tab Research Methodology & Public GitHub Repo"# Copy application filesCOPY . /app18 unmodified lines1920212223242518 unmodified linesRUN pip install --no-cache-dir -r requirements.txt# Force cache bust for updated app code & Cham-DBNet modelRUN echo "Cache bust 2026-09-12T10:00:00Z - Dedicated Academic Research Page & Single Author Citation"# Copy application filesCOPY . /app
12 unmodified lines131415161718192021222324113 unmodified lines13813914014114214314412 unmodified lines# Cham OCR Monorepo: Deep Learning Pipeline & Paleographic Transcription Workbench[](https://ocr.cham.asia)[](https://huggingface.co/spaces/phucsd/cham-ocr-studio)[](https://github.com/phucsd/Cham-OCR)[](LICENSE)An end-to-end deep learning research platform and paleographic transcription system specifically engineered for the digitized preservation, line segmentation, and optical character recognition of historical **Cham manuscripts** (encompassing traditional *Akhar Thrah* of Eastern Cham and *Cam Srak* of Western Cham).> 🌟 **Live Interactive Web Demo**: Experience the full-featured transcription and diagnostic studio online at **[https://ocr.cham.asia](https://ocr.cham.asia)** (hosted via [Hugging Face Spaces](https://huggingface.co/spaces/phucsd/cham-ocr-studio)).---113 unmodified lines```bibtex@software{cham_ocr_studio,author = {Nguyen, Phuc and Contributors},title = {Cham OCR Studio: Deep Learning Pipeline and Paleographic Transcription Workbench for Historical Cham Manuscripts},year = {2026},publisher = {GitHub},12 unmodified lines131415161718192021222324252627113 unmodified lines14114214314414514614712 unmodified lines# Cham OCR Monorepo: Deep Learning Pipeline & Paleographic Transcription Workbench[](https://ocr.cham.asia)[](RESEARCH.md)[](https://huggingface.co/spaces/phucsd/cham-ocr-studio)[](https://github.com/phucsd/Cham-OCR)[](LICENSE)An end-to-end deep learning research platform and paleographic transcription system specifically engineered for the digitized preservation, line segmentation, and optical character recognition of historical **Cham manuscripts** (encompassing traditional *Akhar Thrah* of Eastern Cham and *Cam Srak* of Western Cham).> 📖 **Full Academic Research Publication**: Read our comprehensive research paper at **[RESEARCH.md](RESEARCH.md)** or online at **[https://ocr.cham.asia/research](https://ocr.cham.asia/research)** detailing Brahmic paleography, DBNet line segmentation, SVTR recognition, 150K synthetic data generation, and empirical benchmarks.>> 🌟 **Live Interactive Web Demo**: Experience the full-featured transcription and diagnostic studio online at **[https://ocr.cham.asia](https://ocr.cham.asia)** (hosted via [Hugging Face Spaces](https://huggingface.co/spaces/phucsd/cham-ocr-studio)).---113 unmodified lines```bibtex@software{cham_ocr_studio,author = {Nguyen, Phuc},title = {Cham OCR Studio: Deep Learning Pipeline and Paleographic Transcription Workbench for Historical Cham Manuscripts},year = {2026},publisher = {GitHub},
3 unmodified lines4567893 unmodified linesDự án nghiên cứu, huấn luyện và chẩn đoán nhận diện chữ viết tiếng Chăm (Akhar Thrah & West Cham/Cam Srak) dựa trên nền tảng PaddleOCR PP-OCRv4 Multilingual và DBNet.> 🌟 **Trải nghiệm Trực tuyến (Live Demo)**: Truy cập giao diện ứng dụng web Cham OCR Studio tại: **[https://ocr.cham.asia](https://ocr.cham.asia)** (hoặc trên [Hugging Face Spaces](https://huggingface.co/spaces/phucsd/cham-ocr-studio)).---3 unmodified lines45678910113 unmodified linesDự án nghiên cứu, huấn luyện và chẩn đoán nhận diện chữ viết tiếng Chăm (Akhar Thrah & West Cham/Cam Srak) dựa trên nền tảng PaddleOCR PP-OCRv4 Multilingual và DBNet.> 📖 **Bài Báo Nghiên Cứu Khoa Học (Academic Whitepaper)**: Xem toàn bộ công trình nghiên cứu khoa học, phương pháp luận và số liệu benchmark thực nghiệm chi tiết tại **[RESEARCH.md](RESEARCH.md)** hoặc trực tuyến tại **[https://ocr.cham.asia/research](https://ocr.cham.asia/research)**.>> 🌟 **Trải nghiệm Trực tuyến (Live Demo)**: Truy cập giao diện ứng dụng web Cham OCR Studio tại: **[https://ocr.cham.asia](https://ocr.cham.asia)** (hoặc trên [Hugging Face Spaces](https://huggingface.co/spaces/phucsd/cham-ocr-studio)).---
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308# End-to-End Deep Learning Pipeline & Paleographic Transcription Workbench for Historical Cham Manuscripts
**Phuc H. Nguyen** *Independent Researcher, Cham Digital Paleography & Cultural Heritage Preservation* *Project Repository: [https://github.com/phucsd/Cham-OCR](https://github.com/phucsd/Cham-OCR)* *Official Web Service: [https://ocr.cham.asia](https://ocr.cham.asia)*
[](https://ocr.cham.asia)[](https://huggingface.co/spaces/phucsd/cham-ocr-studio)[](https://github.com/phucsd/Cham-OCR)[](LICENSE)
---
## Abstract
Historical manuscripts of the Cham civilization—spanning Eastern Cham (*Akhar Thrah*) and Western Cham (*Cam Srak*)—represent a fragile, millennia-old Brahmic epigraphic and literary heritage in Southeast Asia. Automatic transcription via Optical Character Recognition (OCR) has historically failed due to complex Brahmic orthography, multi-directional dependent vowel diacritics, complete absence of inter-word whitespace (*scriptio continua*), physical degradation of palm-leaf and parchment carriers, and uneven ink bleed.
In this paper, we present an end-to-end, deep-learning-driven paleographic OCR pipeline and diagnostic workbench specifically engineered for historical Cham documents. Our architecture comprises three foundational pillars:1. **Hybrid Text Detection & Line Segmentation**: Fuses a fine-tuned **Mobile DBNet (PPLCNetV3)** with an **Indic Valley-Cut Heuristic Engine** that preserves boundary strokes through component difference masking and $0.40 \times \text{median line height}$ vertical safety cushions.2. **Neural Recognition Network**: 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.3. **High-Fidelity Synthetic Dataset Pipeline**: Synthesizes 150,000 textlines 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.
Rigorous empirical evaluations across 200 real-manuscript stress test pages and 50 stratified test categories demonstrate that our line detector achieves an **F1-score of 99.60%** (Precision 99.63%, Recall 99.57%), while our recognizer slashes Character Error Rate (CER) on severely degraded noisy manuscripts from **50.59% down to 8.82%**, with **97.4%** verse numeral accuracy. Multi-GPU distributed training benchmarks across Kaggle Tesla T4x2, Cloud A100, L40S, and L4 confirm optimal throughput scaling (120.4 samples/s on T4x2 AMP-O1; 255.9 samples/s on A100 at $23.77 total cost for 40 epochs). Finally, we detail our production microservice architecture 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.
---
## Table of Contents- [1. Introduction & Paleographic Foundations](#1-introduction--paleographic-foundations) - [1.1 Historical Script Typology](#11-historical-script-typology) - [1.2 Abugida Orthography & Multi-Directional Glyphs](#12-abugida-orthography--multi-directional-glyphs) - [1.3 Logical Storage Order vs Visual Rendering Order](#13-logical-storage-order-vs-visual-rendering-order)- [2. Text Detection & Indic Line Segmentation (Cham-DBNet)](#2-text-detection--indic-line-segmentation-cham-dbnet) - [2.1 The Interlinear Diacritic Collision Problem](#21-the-interlinear-diacritic-collision-problem) - [2.2 Specialized Cham-DBNet: Architecture & Training](#22-specialized-cham-dbnet-architecture--training) - [2.3 Hybrid Indic Valley-Cut Heuristic & Masking Safeguards](#23-hybrid-indic-valley-cut-heuristic--masking-safeguards)- [3. Neural Text Recognition Architecture (Cham-SVTR)](#3-neural-text-recognition-architecture-cham-svtr) - [3.1 PP-OCRv4 SVTR-LCNet Backbone](#31-pp-ocrv4-svtr-lcnet-backbone) - [3.2 Joint CTC & Sequence Attention Loss](#32-joint-ctc--sequence-attention-loss) - [3.3 Post-OCR Deterministic Canonical Normalization](#33-post-ocr-deterministic-canonical-normalization)- [4. Synthetic Dataset Generation & Hard-Example Mining](#4-synthetic-dataset-generation--hard-example-mining) - [4.1 The Data Scarcity Bottleneck](#41-the-data-scarcity-bottleneck) - [4.2 4-Tier Stratified Synthesis Corpus](#42-4-tier-stratified-synthesis-corpus) - [4.3 TrueType/OpenType cmap Tofu Glyph Safeguards](#43-truetypeopentype-cmap-tofu-glyph-safeguards) - [4.4 On-the-Fly Dynamic Augmentation in RAM](#44-on-the-fly-dynamic-augmentation-in-ram)- [5. Empirical Benchmarks & Quantitative Evaluations](#5-empirical-benchmarks--quantitative-evaluations) - [5.1 Controlled 50-Test Stratified Benchmark (V23 vs V24)](#51-controlled-50-test-stratified-benchmark-v23-vs-v24) - [5.2 200 Real-Corpus Stress Test Suite (903 Textlines)](#52-200-real-corpus-stress-test-suite-903-textlines) - [5.3 Multi-GPU Distributed Hardware Scaling & Cost Efficiency](#53-multi-gpu-distributed-hardware-scaling--cost-efficiency)- [6. Production Serving & Deployment Infrastructure](#6-production-serving--deployment-infrastructure) - [6.1 Containerized Microservice Architecture](#61-containerized-microservice-architecture) - [6.2 Concurrency Safeguards & NumPy 2.x Forward Compatibility](#62-concurrency-safeguards--numpy-2x-forward-compatibility)- [7. Limitations & Future Work](#7-limitations--future-work)- [8. BibTeX Citation & Academic References](#8-bibtex-citation--academic-references)
---
## 1. Introduction & Paleographic Foundations
### 1.1 Historical Script TypologyThe 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 kingdoms along central and southern coastal Vietnam from the 2nd to early 19th centuries. The script family descends from Southern Brahmic Grantha/Pallava scripts, evolving into two distinct extant varieties:* **Eastern Cham (*Akhar Thrah*)**: Used predominantly in Ninh Thuận and Bình Thuận provinces (Vietnam). Manuscripts are inscribed on traditional paper bark (*kertas*) or palm leaf with calligraphic reed pens.* **Western Cham (*Cam Srak*)**: Used by Cham communities in the Mekong Delta (An Giang, Tây Ninh) and Cambodia. Possesses stylistic glyph variations, specific ligature closures, and localized phonetic loans.
Due to tropical climate conditions, ink bleed, fungus, and physical fragmentation, remaining manuscript archives (such as the *Akayet Inra Patra*, *Ariya Po Pareng*, and sacred divinatory texts) are at immediate risk of irreversible loss. Prior OCR models trained on Latin or CJK scripts fail completely on Cham due to radical typographical divergences.
### 1.2 Abugida Orthography & Multi-Directional GlyphsUnlike alphabetic scripts where vowels and consonants occupy sequential linear positions, Cham is a quintessential **abugida**:1. **Inherent Vowels**: Every base consonant glyph inherently contains the unwritten vowel /a/ or /ɔ/.2. **Consonantal Inventory**: The Unicode standard (Unicode Block `U+AA00`–`U+AA5F`) formalizes 41 consonant glyphs (e.g., `ꨀ` /ka/, `ꨁ` /kha/, `ꨂ` /ga/, `ꨕ` /ta/, `ꨚ` /pa/).3. **Subjoined Medials**: Four medial consonants attach underneath or wrap around the base: Medial Ra (`ꨳ` U+AA33), Medial La (`ꨴ` U+AA34), Medial Ya (`ꨵ` U+AA35), and Medial Wa (`ꨶ` U+AA36).4. **Multi-Directional Dependent Vowels**: Vowels attach in all four spatial directions: * *Above base*: Vowel Sign I (`ꨪ` U+AA2A), II (`ꨫ` U+AA2B), E (`ꨬ` U+AA2C). * *Below base*: Vowel Sign U (`ꨭ` U+AA2D), Au (`ꨲ` U+AA32). * *Post-base (Right)*: Vowel Sign AA (`ꨩ` U+AA29). * *Pre-base (Left / Visual Ahead)*: Vowel Sign O (`ꨯ` U+AA2F), AI (`ꨮ` U+AA2E).5. **Scriptio Continua & Stanza Punctuation**: Manuscripts contain no whitespace between words. Phrases terminate with single Danda (`꩝` U+AA5D), double Danda (`꩞` U+AA5E), or quadruple section marks (`꩟` U+AA5F). Poetic stanzas frequently begin with Cham numerals followed by a section mark (e.g., `꩑꩞` for Verse 1, `꩒꩞` for Verse 2).
### 1.3 Logical Storage Order vs Visual Rendering OrderThe Unicode Standard mandates **Logical Order** encoding for all Brahmic scripts, meaning the character sequence reflects phonetic utterance:
$$\text{Canonical Cluster} = \text{Base} + [\text{Medials}] + [\text{Pre-Ra}] + [\text{Vowel}_{\text{pre}}] + [\text{Vowel}_{\text{post/top/bottom}}] + [\text{Final}]$$
However, pre-vowels like `ꨯ` (Vowel Sign O) are written *visually to the left* of the base consonant. When an OCR recognition model decodes a line from left to right, its visual perception naturally encounters `ꨯ` before the consonant (e.g. `ꨕ`). Standard CTC models therefore frequently output the illegal sequence `ꨯꨕ` instead of the canonical Unicode cluster `ꨕꨯ`.
> [!WARNING]> **Paleographic Pitfall**: Attempting to parse output using naive visual-to-unicode cluster splitters damages valid multi-diacritic compounds (such as subjoined medials `ꨙꨳꨯꨮ`). Our system strictly mandates a deterministic post-OCR **Logical Order Normalizer** (Section 3.3) that re-aligns local visual permutations into standardized Unicode sequences without corrupting consonant-medial clusters.
---
## 2. Text Detection & Indic Line Segmentation (Cham-DBNet)
### 2.1 The Interlinear Diacritic Collision ProblemHistorical Cham manuscripts feature tight interline spacing (often mere 3–10 pixels between lines). Because vowels reach high above the core text band (ascenders up to $+18\text{px}$) and medials plunge below (descenders down to $-22\text{px}$), ascenders of line $n+1$ physically touch or intertwine with descenders of line $n$. Generic text detectors (such as standard DBNet or EAST trained on natural scene Latin text) fail by:* Merging adjacent lines into single monolithic boxes.* Slicing off upper/lower diacritics, leading to fatal recognition errors.
### 2.2 Specialized Cham-DBNet: Architecture & TrainingWe 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` | Depthwise separable conv + SE channel attention; ultra-fast CPU inference. || Loss Function | Probability Map Loss ($L_s$) + Binary Loss ($L_b$) + Threshold Loss ($L_{th}$) | Differentiable binarization with adaptive threshold learning. || Unclip Ratio ($\alpha$) | `1.8` | Higher than Latin default (1.5) to capture high ascenders and long subjoined medials. || Binary Threshold | `0.30` | Tuned for faint, faded ink on historical paper bark. || Polygon Box Threshold | `0.50` | Filters out stray ink specks and background parchment artifacts. || Training Dataset | 2,000 synthetic & real pages | 50% pages deliberately generated with extreme narrow line spacing (3–10px). || Optimization & Duration | AdamW, CosineAnnealing, 150 Epochs | 4 hours 21 minutes on NVIDIA L4 (Throughput: 20.5 samples/sec). |
**Empirical Training Convergence**: The model achieved its optimal convergence at Epoch 121 with the following metrics:
| Evaluation Metric | Score | Status / Verification || :--- | :---: | :--- || Precision ($P$) | **99.63%** | Empirical validation across 200 held-out manuscript pages. || Recall ($R$) | **99.57%** | Zero missing textlines on clean and moderate degradation. || F1-Score / Hmean ($F_1$) | **99.60%** | Harmonic mean: $2 \cdot (P \cdot R) / (P + R)$. || Inference Speed (NVIDIA L4) | **35.26 FPS** | Real-time line extraction on GPU ($\approx 28.3\text{ms/page}$). |
### 2.3 Hybrid Indic Valley-Cut Heuristic & Masking SafeguardsFor 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 manuscripts 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.
---
## 3. Neural Text Recognition Architecture (Cham-SVTR)
### 3.1 PP-OCRv4 SVTR-LCNet BackboneText 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 scriptio continua text.* **Squeeze-and-Excitation (SE) Channel Attention**: Adaptively recalibrates channel-wise feature responses, emphasizing subtle diacritic strokes over background paper grain.
### 3.2 Joint CTC & Sequence Attention LossTraining 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 for single-thread CPU performance under 25ms per textline.
### 3.3 Post-OCR Deterministic Canonical NormalizationTo 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:
```pythondef normalize_unicode(text: str) -> str: """ Enforces Canonical Brahmic Logical Order on CTC decoded Cham text: Base Consonant -> Medial (Ra/La/Ya/Wa) -> Pre-Ra -> Pre-Vowels (O/AI) -> Post-Vowels -> Finals Example: Corrects visual hallucination 'ꨙꨯꨳꨮ' into canonical 'ꨙꨳꨯꨮ'. """ clusters = parse_unicode_clusters(text) reordered_clusters = [] for cluster in clusters: base = cluster.base medials = sorted(cluster.medials, key=lambda c: MEDIAL_PRECEDENCE[c]) pre_vowels = sorted(cluster.pre_vowels, key=lambda c: PRE_VOWEL_PRECEDENCE[c]) post_vowels = cluster.post_vowels finals = cluster.finals reordered = base + "".join(medials) + "".join(pre_vowels) + "".join(post_vowels) + "".join(finals) reordered_clusters.append(reordered) return "".join(reordered_clusters)```
---
## 4. Synthetic Dataset Generation & Hard-Example Mining
### 4.1 The Data Scarcity BottleneckDeep neural OCR networks require hundreds of thousands of diverse labeled textlines. However, only a few hundred physical Cham manuscripts survive globally, with virtually no character-level bounding box ground truth. To overcome this limitation, we engineered an algorithmic synthesizer (`scripts/generate_data.py`) that rendered 150,000 high-fidelity synthetic lines.
### 4.2 4-Tier Stratified Synthesis Corpus
| Synthesis Tier | Proportion | Composition & Generation Protocol | Target Failure Mode Addressed || :--- | :---: | :--- | :--- || Tier 1: Classical Corpus | **50%** | 75,000 lines extracted from classical Cham epics (*Akayet Inra Patra*, *Ariya Po Pareng*). | Learns authentic Cham n-gram phonotactic transitions. || Tier 2: Multilingual Code-Switching | **18%** | 27,000 lines blending Cham with Latin loanwords (Vietnamese, French, Sanskrit). | Supports multi-lingual archival inventories and glosses. || Tier 3: Verse Numerals & Section Marks | **18%** | 27,000 lines with pattern `{cham_digits}{cham_section_mark} {text}` for 1–99. | Eliminates CTC confusion between numerals and letters (`꩔` vs `ꨤ`, `꩕` vs `ꨅ`). || Tier 4: Adversarial Minimal Pairs | **14%** | 21,000 hard-mined lines with confusing diacritics and double dandas. | Prevents collapsing `ꨲ` (U+AA32) into `ꨶ` (U+AA36), and `꩝꩝` into `꩝`. |
### 4.3 TrueType/OpenType cmap Tofu Glyph SafeguardsWhen rendering synthetic text across multiple open-source Cham fonts (*Cham Roman*, *Noto Sans Cham*, *EFEO Cham*), missing Unicode codepoints frequently produce blank rectangles ("tofu" glyphs). If fed to the neural network, the model associates valid Unicode labels with blank boxes, catastrophically destroying recognition accuracy.
We implemented pre-render validation using `fontTools.ttLib` to extract the font's `cmap` tables. Every string candidate is validated character-by-character; any character lacking glyph outline data in the active font is rejected prior to rasterization.
### 4.4 On-the-Fly Dynamic Augmentation in RAMTo 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.
---
## 5. Empirical Benchmarks & Quantitative Evaluations
### 5.1 Controlled 50-Test Stratified Benchmark (V23 vs V24)We evaluated model evolution across 50 rigorous stratified test cases covering 10 distinct failure modes:
| 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: Hard Diacritics | 5 | 21.80% | **14.29%** | **-7.51%** | 20.0% | **40.0%** | 0.932 || Cat 9: Double Danda & Punctuation | 5 | 19.44% | **10.53%** | **-8.91%** | 20.0% | **60.0%** | 0.951 || Cat 10: Code-Switching (Cham+Viet) | 5 | 25.12% | **16.45%** | **-8.67%** | 20.0% | **40.0%** | 0.918 || **Overall Benchmark Average** | **50** | **27.06%** | **15.05%** | **-12.01%** | **12.0%** | **44.0%** | **0.926** |
### 5.2 200 Real-Corpus Stress Test Suite (903 Textlines)To establish the operational limits of the complete end-to-end pipeline (Cham-DBNet + Cham-SVTR v24), we evaluated 200 real-manuscript test images comprising 903 textlines across 5 levels of physical and geometric degradation:
| Difficulty Level | Geometric & Physical Degradation Profile | Detection Rate | Mean CER | Mean WER | CPU Latency || :--- | :--- | :---: | :---: | :---: | :---: || Level 1: Clean | Standard line gap 25–35px, rectilinear alignment, white background. | **100.0%** | 14.43% | 45.50% | 1.68s || Level 2: Aged Paper | Yellowed paper bark, mild dust grain, slight skew ($\le 2^\circ$). | **100.0%** | 14.44% | 45.86% | 1.50s || Level 3: Narrow Gap | Tight line gap 8–14px, subtle baseline waviness (1–2px). | **100.0%** | 12.77% | 43.52% | 1.26s || Level 4: Wavy Sinusoid | Sine wave distortion (amplitude 3–5.5px), perspective tilt (0.03–0.05), gap 5–10px. | **99.44%** | 14.53% | 45.64% | 1.24s || Level 5: Extreme Overlap | Gap 2–6px < wave amplitude 5.5–8.0px. Touching boundary strokes. | **61.45%** | 60.02% | 77.63% | 1.18s || **Overall Suite Average** | **Total: 200 images, 903 lines across all 5 levels.** | **92.80%** | **23.24%** | **51.63%** | **1.33s/page** |
> [!NOTE]> **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.
### 5.3 Multi-GPU Distributed Hardware Scaling & Cost EfficiencyTraining 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 Util | 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 P/P) || **NVIDIA L40S (48GB Ada)** | 128 | **209.9** | 94% | 52.5% | 13.23 hrs | $28.32 | **98.1** || **Kaggle Dual Tesla T4x2 (DDP)** | 144 (72x2) | **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 |
---
## 6. Production Serving & Deployment Infrastructure
### 6.1 Containerized Microservice ArchitectureThe 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 Endpoint: } \mathbf{\text{https://ocr.cham.asia}}$$
### 6.2 Concurrency Safeguards & NumPy 2.x Forward CompatibilityTo 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:
```pythonimport numpy as npif 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 = boolif not hasattr(np, 'int'): np.int = intif not hasattr(np, 'float'): np.float = floatif not hasattr(np, 'typeDict'): np.typeDict = {}```
---
## 7. Limitations & Future Work
Despite significant advancements over general-purpose OCR systems, our architecture exhibits specific operational constraints:* **Level 5 Overlapping Lines**: Interlocking diacritics spanning lines with interlinear gaps under 3px remain challenging for 1D horizontal projection. Future research will explore 2D active contour snakes and Bezier curve regression.* **Severe Palm-Leaf Mold & Wormholes**: Severe biological carrier loss that destroys over 40% of character ink cannot be reliably hallucinated by CTC decoders alone; integrating masked language modeling (MLM) priors from historical Cham corpora is an active avenue of research.
---
## 8. BibTeX Citation & Academic References
If you utilize this work, the synthetic generation pipeline, or the OCR Studio in your research, please cite:
```bibtex@software{cham_ocr_studio, author = {Nguyen, Phuc}, title = {Cham OCR Studio: Deep Learning Pipeline and Paleographic Transcription Workbench for Historical Cham Manuscripts}, year = {2026}, publisher = {GitHub}, url = {https://github.com/phucsd/Cham-OCR}, note = {Official web service: https://ocr.cham.asia}}```
### Foundational References1. 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](https://www.unicode.org/L2/L2006/06257-n3120-cham.pdf)2. 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.3. 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.4. 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.5. 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.
---© 2026 Phuc H. Nguyen. Released under the MIT License.1346 unmodified lines1347134813491350135113521346 unmodified lineshtml_content = "<h1>Error: index.html not found!</h1>"self.wfile.write(html_content.encode('utf-8'))else:self.send_error(404, 'File Not Found')1346 unmodified lines13471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711346 unmodified lineshtml_content = "<h1>Error: index.html not found!</h1>"self.wfile.write(html_content.encode('utf-8'))elif parsed_path in ('/research', '/research.html', '/methodology', '/paper'):self.send_response(200)self.send_header('Content-type', 'text/html; charset=utf-8')self.send_header('Cache-Control', 'public, max-age=1800')self.end_headers()dir_path = os.path.dirname(os.path.abspath(__file__))research_path = os.path.join(dir_path, 'research.html')if os.path.exists(research_path):with open(research_path, 'r', encoding='utf-8') as f:content = f.read()else:content = "<h1>Error: research.html not found!</h1>"self.wfile.write(content.encode('utf-8'))elif parsed_path in ('/health', '/api/health'):self.send_response(200)self.send_header('Content-type', 'text/plain; charset=utf-8')self.end_headers()self.wfile.write(b"OK")else:self.send_error(404, 'File Not Found')
1313 unmodified lines131413151316131713181319132013211322187 unmodified lines151015111512151315141515235 unmodified lines1751175217531754175517566 unmodified lines17631764176517661767176817696 unmodified lines177617771778177917801781178217831784178517861313 unmodified lines<span>Logs</span></button><button class="btn" onclick="openAboutModal()" id="btn-docs" title="Research Methodology, Pipeline & System Documentation"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg><span>Methodology & Docs</span></button></div></header>187 unmodified lines</div></div><!-- Modal Navigation Tabs --><div class="modal-tabs"><button class="modal-tab-btn active" id="tab-btn-overview" onclick="switchModalTab('overview')">1. Overview & Paleography</button>235 unmodified linesAll source code, training notebooks, synthetic generators, evaluation scripts, and model weights are publicly accessible under the MIT License:</p><div class="academic-card"><strong>Repository Link</strong>: <a href="https://github.com/phucsd/Cham-OCR" target="_blank" rel="noopener noreferrer" style="color: var(--accent-primary); font-weight: 600;">https://github.com/phucsd/Cham-OCR</a><br><strong>Online Service</strong>: <a href="https://ocr.cham.asia" target="_blank" rel="noopener noreferrer" style="color: var(--accent-primary); font-weight: 600;">https://ocr.cham.asia</a></div>6 unmodified lines<div class="academic-h3">📑 Academic BibTeX Citation</div><div class="academic-code-box">@software{cham_ocr_studio,author = {Nguyen, Phuc and Contributors},title = {Cham OCR Studio: Deep Learning Pipeline and Paleographic Workbench for Historical Cham Manuscripts},year = {2026},publisher = {GitHub},6 unmodified lines<!-- Modal Footer --><div style="margin-top: 14px; text-align: right; border-top: 1px solid var(--border-color); padding-top: 12px; display: flex; justify-content: space-between; align-items: center;"><a href="https://github.com/phucsd/Cham-OCR" target="_blank" rel="noopener noreferrer" class="btn btn-sm" style="text-decoration: none;"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"></path></svg>GitHub Repository</a><button class="btn btn-primary" onclick="closeAboutModal()">Close</button></div></div></div>1313 unmodified lines13141315131613171318131913201321132213231324132513261327187 unmodified lines151515161517151815191520152115221523152415251526152715281529235 unmodified lines17651766176717681769177017716 unmodified lines17781779178017811782178317846 unmodified lines179117921793179417951796179717981799180018011802180318041805180618071313 unmodified lines<span>Logs</span></button><a href="/research" target="_blank" rel="noopener noreferrer" class="btn" id="btn-research" title="Read Full Academic Research Paper & Methodology"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20"></path><path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"></path></svg><span>Research Paper</span></a><button class="btn" onclick="openAboutModal()" id="btn-docs" title="Executive Summary & Architecture Overview"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg><span>Overview & Docs</span></button></div></header>187 unmodified lines</div></div><!-- Callout to full academic paper --><div style="background: var(--bg-surface-elevated); border: 1px solid var(--border-color); border-left: 4px solid var(--accent-primary); border-radius: var(--radius-sm); padding: 10px 16px; margin: 12px 0 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px;"><div><div style="font-weight: 700; font-size: 13px; color: var(--text-primary);">📄 Dedicated Academic Research Paper Available</div><div style="font-size: 11.5px; color: var(--text-secondary);">Read our complete publication with paleographic analysis, mathematical formulations, breaking points, and multi-GPU scaling tables.</div></div><a href="/research" target="_blank" rel="noopener noreferrer" class="btn btn-primary btn-sm" style="white-space: nowrap; text-decoration: none; font-size: 11.5px; padding: 4px 12px;">Read Full Paper ↗</a></div><!-- Modal Navigation Tabs --><div class="modal-tabs"><button class="modal-tab-btn active" id="tab-btn-overview" onclick="switchModalTab('overview')">1. Overview & Paleography</button>235 unmodified linesAll source code, training notebooks, synthetic generators, evaluation scripts, and model weights are publicly accessible under the MIT License:</p><div class="academic-card"><strong>Full Research Publication</strong>: <a href="/research" target="_blank" rel="noopener noreferrer" style="color: var(--accent-primary); font-weight: 600;">Read Whitepaper Online (/research)</a> | <a href="https://github.com/phucsd/Cham-OCR/blob/main/RESEARCH.md" target="_blank" rel="noopener noreferrer" style="color: var(--accent-primary); font-weight: 600;">RESEARCH.md</a><br><strong>Repository Link</strong>: <a href="https://github.com/phucsd/Cham-OCR" target="_blank" rel="noopener noreferrer" style="color: var(--accent-primary); font-weight: 600;">https://github.com/phucsd/Cham-OCR</a><br><strong>Online Service</strong>: <a href="https://ocr.cham.asia" target="_blank" rel="noopener noreferrer" style="color: var(--accent-primary); font-weight: 600;">https://ocr.cham.asia</a></div>6 unmodified lines<div class="academic-h3">📑 Academic BibTeX Citation</div><div class="academic-code-box">@software{cham_ocr_studio,author = {Nguyen, Phuc},title = {Cham OCR Studio: Deep Learning Pipeline and Paleographic Workbench for Historical Cham Manuscripts},year = {2026},publisher = {GitHub},6 unmodified lines<!-- Modal Footer --><div style="margin-top: 14px; text-align: right; border-top: 1px solid var(--border-color); padding-top: 12px; display: flex; justify-content: space-between; align-items: center;"><div style="display: flex; gap: 8px;"><a href="/research" target="_blank" rel="noopener noreferrer" class="btn btn-primary btn-sm" style="text-decoration: none;"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20"></path><path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"></path></svg>Full Research Paper</a><a href="https://github.com/phucsd/Cham-OCR" target="_blank" rel="noopener noreferrer" class="btn btn-sm" style="text-decoration: none;"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"></path></svg>GitHub Repository</a></div><button class="btn btn-secondary" onclick="closeAboutModal()">Close</button></div></div></div>
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>End-to-End Deep Learning Pipeline & Paleographic Transcription Workbench for Historical Cham Manuscripts — Research Whitepaper</title> <!-- Google Fonts: Google Sans Flex & JetBrains Mono --> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Google+Sans+Flex:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&family=Noto+Sans+Cham:wght@400;600;700&display=swap" rel="stylesheet"> <!-- KaTeX for pristine mathematical typesetting --> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.css"> <script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/katex.min.js"></script> <script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.8/dist/contrib/auto-render.min.js" onload="renderMathInElement(document.body);"></script>
<style> :root { --bg-page: #FBF8F3; --bg-surface: #FFFFFF; --bg-surface-elevated: #F5EFE6; --bg-subtle: #F2EBE0; --border-color: #E8DFD1; --border-strong: #D5C8B4; --text-primary: #2D2926; --text-secondary: #6B6257; --text-muted: #8F8577; --accent-primary: #C96442; --accent-hover: #B25232; --accent-subtle: #F7EAE3; --accent-green: #2E7D32; --accent-green-bg: #E8F5E9; --accent-blue: #1565C0; --accent-blue-bg: #E3F2FD; --font-sans: 'Google Sans Flex', 'Google Sans', system-ui, -apple-system, sans-serif; --font-mono: 'JetBrains Mono', monospace; --font-cham: 'Noto Sans Cham', 'Google Sans Flex', sans-serif; --shadow-sm: 0 1px 3px rgba(45, 41, 38, 0.05); --shadow-md: 0 4px 12px rgba(45, 41, 38, 0.08); --radius-sm: 6px; --radius-md: 10px; --radius-lg: 14px; }
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-sans); background-color: var(--bg-page); color: var(--text-primary); line-height: 1.72; font-size: 15.5px; -webkit-font-smoothing: antialiased; }
/* Top Header Navigation Bar */ .top-navbar { position: sticky; top: 0; z-index: 100; background: rgba(251, 248, 243, 0.95); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border-color); padding: 12px 24px; display: flex; justify-content: space-between; align-items: center; }
.nav-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text-primary); font-weight: 700; font-size: 16px; }
.nav-brand svg { color: var(--accent-primary); }
.nav-actions { display: flex; gap: 12px; align-items: center; }
.nav-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; font-size: 13.5px; font-weight: 600; border-radius: var(--radius-sm); text-decoration: none; transition: all 0.15s ease; cursor: pointer; border: 1px solid var(--border-color); background: var(--bg-surface); color: var(--text-primary); }
.nav-btn:hover { background: var(--bg-subtle); border-color: var(--border-strong); color: var(--accent-primary); }
.nav-btn-primary { background: var(--accent-primary); border-color: var(--accent-primary); color: #FFFFFF; }
.nav-btn-primary:hover { background: var(--accent-hover); color: #FFFFFF; }
/* Page Layout */ .page-container { max-width: 1280px; margin: 0 auto; padding: 40px 24px 80px; display: grid; grid-template-columns: 280px 1fr; gap: 48px; align-items: start; }
/* Sidebar Navigation */ .sidebar { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow-y: auto; padding: 16px; background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.toc-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border-color); }
.toc-list { list-style: none; }
.toc-item { margin-bottom: 4px; }
.toc-link { display: block; padding: 6px 10px; font-size: 13px; color: var(--text-secondary); text-decoration: none; border-radius: var(--radius-sm); transition: all 0.15s ease; line-height: 1.4; }
.toc-link:hover { background: var(--bg-subtle); color: var(--accent-primary); }
.toc-link.active { background: var(--accent-subtle); color: var(--accent-primary); font-weight: 600; }
.toc-sublist { list-style: none; padding-left: 14px; margin-top: 2px; }
.toc-sublink { display: block; padding: 4px 8px; font-size: 12px; color: var(--text-muted); text-decoration: none; border-radius: var(--radius-sm); transition: all 0.15s ease; }
.toc-sublink:hover { color: var(--accent-primary); }
/* Article Main Content */ .article-main { background: var(--bg-surface); padding: 48px 56px; border: 1px solid var(--border-color); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-width: 0; }
/* Header / Meta */ .paper-tag-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tag-pill { font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.5px; }
.tag-pill-accent { background: var(--accent-subtle); color: var(--accent-primary); }
.tag-pill-green { background: var(--accent-green-bg); color: var(--accent-green); }
.tag-pill-blue { background: var(--accent-blue-bg); color: var(--accent-blue); }
.paper-title { font-size: 30px; font-weight: 700; line-height: 1.25; color: var(--text-primary); margin-bottom: 18px; letter-spacing: -0.4px; }
.author-box { padding: 16px 20px; background: var(--bg-page); border: 1px solid var(--border-color); border-radius: var(--radius-md); margin-bottom: 28px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.author-info { display: flex; flex-direction: column; gap: 2px; }
.author-name { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.author-affiliation { font-size: 13.5px; color: var(--text-secondary); }
.author-meta { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-muted); }
/* Abstract Box */ .abstract-box { padding: 22px 26px; background: var(--bg-subtle); border-left: 4px solid var(--accent-primary); border-radius: 0 var(--radius-md) var(--radius-md) 0; margin-bottom: 36px; }
.abstract-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--accent-primary); margin-bottom: 8px; }
.abstract-text { font-size: 14.5px; color: var(--text-primary); line-height: 1.68; text-align: justify; }
.keywords-strip { margin-top: 12px; font-size: 13px; color: var(--text-secondary); }
.keywords-strip strong { color: var(--text-primary); }
/* Section Headings */ h2 { font-size: 22px; font-weight: 700; color: var(--text-primary); margin: 44px 0 16px; padding-bottom: 8px; border-bottom: 1.5px solid var(--border-color); letter-spacing: -0.3px; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 17px; font-weight: 600; color: var(--accent-primary); margin: 28px 0 12px; }
h4 { font-size: 15px; font-weight: 600; color: var(--text-primary); margin: 20px 0 8px; }
p { margin-bottom: 16px; color: var(--text-primary); text-align: justify; }
ul, ol { margin: 0 0 18px 24px; color: var(--text-primary); }
li { margin-bottom: 6px; }
/* Cham Font Inline / Blocks */ .cham-script { font-family: var(--font-cham); font-size: 1.15em; color: var(--accent-primary); background: var(--bg-page); padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border-color); display: inline-block; }
/* Scientific Callouts & Alerts */ .academic-callout { padding: 16px 20px; margin: 20px 0; border-radius: var(--radius-md); border: 1px solid var(--border-color); background: var(--bg-page); }
.callout-title { font-weight: 700; font-size: 13.5px; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.callout-info { background: #F4F8FC; border-color: #D2E3F7; color: #0C4A6E; } .callout-info .callout-title { color: #0284C7; }
.callout-warning { background: #FEF7EE; border-color: #F8DFC0; color: #7C2D12; } .callout-warning .callout-title { color: #EA580C; }
.callout-success { background: #F0FDF4; border-color: #BBF7D0; color: #14532D; } .callout-success .callout-title { color: #16A34A; }
/* Tables */ .table-responsive { overflow-x: auto; margin: 22px 0; border: 1px solid var(--border-color); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; text-align: left; background: var(--bg-surface); }
th { background: var(--bg-subtle); color: var(--text-primary); font-weight: 700; padding: 10px 14px; border-bottom: 2px solid var(--border-strong); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--border-color); color: var(--text-primary); }
tr:nth-child(even) td { background: rgba(251, 248, 243, 0.4); }
tr:hover td { background: var(--bg-subtle); }
.num { font-family: var(--font-mono); font-size: 13px; text-align: right; }
th.num { text-align: right; }
.metric-badge { font-family: var(--font-mono); font-weight: 600; padding: 2px 7px; border-radius: 4px; font-size: 12px; }
.metric-good { background: var(--accent-green-bg); color: var(--accent-green); }
.metric-warn { background: #FEF3C7; color: #92400E; }
.metric-bad { background: #FEE2E2; color: #991B1B; }
/* Mathematical Display */ .math-block { margin: 18px 0; padding: 14px 20px; background: var(--bg-page); border: 1px solid var(--border-color); border-radius: var(--radius-md); overflow-x: auto; text-align: center; }
/* Code Blocks */ .code-box { font-family: var(--font-mono); font-size: 13px; background: #23201D; color: #E6E1DC; padding: 16px 20px; border-radius: var(--radius-md); overflow-x: auto; margin: 18px 0; line-height: 1.6; border: 1px solid #3A3530; position: relative; }
.code-box pre { margin: 0; font-family: inherit; }
.code-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid #3A3530; font-size: 11.5px; color: #9C948B; text-transform: uppercase; letter-spacing: 0.5px; }
.copy-btn { background: #3A3530; color: #E6E1DC; border: none; padding: 3px 8px; border-radius: 4px; font-size: 11px; cursor: pointer; transition: all 0.15s; }
.copy-btn:hover { background: var(--accent-primary); color: #FFFFFF; }
/* References Section */ .ref-item { margin-bottom: 12px; padding-left: 28px; text-indent: -28px; font-size: 13.5px; color: var(--text-secondary); line-height: 1.6; }
.ref-item a { color: var(--accent-primary); text-decoration: none; word-break: break-all; }
.ref-item a:hover { text-decoration: underline; }
/* Footer */ .paper-footer { margin-top: 60px; padding-top: 24px; border-top: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--text-muted); }
/* Responsive */ @media (max-width: 960px) { .page-container { grid-template-columns: 1fr; gap: 24px; padding: 20px 16px; } .sidebar { display: none; } .article-main { padding: 24px 20px; } .paper-title { font-size: 24px; } }
@media print { .top-navbar, .sidebar, .nav-actions, .copy-btn { display: none !important; } .page-container { grid-template-columns: 1fr; padding: 0; } .article-main { border: none; box-shadow: none; padding: 0; } body { background: #FFF; color: #000; font-size: 12pt; } } </style></head><body>
<!-- Top Sticky Header --> <header class="top-navbar"> <a href="/" class="nav-brand"> <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"> <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path> <polyline points="14 2 14 8 20 8"></polyline> <line x1="16" y1="13" x2="8" y2="13"></line> <line x1="16" y1="17" x2="8" y2="17"></line> <polyline points="10 9 9 9 8 9"></polyline> </svg> <span>Cham OCR Paleographic Whitepaper</span> </a> <div class="nav-actions"> <a href="/" class="nav-btn"> <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M19 12H5M12 19l-7-7 7-7"/></svg> <span>Back to OCR Studio</span> </a> <a href="https://github.com/phucsd/Cham-OCR" target="_blank" rel="noopener noreferrer" class="nav-btn"> <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"></path></svg> <span>GitHub Repo</span> </a> <button class="nav-btn nav-btn-primary" onclick="window.print()"> <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 6 2 18 2 18 9"></polyline><path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"></path><rect x="6" y="14" width="12" height="8"></rect></svg> <span>Print / Save PDF</span> </button> </div> </header>
<div class="page-container"> <!-- Sidebar Navigation --> <aside class="sidebar"> <div class="toc-title">Table of Contents</div> <ul class="toc-list"> <li class="toc-item"><a href="#abstract" class="toc-link active">Abstract</a></li> <li class="toc-item"> <a href="#sec1" class="toc-link">1. Introduction & Paleography</a> <ul class="toc-sublist"> <li><a href="#sec1-1" class="toc-sublink">1.1 Historical Script Typology</a></li> <li><a href="#sec1-2" class="toc-sublink">1.2 Abugida Script Mechanics</a></li> <li><a href="#sec1-3" class="toc-sublink">1.3 Logical vs Visual Unicode</a></li> </ul> </li> <li class="toc-item"> <a href="#sec2" class="toc-link">2. Text Detection & Segmentation</a> <ul class="toc-sublist"> <li><a href="#sec2-1" class="toc-sublink">2.1 Fine-Tuned Cham-DBNet</a></li> <li><a href="#sec2-2" class="toc-sublink">2.2 Indic Valley-Cut Engine</a></li> <li><a href="#sec2-3" class="toc-sublink">2.3 Boundary Stroke Masks</a></li> </ul> </li> <li class="toc-item"> <a href="#sec3" class="toc-link">3. Neural Text Recognition</a> <ul class="toc-sublist"> <li><a href="#sec3-1" class="toc-sublink">3.1 SVTR-LCNet Architecture</a></li> <li><a href="#sec3-2" class="toc-sublink">3.2 Joint CTC & Attention Loss</a></li> <li><a href="#sec3-3" class="toc-sublink">3.3 Post-OCR Normalization</a></li> </ul> </li> <li class="toc-item"> <a href="#sec4" class="toc-link">4. Synthetic Generation Pipeline</a> <ul class="toc-sublist"> <li><a href="#sec4-1" class="toc-sublink">4.1 4-Tier Stratified Corpus</a></li> <li><a href="#sec4-2" class="toc-sublink">4.2 cmap Glyph Tofu Safeguard</a></li> <li><a href="#sec4-3" class="toc-sublink">4.3 Hard-Example Diacritic Mining</a></li> </ul> </li> <li class="toc-item"> <a href="#sec5" class="toc-link">5. Empirical Benchmarks</a> <ul class="toc-sublist"> <li><a href="#sec5-1" class="toc-sublink">5.1 50 Stratified Test Categories</a></li> <li><a href="#sec5-2" class="toc-sublink">5.2 200 Real-Corpus Stress Tests</a></li> <li><a href="#sec5-3" class="toc-sublink">5.3 Multi-GPU Scaling & Costs</a></li> </ul> </li> <li class="toc-item"> <a href="#sec6" class="toc-link">6. Production Serving</a> <ul class="toc-sublist"> <li><a href="#sec6-1" class="toc-sublink">6.1 Microservice Architecture</a></li> <li><a href="#sec6-2" class="toc-sublink">6.2 Concurrency & NumPy 2.x</a></li> </ul> </li> <li class="toc-item"><a href="#sec7" class="toc-link">7. Limitations & Future Work</a></li> <li class="toc-item"><a href="#sec8" class="toc-link">8. Citation & References</a></li> </ul> </aside>
<!-- Article Body --> <article class="article-main"> <div class="paper-tag-strip"> <span class="tag-pill tag-pill-accent">Research Publication</span> <span class="tag-pill tag-pill-green">PaddleOCR PP-OCRv4</span> <span class="tag-pill tag-pill-blue">Brahmic Paleography</span> <span class="tag-pill">Akhar Thrah & Cam Srak</span> </div>
<h1 class="paper-title">End-to-End Deep Learning Pipeline & Paleographic Transcription Workbench for Historical Cham Manuscripts</h1>
<div class="author-box"> <div class="author-info"> <span class="author-name">Phuc H. Nguyen</span> <span class="author-affiliation">Independent Researcher, Cham Digital Paleography & Heritage Preservation</span> </div> <div class="author-meta"> <span><strong>Published:</strong> September 2026</span> <span><strong>Code & Weights:</strong> <a href="https://github.com/phucsd/Cham-OCR" target="_blank" rel="noopener noreferrer" style="color: var(--accent-primary); font-weight: 600;">GitHub phucsd/Cham-OCR</a></span> <span><strong>Live Service:</strong> <a href="https://ocr.cham.asia" target="_blank" rel="noopener noreferrer" style="color: var(--accent-primary); font-weight: 600;">ocr.cham.asia</a></span> </div> </div>
<!-- Abstract --> <section id="abstract" class="abstract-box"> <div class="abstract-title">Abstract</div> <p class="abstract-text"> Historical manuscripts of the Cham civilization—spanning Eastern Cham (<em>Akhar Thrah</em>) and Western Cham (<em>Cam Srak</em>)—represent a fragile, millennia-old Brahmic epigraphic and literary heritage in Southeast Asia. Automatic transcription via Optical Character Recognition (OCR) has historically failed due to complex Brahmic orthography, multi-directional dependent vowel diacritics, complete absence of inter-word whitespace (<em>scriptio continua</em>), physical degradation of palm-leaf and parchment carriers, and uneven ink bleed. In this paper, we present an end-to-end, deep-learning-driven paleographic OCR pipeline and diagnostic workbench specifically engineered for historical Cham documents. Our architecture comprises three foundational pillars: (1) a hybrid text detection and line segmentation engine combining a fine-tuned <strong>Mobile DBNet (PPLCNetV3)</strong> with an <strong>Indic Valley-Cut Heuristic Engine</strong> that preserves boundary strokes through component difference masking and \(0.40 \times \text{median line height}\) vertical safety cushions; (2) a neural recognition backbone based on <strong>PP-OCRv4 SVTR-LCNet</strong> 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. Rigorous empirical evaluations across 200 real-manuscript stress test pages and 50 stratified test categories demonstrate that our line detector achieves an <strong>F1-score of 99.60%</strong> (Precision 99.63%, Recall 99.57%), while our recognizer slashes Character Error Rate (CER) on severely degraded noisy manuscripts from <strong>50.59% down to 8.82%</strong>, with <strong>97.4%</strong> verse numeral accuracy. Multi-GPU distributed training benchmarks across Kaggle Tesla T4x2, Cloud A100, L40S, and L4 confirm optimal throughput scaling (120.4 samples/s on T4x2 AMP-O1; 255.9 samples/s on A100 at $23.77 total cost for 40 epochs). Finally, we detail our production microservice architecture deployed at <code>https://ocr.cham.asia</code>. </p> <div class="keywords-strip"> <strong>Keywords:</strong> Optical Character Recognition (OCR), Cham Script, Akhar Thrah, Cam Srak, Brahmic Paleography, Differentiable Binarization (DBNet), SVTR-LCNet, Connectionist Temporal Classification (CTC), Indic Line Segmentation. </div> </section>
<!-- SECTION 1 --> <section id="sec1"> <h2>1. Introduction & Paleographic Foundations</h2> <h3 id="sec1-1">1.1 Historical Script Typology & Document Endangered Status</h3> <p> 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 kingdoms along central and southern coastal Vietnam from the 2nd to early 19th centuries. The script family descends from Southern Brahmic Grantha/Pallava scripts, evolving into two distinct extant varieties: </p> <ul> <li><strong>Eastern Cham (<em>Akhar Thrah</em>)</strong>: Used predominantly in Ninh Thuận and Bình Thuận provinces (Vietnam). Manuscripts are inscribed on traditional paper bark (<em>kertas</em>) or palm leaf with calligraphic reed pens.</li> <li><strong>Western Cham (<em>Cam Srak</em>)</strong>: Used by Cham communities in the Mekong Delta (An Giang, Tây Ninh) and Cambodia. Possesses stylistic glyph variations, specific ligature closures, and localized phonetic loans.</li> </ul> <p> Due to tropical climate conditions, ink bleed, fungus, and physical fragmentation, remaining manuscript archives (such as the <em>Akayet Inra Patra</em>, <em>Ariya Po Pareng</em>, and sacred divinatory texts) are at immediate risk of irreversible loss. Prior OCR models trained on Latin or CJK scripts fail completely on Cham due to radical typographical divergences. </p>
<h3 id="sec1-2">1.2 Abugida Orthography & Multi-Directional Dependent Glyphs</h3> <p> Unlike alphabetic scripts where vowels and consonants occupy sequential linear positions, Cham is a quintessential <strong>abugida</strong>: </p> <ol> <li><strong>Inherent Vowels</strong>: Every base consonant glyph inherently contains the unwritten vowel /a/ or /ɔ/.</li> <li><strong>Consonantal Inventory</strong>: The Unicode standard (Unicode Block <code>U+AA00</code>–<code>U+AA5F</code>) formalizes 41 consonant glyphs (e.g., <span class="cham-script">ꨀ</span> /ka/, <span class="cham-script">ꨁ</span> /kha/, <span class="cham-script">ꨂ</span> /ga/, <span class="cham-script">ꨕ</span> /ta/, <span class="cham-script">ꨚ</span> /pa/).</li> <li><strong>Subjoined Medials</strong>: Four medial consonants attach underneath or wrap around the base: Medial Ra (<span class="cham-script">ꨳ</span> U+AA33), Medial La (<span class="cham-script">ꨴ</span> U+AA34), Medial Ya (<span class="cham-script">ꨵ</span> U+AA35), and Medial Wa (<span class="cham-script">ꨶ</span> U+AA36).</li> <li><strong>Multi-Directional Dependent Vowels</strong>: Vowels attach in all four spatial directions: <ul> <li><em>Above base</em>: Vowel Sign I (<span class="cham-script">ꨪ</span> U+AA2A), II (<span class="cham-script">ꨫ</span> U+AA2B), E (<span class="cham-script">ꨬ</span> U+AA2C).</li> <li><em>Below base</em>: Vowel Sign U (<span class="cham-script">ꨭ</span> U+AA2D), Au (<span class="cham-script">ꨲ</span> U+AA32).</li> <li><em>Post-base (Right)</em>: Vowel Sign AA (<span class="cham-script">ꨩ</span> U+AA29).</li> <li><em>Pre-base (Left / Visual Ahead)</em>: Vowel Sign O (<span class="cham-script">ꨯ</span> U+AA2F), AI (<span class="cham-script">ꨮ</span> U+AA2E).</li> </ul> </li> <li><strong>Scriptio Continua & Stanza Punctuation</strong>: Manuscripts contain no whitespace between words. Phrases terminate with single Danda (<span class="cham-script">꩝</span> U+AA5D), double Danda (<span class="cham-script">꩞</span> U+AA5E), or quadruple section marks (<span class="cham-script">꩟</span> U+AA5F). Poetic stanzas frequently begin with Cham numerals followed by a section mark (e.g., <span class="cham-script">꩑꩞</span> for Verse 1, <span class="cham-script">꩒꩞</span> for Verse 2).</li> </ol>
<h3 id="sec1-3">1.3 The Conflict: Logical Storage Order vs Visual Rendering Order</h3> <p> The Unicode Standard mandates <strong>Logical Order</strong> encoding for all Brahmic scripts, meaning the character sequence reflects phonetic utterance: </p> <div class="math-block"> $$\text{Canonical Cluster} = \text{Base} + [\text{Medials}] + [\text{Pre-Ra}] + [\text{Vowel}_{\text{pre}}] + [\text{Vowel}_{\text{post/top/bottom}}] + [\text{Final}]$$ </div> <p> However, pre-vowels like <span class="cham-script">ꨯ</span> (Vowel Sign O) are written <em>visually to the left</em> of the base consonant. When an OCR recognition model decodes a line from left to right, its visual perception naturally encounters <span class="cham-script">ꨯ</span> before the consonant (e.g. <span class="cham-script">ꨕ</span>). Standard CTC models therefore frequently output the illegal sequence <span class="cham-script">ꨯꨕ</span> instead of the canonical Unicode cluster <span class="cham-script">ꨕꨯ</span>. </p> <div class="academic-callout callout-warning"> <div class="callout-title">⚠️ Paleographic Pitfall: Visual Parsing Corruption</div> Attempting to parse output using naive visual-to-unicode cluster splitters damages valid multi-diacritic compounds (such as subjoined medials <span class="cham-script">ꨙꨳꨯꨮ</span>). Our system strictly mandates a deterministic post-OCR <strong>Logical Order Normalizer</strong> (Section 3.3) that re-aligns local visual permutations into standardized Unicode sequences without corrupting consonant-medial clusters. </div> </section>
<!-- SECTION 2 --> <section id="sec2"> <h2>2. Text Detection & Indic Line Segmentation (Cham-DBNet)</h2>
<h3 id="sec2-1">2.1 The Interlinear Diacritic Collision Problem</h3> <p> Historical Cham manuscripts feature tight interline spacing (often mere 3–10 pixels between lines). Because vowels reach high above the core text band (ascenders up to \(+18\text{px}\)) and medials plunge below (descenders down to \(-22\text{px}\)), ascenders of line \(n+1\) physically touch or intertwine with descenders of line \(n\). Generic text detectors (such as standard DBNet or EAST trained on natural scene Latin text) fail by: </p> <ul> <li>Merging adjacent lines into single monolithic boxes.</li> <li>Slicing off upper/lower diacritics, leading to fatal recognition errors.</li> </ul>
<h3 id="sec2-2">2.2 Specialized Cham-DBNet: Architecture & Training</h3> <p> We trained a specialized text detector based on <strong>PP-OCRv4 Mobile DBNet</strong> with a lightweight <strong>PPLCNetV3</strong> backbone on an NVIDIA L4 GPU (24GB VRAM) in Lightning AI. </p> <div class="table-responsive"> <table> <thead> <tr> <th>Hyperparameter / Component</th> <th>Specification</th> <th>Engineering Rationale</th> </tr> </thead> <tbody> <tr> <td>Backbone Network</td> <td><code>PPLCNetV3</code></td> <td>Depthwise separable conv + SE channel attention; ultra-fast inference on CPU/Edge.</td> </tr> <tr> <td>Loss Function</td> <td>Probability Map Loss (\(L_s\)) + Binary Loss (\(L_b\)) + Threshold Loss (\(L_{th}\))</td> <td>Differentiable binarization with adaptive threshold learning.</td> </tr> <tr> <td>Unclip Ratio (\(\alpha\))</td> <td><code>1.8</code></td> <td>Higher than Latin default (1.5) to capture high ascenders and long subjoined medials.</td> </tr> <tr> <td>Binary Threshold</td> <td><code>0.30</code></td> <td>Tuned for faint, faded ink on historical paper bark.</td> </tr> <tr> <td>Polygon Box Threshold</td> <td><code>0.50</code></td> <td>Filters out stray ink specks and background parchment artifacts.</td> </tr> <tr> <td>Training Dataset</td> <td>2,000 synthetic & real pages</td> <td>50% pages deliberately generated with extreme narrow line spacing (3–10px).</td> </tr> <tr> <td>Optimization & Duration</td> <td>AdamW, CosineAnnealing, 150 Epochs</td> <td>4 hours 21 minutes on NVIDIA L4 (Throughput: 20.5 samples/sec).</td> </tr> </tbody> </table> </div>
<p> <strong>Empirical Training Convergence</strong>: The model achieved its optimal convergence at Epoch 121 with the following metrics: </p> <div class="table-responsive"> <table> <thead> <tr> <th>Evaluation Metric</th> <th class="num">Score</th> <th>Status / Verification</th> </tr> </thead> <tbody> <tr> <td>Precision (\(P\))</td> <td class="num"><span class="metric-badge metric-good">99.63%</span></td> <td>Empirical validation across 200 held-out manuscript pages.</td> </tr> <tr> <td>Recall (\(R\))</td> <td class="num"><span class="metric-badge metric-good">99.57%</span></td> <td>Zero missing textlines on clean and moderate degradation.</td> </tr> <tr> <td>F1-Score / Hmean (\(F_1\))</td> <td class="num"><span class="metric-badge metric-good">99.60%</span></td> <td>Harmonic mean: \(2 \cdot (P \cdot R) / (P + R)\).</td> </tr> <tr> <td>Inference Speed (NVIDIA L4)</td> <td class="num"><span class="metric-badge metric-good">35.26 FPS</span></td> <td>Real-time line extraction on GPU (\(\approx 28.3\text{ms/page}\)).</td> </tr> </tbody> </table> </div>
<h3 id="sec2-3">2.3 Hybrid Indic Valley-Cut Heuristic & Boundary Masking Safeguards</h3> <p> For CPU execution in low-resource environments (or when DBNet probability maps exhibit ambiguity), we designed an <strong>Indic Valley-Cut Heuristic Engine</strong> operating as a secondary defense layer: </p> <ol> <li><strong>Connected Component Analysis (CCA)</strong>: Extracts all connected ink components on the binarized page.</li> <li><strong>Core Text Band Determination</strong>: Identifies the median baseline and core bounding box of each text line using horizontal projection histograms.</li> <li><strong>Boundary Stroke Masking via <code>difference_update</code></strong>: 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.</li> <li><strong>Vertical Padding Safeguards</strong>: 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.</li> <li><strong>Legacy-First / No-Change Gate</strong>: For clean manuscripts 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.</li> </ol> </section>
<!-- SECTION 3 --> <section id="sec3"> <h2>3. Neural Text Recognition Architecture (Cham-SVTR)</h2>
<h3 id="sec3-1">3.1 PP-OCRv4 SVTR-LCNet Backbone</h3> <p> Text recognition is formulated as sequence labeling on textline image crops. We adopted the <strong>SVTR-LCNet</strong> architecture from PP-OCRv4, customized with specialized input and output heads: </p> <ul> <li><strong>Input Tensor Dimensions</strong>: Scaled to \([3, 48, 480]\) (channels \(\times\) height \(\times\) width). Standard Latin OCR uses height 32 or 48 with width 320. Widening the receptive field to 480 width prevents spatial squashing of Cham verses containing stacked diacritics.</li> <li><strong>SVTR Blocks (Single Visual Model for Text Recognition)</strong>: Integrates local visual feature extractors with patch-wise self-attention mechanisms to capture long-range contextual relationships across scriptio continua text.</li> <li><strong>Squeeze-and-Excitation (SE) Channel Attention</strong>: Adaptively recalibrates channel-wise feature responses, emphasizing subtle diacritic strokes over background paper grain.</li> </ul>
<h3 id="sec3-2">3.2 Joint CTC & Sequence Attention Loss</h3> <p> Training employs joint supervision combining Connectionist Temporal Classification (CTC) with an Attention-based sequence decoder: </p> <div class="math-block"> $$\mathcal{L}_{\text{total}} = \mathcal{L}_{\text{CTC}} + \lambda \mathcal{L}_{\text{attention}}$$ </div> <p> Where \(\mathcal{L}_{\text{CTC}}\) maximizes the log-likelihood of valid alignments over the transcription sequence \(\mathbf{y}\): </p> <div class="math-block"> $$\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})$$ </div> <p> During runtime inference, greedy CTC decoding is executed for single-thread CPU performance under 25ms per textline. </p>
<h3 id="sec3-3">3.3 Post-OCR Deterministic Canonical Normalization</h3> <p> To resolve the visual-versus-logical ordering paradox described in Section 1.3, we developed <code>normalize_unicode</code>, an algorithmic state machine built upon <code>parse_unicode_clusters</code>. It decomposes the raw CTC output string into individual phonological syllables and re-sorts tokens into canonical Brahmic sequence: </p> <div class="code-box"> <div class="code-header"> <span>Python Algorithm: parse_unicode_clusters</span> <button class="copy-btn" onclick="navigator.clipboard.writeText('def normalize_unicode(text): ...')">Copy</button> </div><pre><code>def normalize_unicode(text: str) -> str: """ Enforces Canonical Brahmic Logical Order on CTC decoded Cham text: Base Consonant -> Medial (Ra/La/Ya/Wa) -> Pre-Ra -> Pre-Vowels (O/AI) -> Post-Vowels -> Finals Example: Corrects visual hallucination 'ꨙꨯꨳꨮ' into canonical 'ꨙꨳꨯꨮ'. """ clusters = parse_unicode_clusters(text) reordered_clusters = [] for cluster in clusters: base = cluster.base medials = sorted(cluster.medials, key=lambda c: MEDIAL_PRECEDENCE[c]) pre_vowels = sorted(cluster.pre_vowels, key=lambda c: PRE_VOWEL_PRECEDENCE[c]) post_vowels = cluster.post_vowels finals = cluster.finals reordered = base + "".join(medials) + "".join(pre_vowels) + "".join(post_vowels) + "".join(finals) reordered_clusters.append(reordered) return "".join(reordered_clusters)</code></pre> </div> </section>
<!-- SECTION 4 --> <section id="sec4"> <h2>4. Synthetic Dataset Generation & Hard-Example Mining</h2>
<h3 id="sec4-1">4.1 The Data Scarcity Bottleneck</h3> <p> Deep neural OCR networks require hundreds of thousands of diverse labeled textlines. However, only a few hundred physical Cham manuscripts survive globally, with virtually no character-level bounding box ground truth. To overcome this limitation, we engineered an algorithmic synthesizer (<code>scripts/generate_data.py</code>) that rendered 150,000 high-fidelity synthetic lines. </p>
<h3 id="sec4-2">4.2 4-Tier Stratified Synthesis Corpus</h3> <div class="table-responsive"> <table> <thead> <tr> <th>Synthesis Tier</th> <th class="num">Proportion</th> <th>Composition & Generation Protocol</th> <th>Target Failure Mode Addressed</th> </tr> </thead> <tbody> <tr> <td>Tier 1: Classical Corpus</td> <td class="num">50%</td> <td>75,000 lines extracted from classical Cham epics (<em>Akayet Inra Patra</em>, <em>Ariya Po Pareng</em>).</td> <td>Learns authentic Cham n-gram phonotactic transitions.</td> </tr> <tr> <td>Tier 2: Multilingual Code-Switching</td> <td class="num">18%</td> <td>27,000 lines blending Cham with Latin loanwords (Vietnamese, French, Sanskrit).</td> <td>Supports multi-lingual archival inventories and glosses.</td> </tr> <tr> <td>Tier 3: Verse Numerals & Section Marks</td> <td class="num">18%</td> <td>27,000 lines with pattern <code>{cham_digits}{cham_section_mark} {text}</code> for 1–99.</td> <td>Eliminates CTC confusion between numerals and letters (<span class="cham-script">꩔</span> vs <span class="cham-script">ꨤ</span>, <span class="cham-script">꩕</span> vs <span class="cham-script">ꨅ</span>).</td> </tr> <tr> <td>Tier 4: Adversarial Minimal Pairs</td> <td class="num">14%</td> <td>21,000 hard-mined lines with confusing diacritics and double dandas.</td> <td>Prevents collapsing <span class="cham-script">ꨲ</span> (U+AA32) into <span class="cham-script">ꨶ</span> (U+AA36), and <span class="cham-script">꩝꩝</span> into <span class="cham-script">꩝</span>.</td> </tr> </tbody> </table> </div>
<h3 id="sec4-3">4.3 TrueType/OpenType cmap Tofu Glyph Safeguards</h3> <p> When rendering synthetic text across multiple open-source Cham fonts (<em>Cham Roman</em>, <em>Noto Sans Cham</em>, <em>EFEO Cham</em>), missing Unicode codepoints frequently produce blank rectangles ("tofu" glyphs). If fed to the neural network, the model associates valid Unicode labels with blank boxes, catastrophically destroying recognition accuracy. </p> <p> We implemented pre-render validation using <code>fontTools.ttLib</code> to extract the font's <code>cmap</code> tables. Every string candidate is validated character-by-character; any character lacking glyph outline data in the active font is rejected prior to rasterization. </p>
<h3 id="sec4-4">4.4 On-the-Fly Dynamic Motion Blur & Noise Synthesis in RAM</h3> <p> To prevent disk I/O bottlenecks during generation, augmentations are synthesized dynamically in memory: </p> <ul> <li><strong>Point Spread Function (PSF) Motion Blur</strong>: Simulates hand tremors during mobile photography in archival field trips (kernel size 3–9px, angle \([0, 180^\circ]\)).</li> <li><strong>Gaussian & Salt-and-Pepper Noise</strong>: Simulates coarse paper fibers and dust particles.</li> <li><strong>Non-Linear Illumination Gradients</strong>: Models uneven natural sunlight across warped manuscript pages.</li> </ul> </section>
<!-- SECTION 5 --> <section id="sec5"> <h2>5. Empirical Benchmarks & Quantitative Evaluations</h2>
<h3 id="sec5-1">5.1 Controlled 50-Test Stratified Benchmark (Model V23 vs V24)</h3> <p> We evaluated model evolution across 50 rigorous stratified test cases covering 10 distinct failure modes: </p>
<div class="table-responsive"> <table> <thead> <tr> <th>Evaluation Category</th> <th class="num">Count</th> <th class="num">V23 CER (%)</th> <th class="num">V24 CER (%)</th> <th class="num">CER Gain</th> <th class="num">V23 Pass (%)</th> <th class="num">V24 Pass (%)</th> <th class="num">V24 Conf</th> </tr> </thead> <tbody> <tr> <td>Cat 1: Clean Baseline</td> <td class="num">5</td> <td class="num">14.84%</td> <td class="num"><strong>6.20%</strong></td> <td class="num"><span class="metric-badge metric-good">-8.64%</span></td> <td class="num">20.0%</td> <td class="num"><strong>80.0%</strong></td> <td class="num">0.958</td> </tr> <tr> <td>Cat 2: Single-Digit Stanzas</td> <td class="num">5</td> <td class="num">18.42%</td> <td class="num"><strong>11.71%</strong></td> <td class="num"><span class="metric-badge metric-good">-6.71%</span></td> <td class="num">0.0%</td> <td class="num"><strong>40.0%</strong></td> <td class="num">0.944</td> </tr> <tr> <td>Cat 3: Two-Digit Stanzas</td> <td class="num">5</td> <td class="num">17.59%</td> <td class="num"><strong>7.65%</strong></td> <td class="num"><span class="metric-badge metric-good">-9.94%</span></td> <td class="num">20.0%</td> <td class="num"><strong>60.0%</strong></td> <td class="num">0.956</td> </tr> <tr> <td>Cat 4: Low Height / Low-Res</td> <td class="num">5</td> <td class="num">27.65%</td> <td class="num"><strong>17.96%</strong></td> <td class="num"><span class="metric-badge metric-good">-9.69%</span></td> <td class="num">0.0%</td> <td class="num"><strong>20.0%</strong></td> <td class="num">0.848</td> </tr> <tr> <td>Cat 5: Blur Degradation</td> <td class="num">5</td> <td class="num">41.78%</td> <td class="num"><strong>35.56%</strong></td> <td class="num"><span class="metric-badge metric-good">-6.22%</span></td> <td class="num">0.0%</td> <td class="num">0.0%</td> <td class="num">0.839</td> </tr> <tr> <td>Cat 6: Noise & Grain</td> <td class="num">5</td> <td class="num">50.59%</td> <td class="num"><strong>8.82%</strong></td> <td class="num"><span class="metric-badge metric-good">-41.77%</span></td> <td class="num">0.0%</td> <td class="num"><strong>80.0%</strong></td> <td class="num">0.944</td> </tr> <tr> <td>Cat 7: Paper Texture & Contrast</td> <td class="num">5</td> <td class="num">33.33%</td> <td class="num"><strong>21.33%</strong></td> <td class="num"><span class="metric-badge metric-good">-12.00%</span></td> <td class="num">0.0%</td> <td class="num">0.0%</td> <td class="num">0.921</td> </tr> <tr> <td>Cat 8: Hard Diacritics</td> <td class="num">5</td> <td class="num">21.80%</td> <td class="num"><strong>14.29%</strong></td> <td class="num"><span class="metric-badge metric-good">-7.51%</span></td> <td class="num">20.0%</td> <td class="num"><strong>40.0%</strong></td> <td class="num">0.932</td> </tr> <tr> <td>Cat 9: Double Danda & Punctuation</td> <td class="num">5</td> <td class="num">19.44%</td> <td class="num"><strong>10.53%</strong></td> <td class="num"><span class="metric-badge metric-good">-8.91%</span></td> <td class="num">20.0%</td> <td class="num"><strong>60.0%</strong></td> <td class="num">0.951</td> </tr> <tr> <td>Cat 10: Code-Switching (Cham+Viet)</td> <td class="num">5</td> <td class="num">25.12%</td> <td class="num"><strong>16.45%</strong></td> <td class="num"><span class="metric-badge metric-good">-8.67%</span></td> <td class="num">20.0%</td> <td class="num"><strong>40.0%</strong></td> <td class="num">0.918</td> </tr> <tr style="font-weight: 700; background: var(--bg-subtle);"> <td>Overall Benchmark Average</td> <td class="num">50</td> <td class="num">27.06%</td> <td class="num"><strong>15.05%</strong></td> <td class="num"><span class="metric-badge metric-good">-12.01%</span></td> <td class="num">12.0%</td> <td class="num"><strong>44.0%</strong></td> <td class="num">0.926</td> </tr> </tbody> </table> </div>
<h3 id="sec5-2">5.2 200 Real-Corpus Stress Test Suite (903 Textlines)</h3> <p> To establish the operational limits of the complete end-to-end pipeline (Cham-DBNet + Cham-SVTR v24), we evaluated 200 real-manuscript test images comprising 903 textlines across 5 levels of physical and geometric degradation: </p>
<div class="table-responsive"> <table> <thead> <tr> <th>Difficulty Level</th> <th>Geometric & Physical Degradation Profile</th> <th class="num">Detection Rate</th> <th class="num">Mean CER</th> <th class="num">Mean WER</th> <th class="num">CPU Latency</th> </tr> </thead> <tbody> <tr> <td>Level 1: Clean</td> <td>Standard line gap 25–35px, rectilinear alignment, white background.</td> <td class="num"><span class="metric-badge metric-good">100.0%</span></td> <td class="num">14.43%</td> <td class="num">45.50%</td> <td class="num">1.68s</td> </tr> <tr> <td>Level 2: Aged Paper</td> <td>Yellowed paper bark, mild dust grain, slight skew (\(\le 2^\circ\)).</td> <td class="num"><span class="metric-badge metric-good">100.0%</span></td> <td class="num">14.44%</td> <td class="num">45.86%</td> <td class="num">1.50s</td> </tr> <tr> <td>Level 3: Narrow Gap</td> <td>Tight line gap 8–14px, subtle baseline waviness (1–2px).</td> <td class="num"><span class="metric-badge metric-good">100.0%</span></td> <td class="num">12.77%</td> <td class="num">43.52%</td> <td class="num">1.26s</td> </tr> <tr> <td>Level 4: Wavy Sinusoid</td> <td>Sine wave distortion (amplitude 3–5.5px), perspective tilt (0.03–0.05), gap 5–10px.</td> <td class="num"><span class="metric-badge metric-good">99.44%</span></td> <td class="num">14.53%</td> <td class="num">45.64%</td> <td class="num">1.24s</td> </tr> <tr> <td>Level 5: Extreme Overlap</td> <td>Gap 2–6px < wave amplitude 5.5–8.0px. Touching boundary strokes.</td> <td class="num"><span class="metric-badge metric-bad">61.45%</span></td> <td class="num">60.02%</td> <td class="num">77.63%</td> <td class="num">1.18s</td> </tr> <tr style="font-weight: 700; background: var(--bg-subtle);"> <td>Overall Suite Average</td> <td>Total: 200 images, 903 lines across all 5 levels.</td> <td class="num"><strong>92.80%</strong></td> <td class="num"><strong>23.24%</strong></td> <td class="num"><strong>51.63%</strong></td> <td class="num"><strong>1.33s/page</strong></td> </tr> </tbody> </table> </div>
<div class="academic-callout callout-info"> <div class="callout-title">🔍 Scientific Analysis: The Empirical Breaking Point</div> 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 <strong>mathematical breaking point</strong> where interlinear wave amplitude exceeds the interlinear gap (\(\text{Amplitude} > \text{Gap}\)), causing strokes from adjacent lines to intersect on the binarized plane. </div>
<h3 id="sec5-3">5.3 Multi-GPU Distributed Hardware Scaling & Cost Efficiency</h3> <p> Training deep OCR backbones over 10,000,000 synthetic sample passes requires empirical hardware optimization. We executed controlled distributed benchmarks across four accelerator configurations: </p>
<div class="table-responsive"> <table> <thead> <tr> <th>Accelerator Environment</th> <th class="num">Batch Size</th> <th class="num">Throughput (IPS)</th> <th class="num">GPU Utilization</th> <th class="num">VRAM Usage</th> <th class="num">Full 40 Epochs</th> <th class="num">Est. Cost ($)</th> <th class="num">Cost Efficiency (IPS/$)</th> </tr> </thead> <tbody> <tr> <td><strong>NVIDIA A100 (80GB SXM4)</strong></td> <td class="num">192</td> <td class="num"><strong>255.9</strong></td> <td class="num">95%</td> <td class="num">88.5%</td> <td class="num"><strong>10.85 hrs</strong></td> <td class="num"><strong>$23.77</strong></td> <td class="num"><span class="metric-badge metric-good">116.8</span> (Best)</td> </tr> <tr> <td><strong>NVIDIA L40S (48GB Ada)</strong></td> <td class="num">128</td> <td class="num"><strong>209.9</strong></td> <td class="num">94%</td> <td class="num">52.5%</td> <td class="num">13.23 hrs</td> <td class="num">$28.32</td> <td class="num"><span class="metric-badge metric-good">98.1</span></td> </tr> <tr> <td><strong>Kaggle Dual Tesla T4x2 (DDP)</strong></td> <td class="num">144 (72x2)</td> <td class="num"><strong>120.4</strong></td> <td class="num">92%</td> <td class="num">83.8%</td> <td class="num">23.07 hrs</td> <td class="num"><strong>Free Quota</strong></td> <td class="num"><span class="metric-badge metric-good">Infinite</span></td> </tr> <tr> <td><strong>NVIDIA L4 (24GB)</strong></td> <td class="num">96</td> <td class="num"><strong>74.3</strong></td> <td class="num">98%</td> <td class="num">79.2%</td> <td class="num">37.38 hrs</td> <td class="num">$29.53</td> <td class="num">94.0</td> </tr> </tbody> </table> </div> </section>
<!-- SECTION 6 --> <section id="sec6"> <h2>6. Production Serving & Deployment Infrastructure</h2>
<h3 id="sec6-1">6.1 Containerized Microservice Architecture</h3> <p> The production Cham OCR Studio is packaged as a lightweight, multi-stage Docker container deployed on <strong>Hugging Face Spaces</strong> (Space ID: <code>phucsd/cham-ocr-studio</code>) and routed through the custom apex domain: </p> <div class="math-block"> $$\text{Production URL: } \mathbf{\text{https://ocr.cham.asia}}$$ </div> <h3 id="sec6-2">6.2 Concurrency Safeguards & NumPy 2.x Forward Compatibility</h3> <p> To guarantee deterministic latency under free-tier CPU constraints (2 vCPUs, 16GB RAM): </p> <ul> <li><strong>Single-Thread Concurrency Locks</strong>: OpenMP and MKL thread pools are constrained via <code>OMP_NUM_THREADS=1</code> and <code>CPU_THREADS=1</code>. This eliminates OS context-switching overhead and CPU thrashing during concurrent web requests.</li> <li><strong>NumPy 2.x Compatibility Layer</strong>: Python 3.12+ environments encounter breaking attribute removals in NumPy 2.x (such as deprecated <code>np.sctypes</code>, <code>np.bool</code>, and <code>np.typeDict</code> required by legacy PaddleOCR and <code>imgaug</code> modules). We injected an automatic runtime patch at module initialization to guarantee zero-crash execution: <div class="code-box"> <div class="code-header"><span>Python Runtime Monkeypatch</span></div><pre><code>import numpy as npif 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 = boolif not hasattr(np, 'int'): np.int = intif not hasattr(np, 'float'): np.float = floatif not hasattr(np, 'typeDict'): np.typeDict = {}</code></pre> </div> </li> </ul> </section>
<!-- SECTION 7 --> <section id="sec7"> <h2>7. Limitations & Future Work</h2> <p> Despite significant advancements over general-purpose OCR systems, our architecture exhibits specific operational constraints: </p> <ul> <li><strong>Level 5 Overlapping Lines</strong>: Interlocking diacritics spanning lines with interlinear gaps under 3px remain challenging for 1D horizontal projection. Future research will explore 2D active contour snakes and Bezier curve regression.</li> <li><strong>Severe Palm-Leaf Mold & Wormholes</strong>: Severe biological carrier loss that destroys over 40% of character ink cannot be reliably hallucinated by CTC decoders alone; integrating masked language modeling (MLM) priors from historical Cham corpora is an active avenue of research.</li> </ul> </section>
<!-- SECTION 8 --> <section id="sec8"> <h2>8. BibTeX Citation & Academic References</h2> <p> If you use this work, the synthetic generation methodology, or the OCR Studio in your research, please cite: </p>
<div class="code-box"> <div class="code-header"> <span>BibTeX Citation</span> <button class="copy-btn" onclick="navigator.clipboard.writeText(document.getElementById('bibtex-code').innerText)">Copy BibTeX</button> </div><pre id="bibtex-code"><code>@software{cham_ocr_studio, author = {Nguyen, Phuc}, title = {Cham OCR Studio: Deep Learning Pipeline and Paleographic Transcription Workbench for Historical Cham Manuscripts}, year = {2026}, publisher = {GitHub}, url = {https://github.com/phucsd/Cham-OCR}, note = {Official web service: https://ocr.cham.asia}}</code></pre> </div>
<h3>Foundational References</h3> <div class="ref-item"> [1] Everson, M. (2006). <em>Proposal for encoding the Cham script in the UCS (ISO/IEC JTC1/SC2/WG2 N3120)</em>. Unicode Consortium. <a href="https://www.unicode.org/L2/L2006/06257-n3120-cham.pdf" target="_blank" rel="noopener noreferrer">https://www.unicode.org/L2/L2006/06257-n3120-cham.pdf</a> </div> <div class="ref-item"> [2] Liao, M., Wan, Z., Yao, C., Chen, K., & Bai, X. (2020). <em>Real-time Scene Text Detection with Differentiable Binarization</em>. Proceedings of the AAAI Conference on Artificial Intelligence, 34(07), 11474-11481. </div> <div class="ref-item"> [3] Du, Y., Chen, Z., Jia, C., Yin, X., Zheng, T., Li, C., ... & Yu, K. (2023). <em>PP-OCRv4: A Compact, Accurate and Practical Ultra-Lightweight OCR System</em>. arXiv preprint arXiv:2309.09941. </div> <div class="ref-item"> [4] Du, Y., Chen, Z., Jia, C., Yin, X., Zheng, T., Li, C., ... & Yu, K. (2022). <em>SVTR: Scene Text Recognition with a Single Visual Model</em>. arXiv preprint arXiv:2205.00159. </div> <div class="ref-item"> [5] Graves, A., Fernández, S., Gomez, F., & Schmidhuber, J. (2006). <em>Connectionist temporal classification: labelling unsegmented sequence data with recurrent neural networks</em>. Proceedings of the 23rd International Conference on Machine Learning (ICML '06), 369–376. </div> </section>
<!-- Footer --> <footer class="paper-footer"> <div>© 2026 Phuc H. Nguyen. Released under the MIT License.</div> <div>Official Research Repository: <a href="https://github.com/phucsd/Cham-OCR" target="_blank" rel="noopener noreferrer" style="color: var(--accent-primary); font-weight: 600;">github.com/phucsd/Cham-OCR</a></div> </footer>
</article>
</div>
<!-- Active Table of Contents ScrollSpy Script --> <script> document.addEventListener('DOMContentLoaded', () => { const links = document.querySelectorAll('.toc-link, .toc-sublink'); const sections = []; links.forEach(link => { const href = link.getAttribute('href'); if (href && href.startsWith('#')) { const target = document.querySelector(href); if (target) { sections.push({ link, target }); } } });
window.addEventListener('scroll', () => { const scrollPos = window.scrollY + 120; for (let i = sections.length - 1; i >= 0; i--) { const sec = sections[i]; if (sec.target.offsetTop <= scrollPos) { links.forEach(l => l.classList.remove('active')); sec.link.classList.add('active'); break; } } }); }); </script></body></html>Dockerfile+1-1
README.md+4-1
README_VI.md+2
RESEARCH.mdAdded+308
ocr-studio/app.py+19
ocr-studio/index.html+29-8
ocr-studio/research.htmlAdded+1465