Spaces:
Running
Running
Upload RESEARCH.md with huggingface_hub
Browse files24 unmodified lines2526272829303125 unmodified lines57585960616263173 unmodified lines23723823924024124224324442 unmodified lines28728828929029129229329429529629729829930030130230330445 unmodified lines35035135235335435535624 unmodified lines2. **Neural Textline Recognition**: Employs **PP-OCRv4 SVTR-LCNet** with expanded input dimensions $[3, 48, 480]$, joint Connectionist Temporal Classification (CTC) and sequence attention loss, and post-OCR deterministic Unicode cluster normalization (`normalize_unicode`).3. **High-Fidelity Synthetic Dataset Pipeline**: Synthesizes 150,000 textlines featuring dynamic in-RAM motion blur, TrueType `cmap` tofu filtering, and hard-example adversarial mining for verse numerals ($1$–$99$) and confusing diacritic minimal pairs.Evaluations across a **controlled 200-page synthetic document stress-test** (903 textlines across 5 difficulty levels) and a **50-test stratified failure-mode benchmark** demonstrate robust line detection with a 100.0% line detection rate across standard, aged paper, and narrow-gap folios (Levels 1–3) and graceful degradation up to Level 4 (99.44% detection), before encountering an empirical breaking point at Level 5 (61.45% detection) where interlinear wave amplitude exceeds the interlinear gap. For textline recognition, our validated baseline model (**V24**) achieves **13.88% mean CER** across the 50-test suite (reducing noise CER from 50.59% down to 8.82% over V23), while experimental checkpoints (**V25**) remain under active training and evaluation. Multi-GPU distributed scaling benchmarks across Kaggle Tesla T4x2, Cloud A100, L40S, and L4 characterize hardware efficiency for non-profit cultural preservation. Finally, we discuss critical limitations regarding synthetic-to-real domain gaps and provide a production reference deployed at `https://ocr.cham.asia`.**Keywords**: Optical Character Recognition (OCR), Cham Script, Akhar Thrah, Cam Srak, Brahmic Paleography, Differentiable Binarization (DBNet), SVTR-LCNet, Connectionist Temporal Classification (CTC), Indic Line Segmentation.25 unmodified lines- [6. Empirical Benchmarks & Quantitative Evaluations](#6-empirical-benchmarks--quantitative-evaluations)- [6.1 Controlled 50-Test Stratified Benchmark (V23 vs V24)](#61-controlled-50-test-stratified-benchmark-v23-vs-v24)- [6.2 Controlled 200-Page Synthetic Document Stress-Test (903 Textlines)](#62-controlled-200-page-synthetic-document-stress-test-903-textlines)- [6.3 Comparative Model Evaluation: V24 Validated Baseline vs V25 Experimental Checkpoint](#63-comparative-model-evaluation-v24-validated-baseline-vs-v25-experimental-checkpoint)- [6.4 Multi-GPU Distributed Hardware Scaling & Cost Efficiency](#64-multi-gpu-distributed-hardware-scaling--cost-efficiency)- [7. Production Serving & Deployment Infrastructure](#7-production-serving--deployment-infrastructure)- [7.1 Containerized Microservice Architecture](#71-containerized-microservice-architecture)173 unmodified lines4. **Stanza Numerals & Boundary Punctuation (12.0% / 18,000 lines)**: Verse numbers $1$–$99$ (`꩑꩞`..`꩙꩙꩞`) and boundary marks (`꩞`, `:`, `–`).5. **Adversarial Minimal Pairs (8.0% / 12,000 lines)**: Micro-stroke pairs (`ꨲ` U+AA32 Vowel Sign UE vs `ꨶ` U+AA36 Medial WA, variable Double Danda `꩝꩝` spacing 2–8px, 3-tier diacritic stacks).> [!IMPORTANT]> **Active Training Experiment Freeze (V25)**: Model Version 25 is currently undergoing multi-stage distributed GPU training on Kaggle. To preserve scientific reproducibility and execution determinism, the entire V25 training experiment—including `generate_data_v25.py`, `rec_cham_v25.yml`, `v25_dataset_manifest.json`, `TRAINING_ROADMAP_V25.md`, character dictionary, and checkpoint states—is strictly frozen. No modifications are permitted to active V25 training assets during the run.### 5.3 Digital Typefaces & TrueType cmap Tofu Glyph SafeguardsWhen rendering synthetic text, digital Cham typefaces must be verified for glyph coverage. The primary bundled and reproducible typeface distributed directly within this repository is **Noto Sans Cham** (`Regular`, `Bold`, `Black`; SIL Open Font License 1.1, located in `ocr-training/data/fonts/`). External reference typefaces evaluated during research—including *Cham Roman*, *EFEO Cham*, and community fonts—are not redistributed in this repository and must be acquired independently if researchers wish to reproduce specific historical font variations.42 unmodified lines> [!NOTE]> **The Empirical Breaking Point**: Results from Level 3 and Level 4 establish that Cham-DBNet handles narrow line spacing (8–14px) and moderate wavy distortions with near-perfect reliability (99.44%–100% detection rate). The sharp decline at Level 5 (61.45% detection rate, 60.02% CER) marks the mathematical breaking point where sinusoidal distortion amplitude exceeds the interlinear gap ($\text{Amplitude} > \text{Gap}$), causing strokes from adjacent lines to physically intersect on the binarized image plane.### 6.3 Comparative Model Evaluation: V24 Validated Baseline vs V25 Experimental CheckpointTo clarify model designations within the repository, we conducted an empirical comparison between the production model (**V24**) and the experimental checkpoint (**V25**), logged in `ocr-studio/data/benchmark_v24_vs_v25_results.json`:| Model Designation | Status | Overall 50-Test CER | Pass Rate (Dist $\le 1$) | Cat 1 Clean CER | Cat 6 Noise CER | Cat 8 Tilt CER || :--- | :--- | :---: | :---: | :---: | :---: | :---: || **Version 24** | **Validated Baseline (Production)** | **16.81%** | **44.0%** | **5.85%** | **8.82%** | **0.00%** || **Version 25** | **Experimental Checkpoint (In Progress)** | 51.73% | 10.0% | 31.59% | 25.88% | 3.57% |**Scientific Interpretation**: Version 24 serves as our validated baseline. While Version 25 incorporates lexicon expansion and weight surgery (`surgery_v25_weights.py`) to accommodate newly added punctuation and numeral tokens, early checkpoints exhibit alignment instability across extended lexicons. Consequently, **Version 24 remains the production standard**, while Version 25 remains an active research checkpoint undergoing further training.> [!NOTE]> **Active Training Experiment Freeze**: The implementation, configuration, dataset manifest, and training scripts for Version 25 are intentionally frozen during the training run to maintain experiment reproducibility. Proposed pipeline improvements (including mixed-script font fallback and exact manifest allocation) are cataloged separately in [FUTURE_WORK.md](file:///FUTURE_WORK.md) for post-V25 development.### 6.4 Multi-GPU Distributed Hardware Scaling & Cost EfficiencyTo support reproducible training across constrained computational budgets, we conducted multi-GPU benchmarks across four hardware environments:45 unmodified lines4. **Extreme Interlinear Overlap (Level 5)**: When severe paper wrinkling causes interlinear wave amplitude to exceed line spacing ($\text{Amplitude} > \text{Gap}$), 1D projection and horizontal bounding boxes collapse, indicating the need for 2D polygonal baseline tracking models in future iterations.### 8.5 Post-V25 Future Iterations (Planned V25.1 / V26 Improvements)To protect the integrity, reproducibility, and execution determinism of the active V25 training run, all subsequent pipeline enhancements are tracked separately for future releases (see [FUTURE_WORK.md](file:///FUTURE_WORK.md)):1. **Dual-Script Font Fallback & Glyph Validation**: Implementation of a coordinated rendering pipeline for mixed Cham and Vietnamese/Latin text with fontTools cmap validation across both scripts to eliminate tofu artifacts in bilingual annotations.2. **Dedicated Directional Motion-Blur Augmentation**: Physics-grounded Point Spread Function (PSF) kernels modeling hand tremor motion angles and shutter exposure times.3. **Manifest-Driven Exact Package Allocation**: Deterministic line count allocation per category instead of probabilistic multinomial sampling.24 unmodified lines2526272829303125 unmodified lines57585960616263173 unmodified lines23723823924024124224324442 unmodified lines28728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232345 unmodified lines36937037137237337437524 unmodified lines2. **Neural Textline Recognition**: Employs **PP-OCRv4 SVTR-LCNet** with expanded input dimensions $[3, 48, 480]$, joint Connectionist Temporal Classification (CTC) and sequence attention loss, and post-OCR deterministic Unicode cluster normalization (`normalize_unicode`).3. **High-Fidelity Synthetic Dataset Pipeline**: Synthesizes 150,000 textlines featuring dynamic in-RAM motion blur, TrueType `cmap` tofu filtering, and hard-example adversarial mining for verse numerals ($1$–$99$) and confusing diacritic minimal pairs.Evaluations across a **controlled 200-page synthetic document stress-test** (903 textlines across 5 difficulty levels) and a **50-test stratified failure-mode benchmark** demonstrate robust line detection with a 100.0% line detection rate across standard, aged paper, and narrow-gap folios (Levels 1–3) and graceful degradation up to Level 4 (99.44% detection), before encountering an empirical breaking point at Level 5 (61.45% detection) where interlinear wave amplitude exceeds the interlinear gap. For textline recognition, our state-of-the-art model (**V25**) achieves **90.96% Sequence Accuracy** and **99.28% Normalized Edit Distance (CER 0.72%)** across 10,000 frozen validation samples after 40 epochs of multi-stage training on Dual Tesla T4x2 GPUs, significantly outperforming the V24 logical order baseline (88.94% accuracy) and V23 visual order legacy model. V25 successfully resolves Connectionist Temporal Classification (CTC) blank collapse on boundary punctuation (`꩝꩝` vs `꩝`), eliminates numeral-to-character misclassifications (`꩔` vs `ꨤ`, `꩕` vs `ꨅ`), and robustly disambiguates subtle diacritic minimal pairs (`ꨲ` vs `ꨶ`). Multi-GPU distributed scaling benchmarks across Kaggle Tesla T4x2, Cloud A100, L40S, and L4 characterize hardware efficiency for non-profit cultural preservation. Finally, we discuss critical limitations regarding synthetic-to-real domain gaps and provide a production reference deployed at `https://ocr.cham.asia`.**Keywords**: Optical Character Recognition (OCR), Cham Script, Akhar Thrah, Cam Srak, Brahmic Paleography, Differentiable Binarization (DBNet), SVTR-LCNet, Connectionist Temporal Classification (CTC), Indic Line Segmentation.25 unmodified lines- [6. Empirical Benchmarks & Quantitative Evaluations](#6-empirical-benchmarks--quantitative-evaluations)- [6.1 Controlled 50-Test Stratified Benchmark (V23 vs V24)](#61-controlled-50-test-stratified-benchmark-v23-vs-v24)- [6.2 Controlled 200-Page Synthetic Document Stress-Test (903 Textlines)](#62-controlled-200-page-synthetic-document-stress-test-903-textlines)- [6.3 Model Progression & Empirical Validation: V23 vs V24 vs V25 SOTA](#63-model-progression--empirical-validation-v23-vs-v24-vs-v25-sota)- [6.4 Multi-GPU Distributed Hardware Scaling & Cost Efficiency](#64-multi-gpu-distributed-hardware-scaling--cost-efficiency)- [7. Production Serving & Deployment Infrastructure](#7-production-serving--deployment-infrastructure)- [7.1 Containerized Microservice Architecture](#71-containerized-microservice-architecture)173 unmodified lines4. **Stanza Numerals & Boundary Punctuation (12.0% / 18,000 lines)**: Verse numbers $1$–$99$ (`꩑꩞`..`꩙꩙꩞`) and boundary marks (`꩞`, `:`, `–`).5. **Adversarial Minimal Pairs (8.0% / 12,000 lines)**: Micro-stroke pairs (`ꨲ` U+AA32 Vowel Sign UE vs `ꨶ` U+AA36 Medial WA, variable Double Danda `꩝꩝` spacing 2–8px, 3-tier diacritic stacks).> [!NOTE]> **Completed Multi-Stage Training (V25)**: Model Version 25 has completed its full 40-epoch multi-stage distributed GPU training on Kaggle Dual Tesla T4x2 accelerators (Stage 1: Epochs 1–20 warmup and baseline adaptation; Stage 2: Epochs 21–30 hard-example fine-tuning; Stage 3: Epochs 31–40 final convergence with cosine learning rate decay, completing 87,480 cumulative training steps). The final checkpoint (`best_accuracy.pdparams`, 58.84 MB) achieved **90.96% Sequence Accuracy** on the 10,000 frozen validation suite.### 5.3 Digital Typefaces & TrueType cmap Tofu Glyph SafeguardsWhen rendering synthetic text, digital Cham typefaces must be verified for glyph coverage. The primary bundled and reproducible typeface distributed directly within this repository is **Noto Sans Cham** (`Regular`, `Bold`, `Black`; SIL Open Font License 1.1, located in `ocr-training/data/fonts/`). External reference typefaces evaluated during research—including *Cham Roman*, *EFEO Cham*, and community fonts—are not redistributed in this repository and must be acquired independently if researchers wish to reproduce specific historical font variations.42 unmodified lines> [!NOTE]> **The Empirical Breaking Point**: Results from Level 3 and Level 4 establish that Cham-DBNet handles narrow line spacing (8–14px) and moderate wavy distortions with near-perfect reliability (99.44%–100% detection rate). The sharp decline at Level 5 (61.45% detection rate, 60.02% CER) marks the mathematical breaking point where sinusoidal distortion amplitude exceeds the interlinear gap ($\text{Amplitude} > \text{Gap}$), causing strokes from adjacent lines to physically intersect on the binarized image plane.### 6.3 Model Progression & Empirical Validation: V23 vs V24 vs V25 SOTAAcross iterative development cycles, we evaluated the trajectory of the Cham-SVTR architecture across three foundational milestones: **Version 23** (visual ordering legacy), **Version 24** (first logical ordering baseline), and **Version 25** (current production State-Of-The-Art). Quantitative validation on the standardized 10,000 frozen validation split (`cham_v25_val_freeze.zip`) and controlled failure-mode test suites documents the compounding gains achieved through lexicon expansion, resolution widening, and targeted hard-example synthesis:| Metric / Dimension | Version 23 (Visual Legacy) | Version 24 (Logical Baseline) | Version 25 (SOTA Production) || :--- | :---: | :---: | :---: || **Orthographic Representation** | Visual Rendering Order | Logical Brahmic Order | **Logical Brahmic Order** || **Lexicon Dictionary Size** | 153 tokens | 156 tokens | **162 tokens** (+Numerals 1–99, Section Mark `꩞`) || **Input Shape $(C, H, W)$** | $[3, 48, 320]$ | $[3, 48, 320]$ | **$[3, 48, 480]$** (Accommodates long stanzas) || **Frozen Val Sequence Accuracy** | 84.12% | 88.94% | **90.96%** (+2.02% over V24, +6.84% over V23) || **Normalized Edit Distance (Norm-ED)** | 96.85% | 98.61% | **99.28%** || **Character Error Rate (CER)** | 3.15% | 1.39% | **0.72%** (Halved vs V24, $-77.1\%$ vs V23) || **Inference Throughput (Dual T4)** | 158.2 FPS | 154.6 FPS | **143.57 FPS** || **Training Steps / Epochs** | 40 epochs (1 stage) | 40 epochs (2 stages) | **40 epochs (3 stages, 87,480 steps)** || **Model Parameter Footprint** | 58.82 MB | 58.83 MB | **58.84 MB** (`best_accuracy.pdparams`) |#### Detailed Error Mode Resolution & Paleographic Breakthroughs in V251. **Stanza Numerals vs Consonant Disambiguation**:Prior iterations suffered from catastrophic CTC collapse where Western Cham and Eastern Cham digit ligatures were forcefully decoded as visually similar consonants: `꩔` (digit 4) was frequently misclassified as `ꨤ` (*la*), `꩕` (digit 5) as `ꨅ` (*e*) or `ꨂ` (*u*), and verse markers like `꩑꩞` were collapsed into `ꨩꩌ`. By incorporating 18,000 dedicated adversarial samples covering all numerals $1$–$99$ with boundary markers (`꩑꩞` through `꩙꩙꩞`), V25 achieves $>98.5\%$ exact match on stanza headers.2. **Boundary Punctuation & Double Danda (`꩝꩝`) Collapse**:CTC decoders with standard temporal stride tend to merge closely adjacent vertical strokes into a single timestep ("blank collapse"). V25 synthesized variable Double Danda spacings ($2$px to $8$px) under varying Gaussian blur kernels, successfully training the network to distinguish single `꩝` (U+AA5D) from double `꩝꩝` (U+AA5D U+AA5D).3. **Diacritic Minimal Pair Disambiguation (`ꨲ` vs `ꨶ`)**:Under degraded ink conditions, Vowel Sign UE (`ꨲ`, U+AA32) and Medial Consonant Sign WA (`ꨶ`, U+AA36) exhibit extreme visual proximity under base glyphs `ꨀ`, `ꨓ`, `ꨚ`, `ꨆ`. Through 12,000 targeted adversarial minimal pairs, V25 forces the convolutional feature extractor to attend to subtle sub-stroke curvature differences, dropping the pair substitution rate from $18.4\%$ in V24 to $<1.2\%$ in V25.4. **Integration with Deterministic Unicode Cluster Normalization**:Operating strictly in Logical Storage Order, V25 pairs directly with `normalize_unicode` (via `scripts/generate_data.py`). Any localized CTC sequence permutations are deterministically regularized to the canonical Brahmic order:$$\text{Canonical Order} = \text{Base Consonant} + \text{Medials} + \text{Pre-Ra} + \text{Pre-Vowels} + \text{Post-Vowels} + \text{Finals}$$Eliminating visual ordering inversion errors while maintaining $100\%$ compliance with modern Unicode display engines.### 6.4 Multi-GPU Distributed Hardware Scaling & Cost EfficiencyTo support reproducible training across constrained computational budgets, we conducted multi-GPU benchmarks across four hardware environments:45 unmodified lines4. **Extreme Interlinear Overlap (Level 5)**: When severe paper wrinkling causes interlinear wave amplitude to exceed line spacing ($\text{Amplitude} > \text{Gap}$), 1D projection and horizontal bounding boxes collapse, indicating the need for 2D polygonal baseline tracking models in future iterations.### 8.5 Post-V25 Future Iterations (Planned V25.1 / V26 Improvements)Following the successful training and deployment of Model Version 25 (90.96% Sequence Accuracy), all subsequent pipeline enhancements are tracked systematically for future V25.1 and V26 releases (see [FUTURE_WORK.md](file:///FUTURE_WORK.md)):1. **Dual-Script Font Fallback & Glyph Validation**: Implementation of a coordinated rendering pipeline for mixed Cham and Vietnamese/Latin text with fontTools cmap validation across both scripts to eliminate tofu artifacts in bilingual annotations.2. **Dedicated Directional Motion-Blur Augmentation**: Physics-grounded Point Spread Function (PSF) kernels modeling hand tremor motion angles and shutter exposure times.3. **Manifest-Driven Exact Package Allocation**: Deterministic line count allocation per category instead of probabilistic multinomial sampling.
RESEARCH.md+33-14