Kites Translation Pipeline — Algorithm Map

Kites 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 DBNet · polygon detect + warp recognize · Offscreen Runtime › Promise.all Branches › Detect, Merge & Compute PP-OCRv6 DBNet polygon detect + warp recognize 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 4-Pass Font Search · binary 6px…max · width search · Offscreen Runtime › Fit, Bake & Persist 4-Pass Font Search binary 6px…max · width search 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 + 14-Layer Noise Battery

  • • 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–11 Text noise: punctuation recovery; valuable text + area ≥16; short ASCII confidence gate; watermark suffix rescale; scanlator and ornament pruning.
  • • 12–14 Language/dedup: furigana <0.45×; pure-Latin prune after native-script evidence; ≥50% smaller-box coverage dedup + 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.

Typesetting — Two Binary Searches + Affine Render

  • • 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 the minimum width preserving ≤N lines → centered diamond/inverted-pyramid stanza.
  • • Median dialogue cap max(18, round(median×1.25)) → decollide boxes → sample central 20–80% for color → exact lines → aspect pad → affine warp.

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.