Manga Translator
Batch manga page translator (JPβEN first) with free/local models.
Stack: Python FastAPI worker + Next.js UI. Phase 1 ships detect β OCR β translate β overlay preview. Phase 2 adds inpaint + typeset for finished visual pages.
Separate from Dinamus/ml-danbooru-onnx-repo (image tagging / folder routing).
Pipeline
- Detect text regions (heuristic contours; CTD optional later)
- OCR source text (
manga-ocrwhenMANGA_TRANSLATOR_REAL_MODELS=1, else stub) - Translate JPβEN (
opus-mt-ja-enwhen real models, else stub) - Overlay preview (Phase 1) β Inpaint + typeset (Phase 2)
- Export side-by-side PNG + zip / CBZ
Quick start (Phase 1 stubs β no GPU/model download)
Backend
cd backend
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -e ".[dev]"
pytest
uvicorn manga_translator.api.app:app --reload --port 8000
CLI:
manga-translator translate-batch .\path\to\pages
Web UI
cd web
npm install
$env:NEXT_PUBLIC_API_BASE="http://127.0.0.1:8000"
npm run dev
Open http://localhost:3000 β upload pages, poll job progress, preview side-by-side, download zip.
Optional real models (Windows note)
Torch installs into the long project .venv path can fail with WinError 206. Prefer a short venv:
python -m venv C:\mtvenv
C:\mtvenv\Scripts\python -m pip install -e ".[ml]"
C:\mtvenv\Scripts\python -m pip install -e .
$env:MANGA_TRANSLATOR_REAL_MODELS="1"
$env:MANGA_TRANSLATOR_OCR_BACKEND="manga_ocr"
$env:MANGA_TRANSLATOR_TRANSLATE_BACKEND="opus_mt"
C:\mtvenv\Scripts\python -m uvicorn manga_translator.api.app:app --port 8010
Checklist: docs/CHECKLIST-p1-ui-local-models.md
Translation quality (glossary + replacement dictionaries)
Optional, fully local quality controls modeled on production scanlation tools:
# Glossary: preserve names/terms (only entries present in the page are sent to the LLM)
$env:MANGA_TRANSLATOR_GLOSSARY_PATH="data/dict/glossary.json" # {"ε€ͺι":"Taro"}
# Pre-dict: fix OCR artefacts / strip SFX BEFORE translation (ordered regex rules)
$env:MANGA_TRANSLATOR_PRE_DICT_PATH="data/dict/pre_dict.example.json"
# Post-dict: fix recurring MT phrasing AFTER translation
$env:MANGA_TRANSLATOR_POST_DICT_PATH="data/dict/post_dict.example.json"
Dictionaries are JSON β either {"pattern": "replacement"} or ordered [["pattern","replacement"], ...]; keys are regular expressions. Lines already in the target language are passed through untranslated, and identical bubbles are translated once. Reading order follows manga convention (right-to-left, panel-banded).
Measure accuracy against known translations:
C:\mtvenv\Scripts\python backend/scripts/eval_accuracy.py ollama # CER (OCR) + chrF (translation)
Layout
backend/ Python package, FastAPI, CLI, tests
web/ Next.js job UI
data/jobs/ Runtime job store (gitignored)
docs/superpowers/ Design spec + implementation plan
License
MIT β compose Apache/MIT model weights; do not embed GPL engines (manga-image-translator / BallonsTranslator) as libraries.