Files
rv_fansub/OPTIMIZACIONES.md

60 lines
2.0 KiB
Markdown

# Optimizaciones de manga-image-translator
## OPCIÓN A: Solo config (sin tocar código)
### Flags para acelerar en CPU
| Flag | Default | Recomendado | Impacto | Riesgo |
|------|---------|-------------|---------|--------|
| `--detection-size` | 2048 | **1024** | ~2-4x más rápido detección | Puede perder burbujas muy pequeñas |
| `--inpainting-size` | 2048 | **1024** | ~2-4x más rápido inpainting | Menor calidad de borrado |
| `--inpainter` | lama_large | **default (AOT)** | ~3-5x más rápido inpainting | AOT borra un poco peor |
| `--ocr` | 48px | **32px** | ~20-30% más rápido OCR | Puede fallar en texto pequeño |
| `--batch-size` | 1 | **20-50** | Reduce llamadas API ~20x | Textos muy largos pueden fallar (error 2013) |
| `--batch-concurrent` | off | **on** | Superpone red + CPU | Mejora parcial |
| `--skip-no-text` | off | **on** | Ahorra I/O en páginas sin texto | Solo ahorra escritura, no procesamiento |
### Comando óptimo
```bash
python -m manga_translator local \
-i "input" -o "output" \
--config-file translate_config.json \
--detection-size 1024 \
--inpainting-size 1024 \
--inpainter default \
--ocr 32px \
--batch-size 30 \
--batch-concurrent \
--skip-no-text \
--ignore-errors --overwrite
```
### Estimación: 1.5h → ~20-30 min
---
## OPCIÓN B: Cambios de código (requiere modificar el repo)
### B1. Corregir `_concurrent_translate_contexts` (chatgpt.py)
- Usar `asyncio.gather` en vez de loop secuencial
- Impacto: ~30-40% más rápido en fase de traducción
- Riesgo: Bajo
### B2. Pipeline real con ProcessPoolExecutor
- multiprocessing.Pool para detección + OCR paralela
- Bypass del GIL de Python
- Impacto: ~50-60% más rápido (mayor salto)
- Riesgo: Requiere refactorizar state global de modelos
### B3. Aumentar `_MAX_TOKENS` (chatgpt.py)
- Default: 4096 → 8192 si MiniMax lo soporta
- Impacto: Menor con batch-size alto
### Estimación: 1.5h → ~15-25 min
---
## OPCIÓN C: Híbrida (recomendada)
- Config de Opción A + B1 (código menor)
- Estimación: ~15-25 min, ~50-80 llamadas API