Skip to content

sunagdas/mangaTranslator

Repository files navigation

Django Manga Translator

A powerful, Django-based web application for automated manga translation. This is a forked and enhanced version of georgescutelnicu/Manga-Translator.

Unlike the original repository, which primarily handles local files, this fork introduces the ability to translate directly from any manga website URL using its integrated scraping engine.

🌟 Key Features

  • Automated Detection: Uses YOLOv8 to precisely locate text bubbles in manga pages.
  • State-of-the-Art OCR: Leverages manga-ocr for high-accuracy Japanese text recognition.
  • Stable Translation: Optimized support for Google Translate and Microsoft Bing Translator.
  • Modern UI/UX: Custom-built, high-performance vanilla CSS/JS interface with animated transitions and a simulated progress tracking system.
  • Smart Scraping: Integrated cloudscraper to bypass Cloudflare and anti-bot protections on popular manga sites.
  • Image Enhancement: Integrated 2x Lanczos upscaling (Super-Resolution) to improve OCR accuracy for small text and furigana.
  • Professional Logging: Structured logging with loguru, featuring file rotation and retention.
  • Dynamic Cleanup: Automatically manages temporary files and translated images to save storage.

🚀 Improvements in this Fork

  • URL-Based Translation: Translates directly from manga chapter URLs (Scraping engine).
  • Premium UI Overhaul: Replaced standard Bootstrap with a bespoke, mobile-friendly modern design featuring deep indigo accents.
  • Fault-Tolerant Pipeline: Implemented resilient error handling that prevents application crashes during individual translation failures.
  • Robust Scraper: Added fallback to cloudscraper for sites like RawKuma.
  • OCR Optimization: Implemented image upscaling logic that significantly improves recognition of small characters.
  • Furigana Handling: Optimized preprocessing specifically to capture small reading aids (furigana).
  • Production Logging: Integrated a centralized logging system with file outputs for easier debugging.
  • Chained Translation Fallback: Automatically switches between translation services (Google/Bing) if one fails or is rate-limited.
  • Improved OCR Stability: Specialized regex-based filtering to ignore punctuation-only bubbles, preventing API hangs on common "..." sequences.
  • Robust Text Rendering: Implemented failsafe logic in the font-sizing engine to prevent infinite loops in extremely small speech bubbles.
  • Maintenance Logic: Automated cleanup of media files to prevent storage bloat.

🛠️ Installation

Prerequisites

  • Python 3.10+
  • PyTorch (for YOLO and Manga-OCR)
  • CUDA-compatible GPU (optional, but recommended for speed)

Setup

  1. Clone the repository:

    git clone https://github.com/YOUR_USERNAME/Django-Manga-Translator.git
    cd Django-Manga-Translator
  2. Create a virtual environment:

    python -m venv env
    source env/Scripts/activate  # On Windows: env\Scripts\activate
  3. Install dependencies:

    pip install -r mangaTranslator/requirements.txt
  4. Model Setup:

    • Place your YOLOv8 bubble detection model (model.pt) in the mangaTranslator/model/ directory.
  5. Environment Setup:

    • Copy the template file: cp .env.template .env
    • Open .env and add your DJANGO_SECRET_KEY.
    • (Optional) Customize SERVER_PORT or DJANGO_DEBUG.
  6. Run Migrations:

    cd mangaTranslator
    python manage.py migrate
  7. Start the server:

    python manage.py runserver

    Note: The server will log its start-up port and status to the daily log file.

📖 Usage

  1. Open your browser and navigate to http://127.0.0.1:8000/.
  2. Enter the URL of the manga chapter you want to translate.
  3. Select your preferred font and translator.
  4. Click Translate and wait for the magic to happen!

📂 Project Structure

  • mangaTranslator/: Main Django project directory.
    • translate/: Main application logic (views, forms, scrapers).
    • utils/: Helper modules for OCR, detection, and translation.
    • media/: Storage for processed images.
    • logs/: Application logs (created automatically).

⚠️ Current Limitations & Future Roadmap

While this fork introduces major reliability and UI improvements, there are several known limitations where the engine can still be improved:

  • Bubble Detection Bias: The current YOLO model is primarily optimized for standard white bubbles.
  • Common "Misses":
    • Black/Dark Bubbles: Text in inverted bubbles may be missed or poorly OCR'ed.
    • Stylized/Textured Bubbles: Bubbles with complex patterns or rough edges are harder to detect.
    • Borderless Dialogue: Floating text without a clearly defined border is often skipped.
    • Narration Boxes: Rectangular narration panels aren't always recognized as bubbles.
  • Pipeline Constraints:
    • No Fallback for Non-Bubble Text: The system does not currently attempt to find "free-floating" text outside of detected bubbles.
    • OCR Dependency: OCR only runs on successfully detected areas; if the YOLO model misses a bubble, the text within it is missed entirely.

🗺️ Future Improvements

  • Support for black/dark bubble inversion and Stylized/Textured Bubbles before OCR.
  • Integration of a secondary text-only detector (like DBNet) for borderless text.
  • Support for Manhwa (Korean) and Manhua (Chinese) layouts.
  • Moving to a background task queue (Celery) for multi-page chapters.

🙏 Acknowledgments