Manga Garden Translation Pipeline — Algorithm Map

Manga Garden Translation Pipeline — Algorithm Map A workflow diagram generated by Archify. 01 / Webpage Content 02 / Background Worker 03 / Offscreen Runtime 04 / Local Storage Select & Queue Detect, Merge & Compute Fit, Bake & Persist Blob Queue Promise.all Branches Editable Project Data DOM Image Selection · img ≥150×150 · Webpage Content › Select & Queue DOM Image Selection img ≥150×150 DOM Image Swap · baked PNG data URL · Webpage Content › Fit, Bake & Persist DOM Image Swap baked PNG data URL Blob Job Queue · Dexie · 1–5 workers · Background Worker › Blob Queue › Select & Queue Blob Job Queue Dexie · 1–5 workers 14-Gate + Kruskal MST · cut edge > mean+2σ · recurse · Offscreen Runtime › Promise.all Branches › Detect, Merge & Compute 14-Gate + Kruskal MST cut edge > mean+2σ · recurse PP-OCRv6 + 1D Tiler · h≥2500px tiles · DBNet + CRNN · Offscreen Runtime › Promise.all Branches › Detect, Merge & Compute PP-OCRv6 + 1D Tiler h≥2500px tiles · DBNet + CRNN Polygon-Only Inpaint · median · FMM · dynamic patch · Offscreen Runtime › Promise.all Branches › Detect, Merge & Compute Polygon-Only Inpaint median · FMM · dynamic patch Index-Safe Translation · GTX · WebLLM · Cloud Pool · Offscreen Runtime › Promise.all Branches › Detect, Merge & Compute Index-Safe Translation GTX · WebLLM · Cloud Pool Bubble Fit & Typeset · Heuristic/YOLO · 4-pass fit · Offscreen Runtime › Fit, Bake & Persist Bubble Fit & Typeset Heuristic/YOLO · 4-pass fit Dexie IndexedDB · clean Blob + editable lines · Local Storage › Editable Project Data › Fit, Bake & Persist Dexie IndexedDB clean Blob + editable lines Studio Editor · rerender saved TextBlocks · Local Storage › Editable Project Data › Fit, Bake & Persist Studio Editor rerender saved TextBlocks load editable project surviving text-ink polygons merged reading-order blocks clean plate after erase DBNet quads + CRNN text PROCESS_JOB · jobId only translated texts by index TRANSLATE_IMAGE · image URL clean plate + fitted TextBlocks baked PNG data URL Legend User UI Agent logic Policy Context / trace Cloud service

OCR Detection, 1D Tiling & 14-Layer Noise Battery

  • • 1D Webtoon Tiler: images with h ≥2500 px are sliced into 1000 px vertical tiles with 300 px overlap, merging boundary polygons via IoU dedup.
  • • DBNet: max side 960 → probability ≥0.3 → 4-connected blobs ≥15 px → convex hull + minimum-area rectangle → score ≥0.5 → unclip 1.5.
  • • Crop recognition: projective homography + bicubic sampling; rotate vertical crops 90° when height/width ≥1.5.
  • • 1–5 Geometry: stray cleanup; giant ≥60% width and ≥120 px; tilt 12°/10°; margin ≤5 px; thin-sliver overlap rejection.
  • • 6–14 Text & Language: punctuation recovery; valuable text; short ASCII gate; watermark suffix rescale; furigana <0.45×; pure-Latin prune; weak-neighbor suppression.

Line Grouping — Cotrans Graph + Kruskal MST

  • • Direction graph: gap 2, char gap 0.6, alignment 1.5, font ratio 1.5, aspect tolerance 1; connected-component majority assigns horizontal/vertical.
  • • Merge graph: aspect tolerance 1.3, font ratio 2, char gaps 1/3; rotated candidates require angle ≤15° and relative font delta ≤0.25.
  • • For 3+ lines, build complete weighted graph → Kruskal MST → keep if max edge ≤ mean + 2σ or ≤1.5× font; else cut largest edge and recurse.
  • • Assemble blocks top-to-bottom or right-to-left; CJK joins without spaces; minimum line font wins; angle <3° snaps to zero; fit minimum-area rectangle.

Bubble Expansion & Typesetting Layout

  • • Bubble expansion: Tier 1 Heuristic (adaptive luminance, erosion R=14, 12% safe core) + Tier 2 Neural YOLO (detector-v4-s_int8 WebGPU, class 0 only).
  • • BubbleLayoutService: single-bubble expansion with font fit gate; clean single-axis X/Y partition for connected lobes (gap ≥6px); diagonal/complex lobes fall back to Disabled.
  • • Font fitter: 5% inset, line height 1.2, search 6 px…max; Pass 1 clean binary fit; Pass 2 tall-box geometric cap when H/W ≥2.0.
  • • Pass 3 scans down with six-stage hyphenation for words ≥7 chars when H/W ≥1.5; Pass 4 runs fallback binary search to the 6 px floor.
  • • Balanced wrap: greedy line count N → binary-search minimum width preserving ≤N lines; locked axis-aligned typesetBox (0°) bypasses decollision shifts.

Parallel Compute + Output Contract

  • • Translation: Google GTX chunks ≤1800 chars with ⟦index⟧ delimiters; LLM batches 15 tagged segments and writes results back by tag index.
  • • Inpaint: raw surviving line polygons only; Simple uses luminance ≥180 RGB median, Telea-like FMM radius 3, neural tiers (LaMa/AOT-GAN) use 64px dynamic patch bucketing with UNCLIP 1.8 stroke expansion.
  • • Promise.all waits for translated text and clean plate; raw DBNet mask forwarding remains rejected to avoid erasing non-text bubble art.
  • • Persist clean image plus editable fitted lines in Dexie; return a separate baked PNG data URL for immediate DOM replacement.