feat(ocr): unify config, add manga translation pipeline and context lookahead

- Consolidate module configs into root config.example.json with ocr, vision, and epub sections

- Split LLM OCR workflows into novel_ocr.py (prose) and manga_ocr_llm.py (manga)

- Remove gemini_direct_ocr.py in favor of OpenAI-compatible API endpoints

- Support direct manga translation via --translate, --target-lang, and glossary.md

- Add bidirectional context support: past translations (--context-pages) and lookahead Japanese text (--context-pages-ahead)

- Add per-page JSON audit logging under logs/ and expose OpenAI sampling parameters
This commit is contained in:
Poison Flower
2026-09-06 15:42:29 +03:00
parent 41c6e97cd4
commit 35b7be680e
23 changed files with 1811 additions and 494 deletions
+22 -9
View File
@@ -1,15 +1,28 @@
"""
OCR module: batch-transcribes scanned light novel pages (vertical Japanese
text) into per-page .txt files, ready for the epub_builder module.
OCR module: batch-transcribes (or translates) scanned pages into per-page
.txt files. Light novel and manga pages are handled by separate scripts,
since their layouts need genuinely different logic (dense running prose
vs. scattered, typed speech bubbles that benefit from translation +
glossary + cross-page continuity context).
Several interchangeable backends are provided as standalone scripts:
Novel (light novel, dense running prose):
- novel_ocr.py Any OpenAI-compatible API (OpenRouter, a direct
provider endpoint, a self-hosted proxy, etc.)
with a multimodal model. Recommended.
- google_vision_ocr.py Classic OCR via Google Cloud Vision (no LLM,
--mode novel).
- openrouter_ocr.py Recommended. Any OpenAI-compatible API (OpenRouter,
a self-hosted proxy, etc.) with a multimodal model.
- gemini_direct_ocr.py Same idea, but calling the Gemini API directly.
- google_vision_ocr.py Classic OCR via Google Cloud Vision (no LLM).
- local_mangaocr_ocr.py Fully offline, no cloud account, via manga-ocr.
Manga (speech bubbles / narration boxes / SFX):
- manga_ocr_llm.py Any OpenAI-compatible API. Transcribe or
--translate, with --glossary and --context-pages
for cross-page continuity. Recommended.
- google_vision_ocr.py Classic OCR via Google Cloud Vision (no LLM,
--mode manga; transcription only, no translation).
- local_mangaocr_ocr.py Fully offline, no cloud account, via manga-ocr
(also supports --mode novel via column
segmentation, transcription only).
Each script is self-contained and runnable directly, e.g.:
python -m ocr.openrouter_ocr --input ./pages --output ./out
python -m ocr.novel_ocr --input ./pages --output ./out
python -m ocr.manga_ocr_llm --input ./pages --output ./out --translate
"""