Spaces:
Running
Running
Download ocr-studio/research.html from phucsd/cham-ocr-studio: direct link, hf CLI and curl.
- Browser
- Download file 113 kB
-
https://huggingface.co/spaces/phucsd/cham-ocr-studio/resolve/main/ocr-studio/research.html
- Command line
-
hf download hf://spaces/phucsd/cham-ocr-studio/ocr-studio/research.html
-
curl -L -o research.html https://huggingface.co/spaces/phucsd/cham-ocr-studio/resolve/main/ocr-studio/research.html
113 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Cham-OCR: A Deep-Learning OCR Pipeline for Unicode Eastern Cham, toward Historical Manuscript and Epigraphic Recognition — Technical Report</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; | |
| } | |
| html { | |
| scroll-behavior: smooth; | |
| scroll-padding-top: 85px; | |
| } | |
| section[id], h2[id], h3[id], [id] { | |
| scroll-margin-top: 85px; | |
| } | |
| 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 ; | |
| } | |
| .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 Technical Report</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 Orthography & Glyphs</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. Related Work</a> | |
| <ul class="toc-sublist"> | |
| <li><a href="#sec2-1" class="toc-sublink">2.1 Epigraphic Glyph Recognition</a></li> | |
| <li><a href="#sec2-2" class="toc-sublink">2.2 Deep Learning & Transliteration</a></li> | |
| <li><a href="#sec2-3" class="toc-sublink">2.3 Manuscript Preservation</a></li> | |
| <li><a href="#sec2-4" class="toc-sublink">2.4 System Positioning</a></li> | |
| </ul> | |
| </li> | |
| <li class="toc-item"> | |
| <a href="#sec3" class="toc-link">3. Detection & Line Segmentation</a> | |
| <ul class="toc-sublist"> | |
| <li><a href="#sec3-1" class="toc-sublink">3.1 Diacritic Collision Problem</a></li> | |
| <li><a href="#sec3-2" class="toc-sublink">3.2 Cham-DBNet Architecture</a></li> | |
| <li><a href="#sec3-3" class="toc-sublink">3.3 Indic Valley-Cut Heuristics</a></li> | |
| </ul> | |
| </li> | |
| <li class="toc-item"> | |
| <a href="#sec4" class="toc-link">4. Recognition Architecture</a> | |
| <ul class="toc-sublist"> | |
| <li><a href="#sec4-1" class="toc-sublink">4.1 SVTR-LCNet Backbone</a></li> | |
| <li><a href="#sec4-2" class="toc-sublink">4.2 Joint CTC & Attention Loss</a></li> | |
| <li><a href="#sec4-3" class="toc-sublink">4.3 Canonical Normalization</a></li> | |
| </ul> | |
| </li> | |
| <li class="toc-item"> | |
| <a href="#sec5" class="toc-link">5. Synthetic Generation Pipeline</a> | |
| <ul class="toc-sublist"> | |
| <li><a href="#sec5-1" class="toc-sublink">5.1 Data Scarcity Bottleneck</a></li> | |
| <li><a href="#sec5-2" class="toc-sublink">5.2 Dataset Partitioning & Dual Generators</a></li> | |
| <li><a href="#sec5-3" class="toc-sublink">5.3 cmap Glyph Tofu Safeguard</a></li> | |
| <li><a href="#sec5-4" class="toc-sublink">5.4 In-RAM Augmentations</a></li> | |
| </ul> | |
| </li> | |
| <li class="toc-item"> | |
| <a href="#sec6" class="toc-link">6. Empirical Benchmarks</a> | |
| <ul class="toc-sublist"> | |
| <li><a href="#sec6-1" class="toc-sublink">6.1 50-Test Benchmark (V23 vs V24)</a></li> | |
| <li><a href="#sec6-2" class="toc-sublink">6.2 200-Page Stress-Test Suite</a></li> | |
| <li><a href="#sec6-3" class="toc-sublink">6.3 Model Progression: V23 vs V24 vs V25 SOTA</a></li> | |
| <li><a href="#sec6-4" class="toc-sublink">6.4 Multi-GPU Hardware Scaling</a></li> | |
| </ul> | |
| </li> | |
| <li class="toc-item"> | |
| <a href="#sec7" class="toc-link">7. Production Serving</a> | |
| <ul class="toc-sublist"> | |
| <li><a href="#sec7-1" class="toc-sublink">7.1 Microservice Architecture</a></li> | |
| <li><a href="#sec7-2" class="toc-sublink">7.2 Concurrency & NumPy 2.x</a></li> | |
| </ul> | |
| </li> | |
| <li class="toc-item"> | |
| <a href="#sec8" class="toc-link">8. Limitations & Open Challenges</a> | |
| <ul class="toc-sublist"> | |
| <li><a href="#sec8-5" class="toc-sublink">8.5 Planned Post-V25 Iterations</a></li> | |
| </ul> | |
| </li> | |
| <li class="toc-item"><a href="#sec9" class="toc-link">9. Citation & References</a></li> | |
| </ul> | |
| </aside> | |
| <!-- Article Body --> | |
| <article class="article-main"> | |
| <div class="paper-tag-strip"> | |
| <span class="tag-pill tag-pill-accent">Technical Report / Research Preprint</span> | |
| <span class="tag-pill">Not Peer Reviewed</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">Unicode Eastern Cham (Akhar Thrah)</span> | |
| </div> | |
| <h1 class="paper-title">Cham-OCR: A Deep-Learning OCR Pipeline for Unicode Eastern Cham, toward Historical Manuscript and Epigraphic Recognition</h1> | |
| <div class="author-box"> | |
| <div class="author-info"> | |
| <span class="author-name">Phuc H. Nguyen</span> | |
| <span class="author-affiliation">Independent Researcher and Software Developer, Vietnam — Cham-OCR Project</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> | |
| <span><strong>Contact:</strong> <a href="mailto:phucsd@gmail.com" style="color: var(--accent-primary); font-weight: 600;">phucsd@gmail.com</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—primarily preserved in Eastern Cham (<em>Akhar Thrah</em>) alongside Western Cham (<em>Cam Srak</em>) traditions—represent a fragile, millennia-old Brahmic epigraphic and literary heritage in Southeast Asia. While this project validates an end-to-end deep learning OCR pipeline specifically on Unicode Eastern Cham (<em>Akhar Thrah</em>), Western Cham (<em>Cam Srak</em>), real physical manuscripts, and epigraphic stone carvings represent active and ongoing future extensions. Automatic transcription via Optical Character Recognition (OCR) has historically faced steep barriers due to complex Brahmic abugida orthography, multi-directional dependent vowel diacritics, predominantly continuous script (<em>scriptio continua</em>) in classical manuscripts, physical carrier degradation, and tight interlinear diacritic collisions. In this technical report, we describe the design, implementation, and empirical evaluation of an end-to-end deep learning pipeline and diagnostic transcription workbench engineered for Cham documents: (1) a hybrid text detection and line segmentation engine combining a fine-tuned <strong>Mobile DBNet (PPLCNetV3)</strong> with an <strong>Indic Valley-Cut Heuristic Engine</strong> that preserves boundary strokes via mathematical set-difference masking (<code>difference_update</code>) 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. Evaluations across a <strong>controlled 200-page synthetic document stress-test</strong> (903 textlines across 5 difficulty levels) and a <strong>50-test stratified failure-mode benchmark</strong> demonstrate robust textline detection with a <strong>100.0% line detection rate</strong> 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 (<strong>V25</strong>) achieves <strong>90.96% Sequence Accuracy</strong> and <strong>99.28% Normalized Edit Distance (CER 0.72%)</strong> 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 (<span class="cham-script">꩝꩝</span> vs <span class="cham-script">꩝</span>), eliminates numeral-to-character misclassifications (<span class="cham-script">꩔</span> vs <span class="cham-script">ꨤ</span>, <span class="cham-script">꩕</span> vs <span class="cham-script">ꨅ</span>), and robustly disambiguates subtle diacritic minimal pairs (<span class="cham-script">ꨲ</span> vs <span class="cham-script">ꨶ</span>). 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 <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 polities along coastal central and southern Vietnam from the 2nd to early 19th centuries. The script family descends from Southern Brahmic Grantha/Pallava lineages, evolving into two distinct extant traditions: | |
| </p> | |
| <ul> | |
| <li><strong>Eastern Cham (<em>Akhar Thrah</em>)</strong>: Inscribed and preserved predominantly in Ninh Thuận and Bình Thuận provinces (Vietnam). Historical manuscripts are executed on traditional bark-paper (<em>kertas</em>) or palm leaf with calligraphic bamboo pens.</li> | |
| <li><strong>Western Cham (<em>Cam Srak</em>)</strong>: Preserved by Cham communities in the Mekong Delta (An Giang, Tây Ninh) and Cambodia. It features distinctive stylistic glyph contours, regional ligature forms, and localized phonetic loan signs.</li> | |
| </ul> | |
| <p> | |
| Due to tropical climate conditions, ink bleed, microbiological decay, and physical fragmentation, remaining manuscript archives (such as the <em>Akayet Inra Patra</em>, <em>Ariya Po Pareng</em>, and sacred divinatory compendia) face significant preservation risks. Standard off-the-shelf OCR engines designed primarily for Latin or CJK scripts struggle significantly on historical Cham manuscripts due to fundamental typographical divergences. | |
| </p> | |
| <h3 id="sec1-2">1.2 Abugida Orthography & Multi-Directional Glyphs</h3> | |
| <p> | |
| Unlike alphabetic writing systems where letters follow a single horizontal axis, Cham is an <strong>abugida</strong> governed by complex spatial attachment rules: | |
| </p> | |
| <ol> | |
| <li><strong>Independent Vowels (<code>U+AA00</code>–<code>U+AA05</code>)</strong>: Six standalone vowel glyphs represent syllable-initial vowel phonemes without a preceding consonant base: | |
| <span class="cham-script">ꨀ</span> (U+AA00: <code>CHAM LETTER A</code>), | |
| <span class="cham-script">ꨁ</span> (U+AA01: <code>CHAM LETTER I</code>), | |
| <span class="cham-script">ꨂ</span> (U+AA02: <code>CHAM LETTER U</code>), | |
| <span class="cham-script">ꨃ</span> (U+AA03: <code>CHAM LETTER E</code>), | |
| <span class="cham-script">ꨄ</span> (U+AA04: <code>CHAM LETTER AI</code>), | |
| <span class="cham-script">ꨅ</span> (U+AA05: <code>CHAM LETTER O</code>). | |
| </li> | |
| <li><strong>Consonantal Inventory (<code>U+AA06</code>–<code>U+AA28</code>)</strong>: Thirty-five consonant glyphs carry an inherent vowel (/a/ or /ɔ/), beginning with <span class="cham-script">ꨆ</span> (U+AA06: <code>CHAM LETTER KA</code>) through <span class="cham-script">ꨨ</span> (U+AA28: <code>CHAM LETTER HA</code>), encompassing unaspirated, aspirated, nasal, and liquid articulation series.</li> | |
| <li><strong>Subjoined Medials (<code>U+AA33</code>–<code>U+AA36</code>)</strong>: Four medial consonants attach underneath or encircle the consonant base: | |
| Medial Ya (<span class="cham-script">ꨳ</span> U+AA33: <code>CHAM CONSONANT SIGN YA</code>), | |
| Medial Ra (<span class="cham-script">ꨴ</span> U+AA34: <code>CHAM CONSONANT SIGN RA</code>), | |
| Medial La (<span class="cham-script">ꨵ</span> U+AA35: <code>CHAM CONSONANT SIGN LA</code>), and | |
| Medial Wa (<span class="cham-script">ꨶ</span> U+AA36: <code>CHAM CONSONANT SIGN WA</code>). | |
| </li> | |
| <li><strong>Multi-Directional Dependent Vowels (<code>U+AA29</code>–<code>U+AA32</code>)</strong>: Dependent vowel signs attach across all four spatial quadrants around the base: | |
| <ul> | |
| <li><em>Above base</em>: Vowel Sign I (<span class="cham-script">ꨪ</span> U+AA2A), II (<span class="cham-script">ꨫ</span> U+AA2B), EI (<span class="cham-script">ꨬ</span> U+AA2C).</li> | |
| <li><em>Below base</em>: Vowel Sign U (<span class="cham-script">ꨭ</span> U+AA2D), UE (<span class="cham-script">ꨲ</span> U+AA32).</li> | |
| <li><em>Post-base / Dependent</em>: Vowel Sign AA (<span class="cham-script">ꨩ</span> U+AA29), OE (<span class="cham-script">ꨮ</span> U+AA2E), AU (<span class="cham-script">ꨱ</span> U+AA31).</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+AA30).</li> | |
| </ul> | |
| </li> | |
| <li><strong>Final Consonants & Signs ([<code>U+AA40</code>–<code>U+AA4D</code>, <code>U+AA25</code>])</strong>: Explicit syllable codas including separate base glyphs with extended terminal strokes (<code>U+AA40</code>–<code>U+AA4B</code>), combining coda marks (Final Ng <span class="cham-script">ꩃ</span> U+AA43, Final M / Anusvara <span class="cham-script">ꩌ</span> U+AA4C, Final H / Visarga <span class="cham-script">ꩍ</span> U+AA4D), and the base consonant <span class="cham-script">ꨥ</span> (<code>U+AA25</code> CHAM LETTER VA) which, per Unicode Standard Chapter 16 Table 16-16, functions without alteration in both initial and syllable-final positions (e.g., in syllables such as <span class="cham-script">ꨀꨍꨯꨱꨥ</span> and <span class="cham-script">ꨝꨗꨴꨭꨥ</span>).</li> | |
| <li><strong>Script Spacing Conventions</strong>: Many historical Cham manuscripts exhibit limited or inconsistent inter-word spacing, while modern printed Cham commonly uses spaces. Classical literary texts and verse compendia frequently exhibit continuous running script (<em>scriptio continua</em>), though section divisions, poetic hemistichs, or phrasing pauses are demarcated by punctuation marks (e.g., Danda <span class="cham-script">꩝</span>, Double Danda <span class="cham-script">꩞</span>, Triple Danda <span class="cham-script">꩟</span>) and occasional whitespace gaps.</li> | |
| <li><strong>Punctuation & Verse Markers</strong>: Traditional discourse is demarcated via Danda (<span class="cham-script">꩝</span> U+AA5D), Double Danda (<span class="cham-script">꩞</span> U+AA5E, also serving as section/stanza mark), and Triple Danda (<span class="cham-script">꩟</span> U+AA5F). Poetic stanzas frequently open 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 Consonant} + [\text{Medials}] + [\text{Pre-Vowels}] + [\text{Dependent Vowels}] + [\text{Finals / Signs}]$$ | |
| </div> | |
| <p> | |
| However, pre-vowels like <span class="cham-script">ꨯ</span> (Vowel Sign O, U+AA2F) and <span class="cham-script">ꨰ</span> (Vowel Sign AI, U+AA30) are rendered <em>visually to the left</em> of the base consonant. When an optical sequence decoder scans an image crop left-to-right, its visual perception encounters the pre-vowel ahead of the consonant glyph (e.g. perceiving <span class="cham-script">ꨯ</span> before base <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 resolve visual ordering with naive string replacements or visual-to-unicode cluster splitters damages valid multi-diacritic compounds containing subjoined medials (such as <span class="cham-script">ꨙꨳꨯꨮ</span>). Our system strictly mandates a deterministic post-OCR <strong>Logical Order Normalizer</strong> (Section 4.3) that re-aligns local visual permutations into standardized Unicode sequences without corrupting consonant-medial clusters. | |
| </div> | |
| </section> | |
| <!-- SECTION 2: RELATED WORK --> | |
| <section id="sec2"> | |
| <h2>2. Related Work on Cham Document Analysis & Epigraphy</h2> | |
| <h3 id="sec2-1">2.1 Early Epigraphic & Glyph Recognition</h3> | |
| <p> | |
| Automated processing of Cham script originated in the analysis of stone inscriptions from ancient Champa sanctuaries (Mỹ Sơn, Po Nagar, Đồng Dương). Nguyen, Schweyer, Le, Tran, & Vu (2019a) presented preliminary results on recognizing ancient Cham glyphs extracted from stone rubbings and photographs using Histogram of Oriented Gradients (HOG), Non-Parametric Weighted (NPW) features, and CNN-derived feature representations coupled with $k$-NN and linear SVM classifiers at the IEEE MAPR 2019 conference. Due to severe stone weathering, erosion, and irregular surface texture, isolated glyph classification across noisy background substrates was evaluated. | |
| </p> | |
| <p> | |
| To mitigate extreme sample scarcity in epigraphic corpora, Nguyen, Schweyer, Le, Tran, & Vu (2019b) evaluated data augmentation strategies and transfer learning from scripts of similar or the same language family to ancient stone inscription glyphs at the ICIAP 2019 Workshops (PatReCH), demonstrating quantitative gains on script-to-inscription transfer across weathered stone carvings. | |
| </p> | |
| <h3 id="sec2-2">2.2 Deep Learning for Cham Epigraphy & Transliteration</h3> | |
| <p> | |
| In his doctoral dissertation, Nguyen (2023) developed comprehensive document image processing and understanding methodologies dedicated to ancient Cham documents. His work investigated stone inscription image restoration, automatic glyph segmentation under rough stone substrate conditions, and deep convolutional representations for historical Brahmic scripts. | |
| </p> | |
| <p> | |
| Complementing glyph recognition, Nguyen, Burie, Le, & Schweyer (2022) proposed an effective multi-stage method for text line segmentation in historical document images presented at the 26th International Conference on Pattern Recognition (ICPR 2022), addressing line curvature and touching diacritics in historical archives. Expanding to linguistic representation, Nguyen, Burie, Le, & Schweyer (2023) introduced a two-step sequence transformer model for Cham-to-Latin script transliteration presented at the HIP@ICDAR 2023 workshop. Their system demonstrated the efficacy of sequence-to-sequence transformers in mapping recognized Cham text sequences to standardized Latin phonological romanizations (<em>Cam-Latin</em>). Most recently, Nguyen, Burie, Le, & Schweyer (2025) published a comprehensive study entitled <em>Text line segmentation approach combining deep learning model and traditional image processing techniques - application to transliteration of Cham manuscripts</em> in <em>Multimedia Tools and Applications</em>, evaluating text-line segmentation and automatic transliteration across 627 manuscript images and approximately 8,300 textlines (focusing on line segmentation and transliteration rather than end-to-end character OCR benchmarking). | |
| </p> | |
| <h3 id="sec2-3">2.3 Manuscript Preservation & Digitization Initiatives</h3> | |
| <p> | |
| Beyond epigraphy on stone, historical Cham manuscripts on paper (<em>kertas</em>) and palm-leaf have been documented through preservation missions. The Historic Cham Manuscripts of Vietnam collection in the Southeast Asia Digital Library (SEADL) contains 977 digitized manuscripts comprising more than 57,800 page scans. In addition, field surveys estimate approximately 3,000 physical manuscripts preserved within Cham community families and religious dignitaries across Vietnam and Cambodia. The French National Research Agency funded the CHAMDOC project (<em>Cham Documentation</em>, ANR-19-CE27-0018, 2019–2024) to support preservation, cataloging, and linguistic documentation. | |
| </p> | |
| <p> | |
| However, despite the preservation of tens of thousands of scanned folios, almost none of these archives possess open, machine-readable character-level or line-level bounding box ground-truth annotations suitable for training supervised deep learning models. The bottleneck for Cham OCR is therefore not an absolute absence of physical manuscripts, but rather the severe scarcity of annotated, verified training ground truth. | |
| </p> | |
| <h3 id="sec2-4">2.4 Positioning of the Present System</h3> | |
| <p> | |
| Prior research has focused predominantly on either <strong>isolated glyph recognition on stone inscriptions</strong>, <strong>downstream transliteration of cleaned text</strong>, or academic research prototypes evaluated on private manuscript subsets. In contrast, the system presented in this report addresses the complete <strong>end-to-end continuous document pipeline</strong> for historical manuscripts: | |
| </p> | |
| <ul> | |
| <li>Full-page line detection and segmentation robust to undulating baselines and tight interlinear diacritics.</li> | |
| <li>End-to-end continuous textline recognition without manual character pre-segmentation.</li> | |
| <li>Deterministic canonical reordering adhering strictly to the official Unicode standard.</li> | |
| <li>Production-grade serving designed for cultural heritage researchers and native community access.</li> | |
| </ul> | |
| </section> | |
| <!-- Section 3 --> | |
| <section id="sec3"> | |
| <h2>3. Text Detection & Indic Line Segmentation (Cham-DBNet)</h2> | |
| <h3 id="sec3-1">3.1 The Interlinear Diacritic Collision Problem</h3> | |
| <p> | |
| In digital modeling and synthetic text rendering at nominal glyph heights (32–36px), interlinear clearance often narrows to 3–12 pixels between adjacent lines (with ascender excursions extending up to \(+18\text{px}\) and descender excursions down to \(-22\text{px}\) in normalized coordinate space). Because upper dependent vowels reach high above the core text band and subjoined medials plunge below, the ascenders of line \(n+1\) routinely touch or intertwine with the descenders of line \(n\) under dense formatting. Standard off-the-shelf text detection models (such as baseline DBNet trained on natural scene Latin or CJK text) frequently encounter two severe failure modes when applied to dense historical manuscripts: | |
| </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="sec3-2">3.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> (scale 0.75)</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 (Dice Loss).</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>Binarization Threshold</td> | |
| <td><code>0.25</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>Max Candidates</td> | |
| <td><code>1500</code></td> | |
| <td>Accommodates densely packed multi-line folios without candidate truncation.</td> | |
| </tr> | |
| <tr> | |
| <td>Training Dataset</td> | |
| <td>2,000 document pages</td> | |
| <td>50% synthesized with narrow interline spacing (3–10px) to penalize box merging (as configured in <code>launch_h100_full_pipeline.py</code>).</td> | |
| </tr> | |
| <tr> | |
| <td>Optimizer & Schedule</td> | |
| <td>Adam (Cosine decay, initial lr 0.001, 5 warmup epochs, L2 factor 5e-5)</td> | |
| <td>Stable gradient convergence without aggressive parameter divergence.</td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| </div> | |
| <p> | |
| <strong>Empirical Line Detection Performance</strong>: Evaluated within the complete document processing pipeline on our 200-page synthetic stress-test suite (<code>evaluation_report.json</code>), Cham-DBNet achieves high line extraction fidelity across difficulty levels: | |
| </p> | |
| <div class="table-responsive"> | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Stress Tier / Evaluation Condition</th> | |
| <th class="num">GT Lines</th> | |
| <th class="num">Detected</th> | |
| <th class="num">Line Detection Rate</th> | |
| <th>Empirical Observation</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>Level 1: Standard (Gap 25–35px)</td> | |
| <td class="num">201</td> | |
| <td class="num">201</td> | |
| <td class="num"><span class="metric-badge metric-good">100.0%</span></td> | |
| <td>Flawless detection across clean rectilinear textlines.</td> | |
| </tr> | |
| <tr> | |
| <td>Level 2: Aged Paper (Noise, Skew ≤ 2°)</td> | |
| <td class="num">189</td> | |
| <td class="num">189</td> | |
| <td class="num"><span class="metric-badge metric-good">100.0%</span></td> | |
| <td>Resilient to aged background texture and paper fiber noise.</td> | |
| </tr> | |
| <tr> | |
| <td>Level 3: Narrow Gap (Gap 8–14px)</td> | |
| <td class="num">170</td> | |
| <td class="num">170</td> | |
| <td class="num"><span class="metric-badge metric-good">100.0%</span></td> | |
| <td>Zero line merging on tightly spaced manuscript lines.</td> | |
| </tr> | |
| <tr> | |
| <td>Level 4: Wavy Sinusoid (Warping 3–5.5px)</td> | |
| <td class="num">177</td> | |
| <td class="num">176</td> | |
| <td class="num"><span class="metric-badge metric-good">99.44%</span></td> | |
| <td>Graceful degradation under undulating non-linear baselines.</td> | |
| </tr> | |
| <tr> | |
| <td>Level 5: Extreme Overlap (Amplitude > Gap)</td> | |
| <td class="num">166</td> | |
| <td class="num">102</td> | |
| <td class="num"><span class="metric-badge metric-warn">61.45%</span></td> | |
| <td>Empirical breaking point where intersecting strokes cause line merging.</td> | |
| </tr> | |
| <tr> | |
| <td><strong>Overall Suite Summary</strong></td> | |
| <td class="num"><strong>903</strong></td> | |
| <td class="num"><strong>838</strong></td> | |
| <td class="num"><strong><span class="metric-badge metric-good">92.80%</span></strong></td> | |
| <td><strong>Average end-to-end CPU latency: 1.33s / page</strong></td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| </div> | |
| <h3 id="sec3-3">3.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 documents where interline gap \(\ge 0.35 \times \text{height}\) and initial confidence \(\ge 0.75\), multi-crop splitting is bypassed entirely to guarantee zero regression on pristine folios.</li> | |
| </ol> | |
| </section> | |
| <!-- SECTION 4 --> | |
| <section id="sec4"> | |
| <h2>4. Neural Text Recognition Architecture (Cham-SVTR)</h2> | |
| <h3 id="sec4-1">4.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). 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 unspaced 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="sec4-2">4.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 to provide lightweight, low-latency single-thread CPU execution without costly beam search. | |
| </p> | |
| <h3 id="sec4-3">4.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: normalize_unicode</span> | |
| <button class="copy-btn" onclick="navigator.clipboard.writeText(document.getElementById('norm-code').innerText)">Copy</button> | |
| </div> | |
| <pre id="norm-code"><code>def normalize_unicode(text: str) -> str: | |
| # Enforces Canonical Brahmic Logical Order on CTC decoded Cham text: | |
| # Base Consonant -> Medial RA/LA -> Medial YA/WA -> Pre-Vowels (O/AI) -> | |
| # Other Dependent Vowels -> Vowel Lengthener AA -> Final Consonants / Signs (incl. Final VA) | |
| # Example: Corrects visual sequence 'ꨙꨯꨳꨮ' into canonical 'ꨙꨳꨯꨮ'. | |
| clusters = parse_unicode_clusters(text) | |
| uni_clusters = [visual_to_unicode_cluster(c) for c in clusters] | |
| return "".join("".join(c) for c in uni_clusters)</code></pre> | |
| </div> | |
| </section> | |
| <!-- SECTION 5 --> | |
| <section id="sec5"> | |
| <h2>5. Synthetic Dataset Generation & Hard-Example Mining</h2> | |
| <h3 id="sec5-1">5.1 The Data Scarcity Bottleneck</h3> | |
| <p> | |
| Deep neural OCR networks require hundreds of thousands of diverse labeled textlines. However, surviving physical Cham manuscripts lack open character-level bounding box ground truth. To overcome this limitation, we engineered an algorithmic synthesizer (<code>scripts/generate_data.py</code>) capable of rendering 150,000 diverse textline crops from authentic literary corpora. | |
| </p> | |
| <h3 id="sec5-2">5.2 Calibrated Synthetic Dataset Partitioning & Dual-Generator Architecture</h3> | |
| <p> | |
| To support both baseline reproducibility and ongoing experimental modeling, the repository provides two distinct synthetic dataset generation pipelines: | |
| </p> | |
| <h4 style="margin-top: 1.25rem; font-size: 1.05rem; color: var(--text-primary);">Pipeline A: Baseline General Generator (<code>scripts/generate_data.py</code>)</h4> | |
| <p> | |
| The baseline generator produces a 150,000 textline corpus partitioned into <strong>15% evaluation/locked splits</strong> (22,500 lines: <code>val_clean_short</code> 3%, <code>val_clean_long</code> 3%, <code>val_noisy_short</code> 3%, <code>val_noisy_long</code> 3%, <code>locked_test</code> 3%) and an <strong>85% training split</strong> (127,500 lines) structured across 6 calibrated sub-categories: | |
| </p> | |
| <div class="table-responsive"> | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Training Sub-Category</th> | |
| <th class="num">Proportion</th> | |
| <th class="num">Line Count</th> | |
| <th>Composition & Generation Protocol</th> | |
| <th>Target Failure Mode Addressed</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td><code>train_clean_short</code></td> | |
| <td class="num">25%</td> | |
| <td class="num">31,875</td> | |
| <td>Short clean literary phrases (1–4 tokens).</td> | |
| <td>Fast convergence on high-frequency base consonants and common syllables.</td> | |
| </tr> | |
| <tr> | |
| <td><code>train_clean_medium</code></td> | |
| <td class="num">20%</td> | |
| <td class="num">25,500</td> | |
| <td>Medium-length lines (5–8 tokens) from classical texts (<em>Akayet Inra Patra</em>, <em>Ariya Po Pareng</em>).</td> | |
| <td>Teaches authentic Cham phonotactic and n-gram transitions.</td> | |
| </tr> | |
| <tr> | |
| <td><code>train_clean_long</code></td> | |
| <td class="num">15%</td> | |
| <td class="num">19,125</td> | |
| <td>Long full verse hemistichs and prose sentences (9+ tokens).</td> | |
| <td>Robustness to full-line receptive fields and CTC sequence alignment without truncation.</td> | |
| </tr> | |
| <tr> | |
| <td><code>train_noisy_short</code></td> | |
| <td class="num">15%</td> | |
| <td class="num">19,125</td> | |
| <td>Short lines rendered with Point Spread Function (PSF) blur, noise, and lighting gradients.</td> | |
| <td>Invariance to archival handling artifacts, tremor, and fading ink.</td> | |
| </tr> | |
| <tr> | |
| <td><code>train_noisy_long</code></td> | |
| <td class="num">15%</td> | |
| <td class="num">19,125</td> | |
| <td>Long verse lines with severe photometric degradation and spatial elastic distortion.</td> | |
| <td>Prevents alignment collapse on degraded multi-word lines.</td> | |
| </tr> | |
| <tr> | |
| <td><code>train_hard_examples</code></td> | |
| <td class="num">10%</td> | |
| <td class="num">12,750</td> | |
| <td>Adversarial minimal pairs (<span class="cham-script">ꨲ</span> vs <span class="cham-script">ꨶ</span>, <span class="cham-script">꩝꩝</span> vs <span class="cham-script">꩝</span>), verse numerals (1–99) with section marks (<span class="cham-script">꩑꩞</span>), and stacked subjoined clusters.</td> | |
| <td>Eliminates CTC misclassification of numerals as letters (<span class="cham-script">꩔</span> vs <span class="cham-script">ꨤ</span>, <span class="cham-script">꩕</span> vs <span class="cham-script">ꨅ</span>) and diacritic collapsing.</td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| </div> | |
| <h4 style="margin-top: 1.5rem; font-size: 1.05rem; color: var(--text-primary);">Pipeline B: Experimental V25 Generator (<code>scripts/generate_data_v25.py</code>)</h4> | |
| <p> | |
| For the V25 experimental iteration, a dedicated multi-threaded generator (<code>generate_data_v25.py</code>) synthesizes 150,000 textline images (140,000 train + 10,000 validation) directly synchronized with <code>configs/v25_dataset_manifest.json</code> across 5 core pillars: | |
| </p> | |
| <ol style="margin-bottom: 1.5rem; line-height: 1.7; color: var(--text-secondary);"> | |
| <li><strong>Canonical Cham Literature (43.3% / 65,000 lines)</strong>: Classical literary vocabulary (<em>Po Klong Garai</em>, 57-stanza verse).</li> | |
| <li><strong>Anti-Motion Blur Base (20.0% / 30,000 lines)</strong>: Clean base images paired with dynamic in-RAM directional motion blur (\(7\times 7\) to \(13\times 13\)) and defocus.</li> | |
| <li><strong>Inline Bilingual Code-Switching (16.7% / 25,000 lines)</strong>: Intra-line mixed phrases with Vietnamese diacritics and Latin annotations.</li> | |
| <li><strong>Stanza Numerals & Boundary Punctuation (12.0% / 18,000 lines)</strong>: Verse numbers \(1\)–\(99\) (<span class="cham-script">꩑꩞</span>..<span class="cham-script">꩙꩙꩞</span>) and boundary marks (<span class="cham-script">꩞</span>, <code>:</code>, <code>–</code>).</li> | |
| <li><strong>Adversarial Minimal Pairs (8.0% / 12,000 lines)</strong>: Micro-stroke pairs (<span class="cham-script">ꨲ</span> U+AA32 Vowel Sign UE vs <span class="cham-script">ꨶ</span> U+AA36 Medial WA, variable Double Danda <span class="cham-script">꩝꩝</span> spacing 2–8px, 3-tier diacritic stacks).</li> | |
| </ol> | |
| <div class="academic-callout callout-info"> | |
| <div class="callout-title">✅ Completed Multi-Stage Training (V25)</div> | |
| 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 (<code>best_accuracy.pdparams</code>, 58.84 MB) achieved <strong>90.96% Sequence Accuracy</strong> and <strong>99.28% Normalized Edit Distance (CER 0.72%)</strong> on the 10,000 frozen validation suite. | |
| </div> | |
| <h3 id="sec5-3">5.3 Digital Typefaces & TrueType cmap Tofu Glyph Safeguards</h3> | |
| <p> | |
| When rendering synthetic text, digital Cham typefaces must be verified for glyph coverage. The primary bundled and reproducible typeface distributed directly within this repository is <strong>Noto Sans Cham</strong> (<code>Regular</code>, <code>Bold</code>, <code>Black</code>; SIL Open Font License 1.1, located in <code>ocr-training/data/fonts/</code>). External reference typefaces evaluated during research—including <em>Cham Roman</em>, <em>EFEO Cham</em>, and community fonts—are not redistributed in this repository and must be acquired independently if researchers wish to reproduce specific historical font variations. | |
| </p> | |
| <p> | |
| To prevent missing Unicode codepoints from producing blank rectangles ("tofu" glyphs), our generator incorporates pre-render verification via <code>fontTools.ttLib</code> to extract each font's <code>cmap</code> table. Candidate strings are inspected character-by-character; any string containing unmapped glyphs for the active font is rejected prior to rasterization. | |
| </p> | |
| <h3 id="sec5-4">5.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 6 --> | |
| <section id="sec6"> | |
| <h2>6. Empirical Benchmarks & Quantitative Evaluations</h2> | |
| <h3 id="sec6-1">6.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, logged in <code>benchmark_50_tests_results.json</code> and <code>benchmark_50_tests_results_v24.json</code>: | |
| </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: Tilt & Perspective</td> | |
| <td class="num">5</td> | |
| <td class="num">22.14%</td> | |
| <td class="num"><strong>0.71%</strong></td> | |
| <td class="num"><span class="metric-badge metric-good">-21.43%</span></td> | |
| <td class="num">0.0%</td> | |
| <td class="num"><strong>100.0%</strong></td> | |
| <td class="num">0.982</td> | |
| </tr> | |
| <tr> | |
| <td>Cat 9: Stroke Degradation</td> | |
| <td class="num">5</td> | |
| <td class="num">26.67%</td> | |
| <td class="num"><strong>6.67%</strong></td> | |
| <td class="num"><span class="metric-badge metric-good">-20.00%</span></td> | |
| <td class="num">0.0%</td> | |
| <td class="num"><strong>80.0%</strong></td> | |
| <td class="num">0.928</td> | |
| </tr> | |
| <tr> | |
| <td>Cat 10: Diacritics & Punctuation</td> | |
| <td class="num">5</td> | |
| <td class="num">28.72%</td> | |
| <td class="num"><strong>22.19%</strong></td> | |
| <td class="num"><span class="metric-badge metric-good">-6.53%</span></td> | |
| <td class="num">0.0%</td> | |
| <td class="num"><strong>40.0%</strong></td> | |
| <td class="num">0.913</td> | |
| </tr> | |
| <tr style="font-weight: 700; background: var(--bg-subtle);"> | |
| <td>Overall Benchmark Average</td> | |
| <td class="num">50</td> | |
| <td class="num">28.17%</td> | |
| <td class="num"><strong>13.88%</strong></td> | |
| <td class="num"><span class="metric-badge metric-good">-14.29%</span></td> | |
| <td class="num">4.0%</td> | |
| <td class="num"><strong>50.0%</strong></td> | |
| <td class="num">0.923</td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| </div> | |
| <h3 id="sec6-2">6.2 Controlled 200-Page Synthetic Document Stress-Test (903 Textlines)</h3> | |
| <p> | |
| To establish the operational limits of the complete end-to-end pipeline (Cham-DBNet + Cham-SVTR v24), we evaluated a <strong>controlled synthetic stress-test suite</strong> of 200 generated page images comprising 903 ground-truth textlines. Generated by <code>ocr-benchmark/scripts/generate_benchmark_200.py</code>, this suite renders authentic literary passages under calibrated geometric and photometric stress across 5 difficulty tiers: | |
| </p> | |
| <div class="table-responsive"> | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Difficulty Tier</th> | |
| <th>Stress & Degradation Profile</th> | |
| <th class="num">Samples</th> | |
| <th class="num">GT Lines</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: Standard</td> | |
| <td>Line gap 25–35px, rectilinear alignment, white background.</td> | |
| <td class="num">40</td> | |
| <td class="num">201</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 texture, mild dust grain, slight skew (\(\le 2^\circ\)).</td> | |
| <td class="num">40</td> | |
| <td class="num">189</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 interline gap 8–14px, micro-waviness (1–2px).</td> | |
| <td class="num">40</td> | |
| <td class="num">170</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 warping (amp 3–5.5px), perspective tilt (0.03–0.05), gap 5–10px.</td> | |
| <td class="num">40</td> | |
| <td class="num">177</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. Intersecting boundary strokes.</td> | |
| <td class="num">40</td> | |
| <td class="num">166</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">0.99s</td> | |
| </tr> | |
| <tr style="font-weight: 700; background: var(--bg-subtle);"> | |
| <td>Overall Suite Summary</td> | |
| <td>200 synthetic document images, 903 textlines total.</td> | |
| <td class="num">200</td> | |
| <td class="num">903</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="sec6-3">6.3 Model Progression & Empirical Validation: V23 vs V24 vs V25 SOTA</h3> | |
| <p> | |
| Across iterative development cycles, we evaluated the trajectory of the Cham-SVTR architecture across three foundational milestones: <strong>Version 23</strong> (visual ordering legacy), <strong>Version 24</strong> (first logical ordering baseline), and <strong>Version 25</strong> (current production State-Of-The-Art). Quantitative validation on the standardized 10,000 frozen validation split (<code>cham_v25_val_freeze.zip</code>) documents the compounding gains achieved through lexicon expansion, resolution widening, and targeted hard-example synthesis: | |
| </p> | |
| <div class="table-responsive"> | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Metric / Dimension</th> | |
| <th class="num">Version 23 (Visual Legacy)</th> | |
| <th class="num">Version 24 (Logical Baseline)</th> | |
| <th class="num">Version 25 (SOTA Production)</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td><strong>Orthographic Representation</strong></td> | |
| <td class="num">Visual Rendering Order</td> | |
| <td class="num">Logical Brahmic Order</td> | |
| <td class="num"><strong style="color: var(--accent-primary);">Logical Brahmic Order</strong></td> | |
| </tr> | |
| <tr> | |
| <td><strong>Lexicon Dictionary Size</strong></td> | |
| <td class="num">153 tokens</td> | |
| <td class="num">156 tokens</td> | |
| <td class="num"><strong>162 tokens</strong> (+Numerals 1–99, Mark <span class="cham-script">꩞</span>)</td> | |
| </tr> | |
| <tr> | |
| <td><strong>Input Resolution \((C, H, W)\)</strong></td> | |
| <td class="num">\([3, 48, 320]\)</td> | |
| <td class="num">\([3, 48, 320]\)</td> | |
| <td class="num"><strong>\([3, 48, 480]\)</strong> (Long Stanzas)</td> | |
| </tr> | |
| <tr> | |
| <td><strong>Frozen Val Sequence Accuracy</strong></td> | |
| <td class="num">84.12%</td> | |
| <td class="num">88.94%</td> | |
| <td class="num"><strong style="color: var(--color-success, #2e7d32);">90.96%</strong> (+2.02% over V24)</td> | |
| </tr> | |
| <tr> | |
| <td><strong>Normalized Edit Distance (Norm-ED)</strong></td> | |
| <td class="num">96.85%</td> | |
| <td class="num">98.61%</td> | |
| <td class="num"><strong style="color: var(--color-success, #2e7d32);">99.28%</strong></td> | |
| </tr> | |
| <tr> | |
| <td><strong>Character Error Rate (CER)</strong></td> | |
| <td class="num">3.15%</td> | |
| <td class="num">1.39%</td> | |
| <td class="num"><strong style="color: var(--color-success, #2e7d32);">0.72%</strong> (-48.2% vs V24)</td> | |
| </tr> | |
| <tr> | |
| <td><strong>Inference Throughput (Dual T4)</strong></td> | |
| <td class="num">158.2 FPS</td> | |
| <td class="num">154.6 FPS</td> | |
| <td class="num"><strong>143.57 FPS</strong></td> | |
| </tr> | |
| <tr> | |
| <td><strong>Training Regimen</strong></td> | |
| <td class="num">40 epochs (1 stage)</td> | |
| <td class="num">40 epochs (2 stages)</td> | |
| <td class="num"><strong>40 epochs (3 stages, 87,480 steps)</strong></td> | |
| </tr> | |
| <tr> | |
| <td><strong>Model Parameter Footprint</strong></td> | |
| <td class="num">58.82 MB</td> | |
| <td class="num">58.83 MB</td> | |
| <td class="num"><strong>58.84 MB</strong> (<code>best_accuracy.pdparams</code>)</td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| </div> | |
| <h4 style="margin-top: 1.5rem; font-size: 1.05rem; color: var(--text-primary);">Detailed Error Mode Resolution & Paleographic Breakthroughs in V25</h4> | |
| <ol style="margin-bottom: 1.5rem; line-height: 1.7; color: var(--text-secondary);"> | |
| <li><strong>Stanza Numerals vs Consonant Disambiguation</strong>: | |
| Prior iterations suffered from CTC blank collapse where Western and Eastern Cham digit ligatures were decoded as visually similar consonants: <span class="cham-script">꩔</span> (digit 4) was misclassified as <span class="cham-script">ꨤ</span> (<em>la</em>), <span class="cham-script">꩕</span> (digit 5) as <span class="cham-script">ꨅ</span> (<em>e</em>) or <span class="cham-script">ꨂ</span> (<em>u</em>), and verse markers like <span class="cham-script">꩑꩞</span> collapsed into <span class="cham-script">ꨩꩌ</span>. Incorporating 18,000 dedicated adversarial samples covering numerals \(1\)–\(99\) with boundary markers (<span class="cham-script">꩑꩞</span> through <span class="cham-script">꩙꩙꩞</span>) achieved \(>98.5\%\) exact match on stanza headers. | |
| </li> | |
| <li><strong>Boundary Punctuation & Double Danda (<span class="cham-script">꩝꩝</span>) Spacing</strong>: | |
| CTC decoders with standard temporal stride tend to merge closely adjacent vertical strokes into a single timestep. V25 synthesized variable Double Danda spacings (\(2\)px to \(8\)px) under varying blur kernels, training the network to distinguish single <span class="cham-script">꩝</span> (U+AA5D) from double <span class="cham-script">꩝꩝</span> (U+AA5D U+AA5D). | |
| </li> | |
| <li><strong>Diacritic Minimal Pair Disambiguation (<span class="cham-script">ꨲ</span> vs <span class="cham-script">ꨶ</span>)</strong>: | |
| Under degraded ink conditions, Vowel Sign UE (<span class="cham-script">ꨲ</span>, U+AA32) and Medial Consonant Sign WA (<span class="cham-script">ꨶ</span>, U+AA36) exhibit extreme visual proximity under base glyphs <span class="cham-script">ꨀ</span>, <span class="cham-script">ꨓ</span>, <span class="cham-script">ꨚ</span>, <span class="cham-script">ꨆ</span>. 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. | |
| </li> | |
| <li><strong>Integration with Deterministic Unicode Cluster Normalization</strong>: | |
| Operating strictly in Logical Storage Order, V25 pairs directly with <code>normalize_unicode</code> (via <code>scripts/generate_data.py</code>). Any localized CTC sequence permutations are deterministically regularized to the canonical Brahmic order: \(\text{Base} + \text{Medials} + \text{Pre-Ra} + \text{Pre-Vowels} + \text{Post-Vowels} + \text{Finals}\), eliminating ordering inversion errors while maintaining 100% compliance with modern Unicode display engines. | |
| </li> | |
| </ol> | |
| <h3 id="sec6-4">6.4 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">64 (32x2)</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 7 --> | |
| <section id="sec7"> | |
| <h2>7. Production Serving & Deployment Infrastructure</h2> | |
| <h3 id="sec7-1">7.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="sec7-2">7.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 np | |
| if not hasattr(np, 'sctypes'): | |
| np.sctypes = {'int': [np.int8, np.int16, np.int32, np.int64], | |
| 'uint': [np.uint8, np.uint16, np.uint32, np.uint64], | |
| 'float': [np.float16, np.float32, np.float64], | |
| 'complex': [np.complex64, np.complex128], | |
| 'others': [bool, object, bytes, str]} | |
| if not hasattr(np, 'bool'): np.bool = bool | |
| if not hasattr(np, 'int'): np.int = int | |
| if not hasattr(np, 'float'): np.float = float | |
| if not hasattr(np, 'typeDict'): np.typeDict = {}</code></pre> | |
| </div> | |
| </li> | |
| </ul> | |
| </section> | |
| <!-- SECTION 8 --> | |
| <section id="sec8"> | |
| <h2>8. Limitations & Open Research Challenges</h2> | |
| <p> | |
| While our pipeline demonstrates substantial gains on synthetic and semi-controlled documents, rigorous academic honesty requires acknowledging the following boundaries: | |
| </p> | |
| <ul> | |
| <li><strong>Synthetic-to-Real Domain Gap</strong>: The neural recognizer is trained predominantly on synthetic textlines rendered with bundled <em>Noto Sans Cham</em> (SIL OFL 1.1). Historical manuscripts feature idiosyncratic scribal hands, variable ink viscosity, and non-standard ligature variations that may exhibit lower recognition confidence in the field.</li> | |
| <li><strong>Absence of Large-Scale Real Manuscript Ground Truth</strong>: Due to the acute scarcity of digitized historical Cham archives with line-level annotations, current benchmarks rely on controlled synthetic stress-tests and curated test slices. Establishing an open, expert-verified historical palm-leaf manuscript benchmark represents an urgent necessity requiring future collaborative scholarship with native Cham elders and linguists.</li> | |
| <li><strong>Severe Biological Degradation & Epigraphy</strong>: Inscription stone rubbings and severely mold-damaged palm leaves (where character ink has substantially eroded) remain beyond the capabilities of pure vision-based CTC sequence models. Integrating masked language models (MLMs) trained on historical Cham corpora is an active subject of future study.</li> | |
| <li><strong>Extreme Interlinear Overlap (Level 5)</strong>: 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.</li> | |
| </ul> | |
| <h3 id="sec8-5">8.5 Post-V25 Future Iterations (Planned V25.1 / V26 Improvements)</h3> | |
| <p> | |
| Following the successful training and deployment of Model Version 25 (90.96% Sequence Accuracy), all subsequent pipeline enhancements are tracked systematically in <a href="https://github.com/phucsd/Cham-OCR/blob/main/FUTURE_WORK.md" target="_blank" rel="noopener noreferrer" style="color: var(--accent-primary); font-weight: 600;">FUTURE_WORK.md</a>: | |
| </p> | |
| <ol style="margin-bottom: 1.5rem; line-height: 1.7; color: var(--text-secondary);"> | |
| <li><strong>Dual-Script Font Fallback & Combined Glyph Validation</strong>: Coordinated rendering pipeline for mixed Cham and Vietnamese/Latin text with fontTools cmap validation across both scripts to eliminate tofu artifacts in bilingual annotations.</li> | |
| <li><strong>Dedicated Directional Motion-Blur Augmentation</strong>: Physics-grounded Point Spread Function (PSF) kernels modeling hand tremor motion angles and camera exposure duration.</li> | |
| <li><strong>Manifest-Driven Exact Package Allocation</strong>: Deterministic line count allocation per category instead of probabilistic multinomial sampling.</li> | |
| <li><strong>Deterministic Frozen Validation Generation</strong>: Pre-generated, permanent frozen validation splits for zero-variance benchmark comparisons across training stages.</li> | |
| </ol> | |
| </section> | |
| <!-- SECTION 9 --> | |
| <section id="sec9"> | |
| <h2>9. 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_pipeline, | |
| author = {Nguyen, Phuc H.}, | |
| title = {Cham-OCR: A Deep-Learning OCR Pipeline for Unicode Eastern Cham, toward Historical Manuscript and Epigraphic Recognition}, | |
| year = {2026}, | |
| publisher = {GitHub}, | |
| url = {https://github.com/phucsd/Cham-OCR}, | |
| note = {Production web service: https://ocr.cham.asia} | |
| }</code></pre> | |
| </div> | |
| <h3>Academic 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] Nguyen, M.-T., Schweyer, A.-V., Le, T.-L., Tran, T.-H., & Vu, H. (2019a). <em>Preliminary Results on Ancient Cham Glyph Recognition from Cham Inscription Images</em>. In 2019 International Conference on Multimedia Analysis and Pattern Recognition (MAPR 2019), IEEE, pp. 1–6. DOI: <a href="https://doi.org/10.1109/MAPR.2019.8743540" target="_blank" rel="noopener noreferrer">10.1109/MAPR.2019.8743540</a> | |
| </div> | |
| <div class="ref-item"> | |
| [3] Nguyen, M.-T., Schweyer, A.-V., Le, T.-L., Tran, T.-H., & Vu, H. (2019b). <em>Improving Ancient Cham Glyph Recognition Using Data Augmentation and Transfer Learning</em>. In International Conference on Image Analysis and Processing (ICIAP 2019 Workshops: PatReCH), Springer, Cham, LNCS 11808, pp. 115–125. DOI: <a href="https://doi.org/10.1007/978-3-030-30754-7_12" target="_blank" rel="noopener noreferrer">10.1007/978-3-030-30754-7_12</a> | |
| </div> | |
| <div class="ref-item"> | |
| [4] Nguyen, T.-N. (2023). <em>Segmentation, Recognition and Indexing of Cham characters in Cham documents</em> (<em>Segmentation, reconnaissance et indexation des caractères Cham dans les documents Cham</em>). Ph.D. Dissertation, Université de La Rochelle, France. | |
| </div> | |
| <div class="ref-item"> | |
| [5] Nguyen, T.-N., Burie, J.-C., Le, T.-L., & Schweyer, A.-V. (2023). <em>A Two-Step Sequence Transformer Based Method for Cham to Latin Script Transliteration</em>. In Proceedings of the 7th International Workshop on Historical Document Imaging and Processing (HIP@ICDAR 2023), ACM, pp. 25–30. DOI: <a href="https://doi.org/10.1145/3604951.3605525" target="_blank" rel="noopener noreferrer">10.1145/3604951.3605525</a> | |
| </div> | |
| <div class="ref-item"> | |
| [6] Nguyen, T.-N., Burie, J.-C., Le, T.-L., & Schweyer, A.-V. (2022). <em>An effective method for text line segmentation in historical document images</em>. In 26th International Conference on Pattern Recognition (ICPR 2022), IEEE, pp. 2686–2692. DOI: <a href="https://doi.org/10.1109/ICPR56361.2022.9956617" target="_blank" rel="noopener noreferrer">10.1109/ICPR56361.2022.9956617</a> | |
| </div> | |
| <div class="ref-item"> | |
| [7] Nguyen, T.-N., Burie, J.-C., Le, T.-L., & Schweyer, A.-V. (2025). <em>Text line segmentation approach combining deep learning model and traditional image processing techniques - application to transliteration of Cham manuscripts</em>. <em>Multimedia Tools and Applications</em>, Springer. DOI: <a href="https://doi.org/10.1007/s11042-025-20602-x" target="_blank" rel="noopener noreferrer">10.1007/s11042-025-20602-x</a> | |
| </div> | |
| <div class="ref-item"> | |
| [8] ANR CHAMDOC Project. (2019–2024). <em>Cham Documentation (CHAMDOC)</em>, Project ANR-19-CE27-0018, Agence Nationale de la Recherche, France. | |
| </div> | |
| <div class="ref-item"> | |
| [9] 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"> | |
| [10] 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"> | |
| [11] 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"> | |
| [12] 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. | Contact: <a href="mailto:phucsd@gmail.com" style="color: var(--accent-primary); font-weight: 600;">phucsd@gmail.com</a></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 & Anchor Offset Script --> | |
| <script> | |
| document.addEventListener('DOMContentLoaded', () => { | |
| const links = document.querySelectorAll('.toc-link, .toc-sublink'); | |
| const sections = []; | |
| const NAV_OFFSET = 85; // 58px navbar + 27px breathing margin | |
| links.forEach(link => { | |
| const href = link.getAttribute('href'); | |
| if (href && href.startsWith('#')) { | |
| const target = document.querySelector(href); | |
| if (target) { | |
| sections.push({ link, target }); | |
| link.addEventListener('click', (e) => { | |
| e.preventDefault(); | |
| const targetTop = target.getBoundingClientRect().top + window.pageYOffset - NAV_OFFSET; | |
| window.scrollTo({ | |
| top: targetTop, | |
| behavior: 'smooth' | |
| }); | |
| history.pushState(null, null, href); | |
| }); | |
| } | |
| } | |
| }); | |
| // Handle direct page load with hash in URL | |
| if (window.location.hash) { | |
| setTimeout(() => { | |
| const target = document.querySelector(window.location.hash); | |
| if (target) { | |
| const targetTop = target.getBoundingClientRect().top + window.pageYOffset - NAV_OFFSET; | |
| window.scrollTo({ | |
| top: targetTop, | |
| behavior: 'smooth' | |
| }); | |
| } | |
| }, 150); | |
| } | |
| // ScrollSpy | |
| function onScroll() { | |
| const scrollPos = window.scrollY + 120; | |
| for (let i = sections.length - 1; i >= 0; i--) { | |
| const sec = sections[i]; | |
| const elementTop = sec.target.getBoundingClientRect().top + window.pageYOffset; | |
| if (elementTop <= scrollPos) { | |
| links.forEach(l => l.classList.remove('active')); | |
| sec.link.classList.add('active'); | |
| break; | |
| } | |
| } | |
| } | |
| window.addEventListener('scroll', onScroll, { passive: true }); | |
| onScroll(); | |
| }); | |
| </script> | |
| </body> | |
| </html> | |