$ show dmMaze/BallonsTranslator
BallonsTranslator is a mature, feature-rich desktop application for translating manga and comic images. It provides a complete pipeline: text detection (CTD, YOLO, DBNet), OCR (MangaOCR, MIT48px, PaddleOCR, cloud APIs), inpainting (AOT, LaMa, PatchMatch, LLM), machine/LLM translation (Google, DeepL, Sakura, OpenAI-compatible, etc.), and a sophisticated WYSIWYG text editor with effects (stroke, shadow, glow, gradient, filters, transforms). The architecture is monolithic with a plugin-like module registry for extensible backends. It uses PyQt5/PyQt6 for the GUI, supports project-based workflows, undo/redo, and headless batch processing. While primarily an application, it incorporates significant data engineering and ML model integration, making it a hybrid tool with strong research components. The codebase demonstrates high craftsmanship in areas like custom Qt widgets, frameless windows, text rendering engine, and LLM context management, but also carries technical debt from platform-specific code and a large dependency surface.
The LLM identified 5 files worth highlighting for reuse:
Implements a lazy module registry that scans Python source files using AST to extract metadata (name, description, parameters) without importing the modules. The `SafeEval` class safely evaluates literal expressions from AST nodes, enabling a plugin-like system where modules can be discovered and configured at runtime. This pattern is reusable for any application needing dynamic plugin loading with metadata extraction.
Provides robust file download utilities with SHA-256 hash verification, atomic writes (download to temp then rename), archive extraction (zip, tar, 7z), and HuggingFace mirror URL rewriting. The `download_url_to_file` function supports progress callbacks and retries. This is a self-contained, reusable module for any project that needs reliable model or data file downloads.
A filter registry that discovers and manages image effect filters (bloom, glitch, grain, etc.) with lazy import, parameter validation, schema migration, and failure isolation. Filters are registered via decorators with metadata, and the registry provides runtime compilation and rendering. This pattern is reusable for any plugin-based image processing pipeline.
Manages LLM context windows for translation, including token counting, budget enforcement, low-water eviction, and context-length error recovery. The `eligible_history_for_request` function selects relevant history pages while respecting token limits. This is a well-designed, reusable component for any LLM application that needs context window management with glossary injection.
Provides Windows-specific utilities for frameless windows, including DWM shadow, acrylic/mica effects, taskbar integration, and DPI awareness. Uses ctypes to call Win32 API functions. While platform-specific, the pattern of encapsulating native window management is reusable for any cross-platform Qt application needing custom title bars.