Skip to content

NinjaScoutZ/web_app

Repository files navigation

Manga Translator Pro - Web App

A full-stack web application for manga translation with AI-powered features including OCR, balloon detection, and inpainting.

Features

  • πŸ–ΌοΈ Image Upload - Drag & drop or click to upload manga images
  • πŸ” Balloon Detection - AI-powered detection of speech balloons and text regions
  • πŸ“ OCR - Extract text from manga images (supports Japanese, English, Korean, Chinese)
  • 🎨 Inpainting - Clean/remove text from images using AI
  • πŸ–ŒοΈ Canvas Editor - Zoom, pan, and select regions
  • πŸ”„ Real-time Updates - WebSocket connection for progress updates
  • πŸ“± Responsive UI - Modern interface with Tailwind CSS

Tech Stack

Frontend

  • React 18 + TypeScript
  • Vite (build tool)
  • Tailwind CSS (styling)

Backend

  • FastAPI (Python)
  • WebSocket support
  • PIL/Pillow (image processing)
  • CORS enabled

Project Structure

web_app/
β”œβ”€β”€ backend/                 # FastAPI backend
β”‚   β”œβ”€β”€ api/                # API endpoints
β”‚   β”‚   β”œβ”€β”€ upload.py       # Image upload endpoint
β”‚   β”‚   β”œβ”€β”€ ocr.py          # OCR endpoint
β”‚   β”‚   β”œβ”€β”€ inpaint.py      # Inpainting endpoint
β”‚   β”‚   └── detect.py       # Detection endpoint
β”‚   β”œβ”€β”€ core/               # Core utilities
β”‚   β”‚   β”œβ”€β”€ config.py       # Configuration settings
β”‚   β”‚   β”œβ”€β”€ websocket_manager.py  # WebSocket manager
β”‚   β”‚   └── utils.py        # Utility functions
β”‚   β”œβ”€β”€ services/           # AI service implementations
β”‚   β”‚   β”œβ”€β”€ ocr_service.py
β”‚   β”‚   β”œβ”€β”€ inpaint_service.py
β”‚   β”‚   └── detection_service.py
β”‚   β”œβ”€β”€ uploads/            # Uploaded images (created at runtime)
β”‚   β”œβ”€β”€ results/            # Processing results (created at runtime)
β”‚   β”œβ”€β”€ temp/               # Temporary files (created at runtime)
β”‚   β”œβ”€β”€ main.py             # FastAPI entry point
β”‚   └── requirements.txt    # Python dependencies
β”œβ”€β”€ src/                     # Frontend source
β”‚   β”œβ”€β”€ components/         # React components
β”‚   β”œβ”€β”€ hooks/              # Custom React hooks
β”‚   β”œβ”€β”€ services/           # API client
β”‚   └── types/              # TypeScript types
β”œβ”€β”€ start-dev.bat           # Windows startup script
β”œβ”€β”€ start-dev.sh            # Linux/Mac startup script
└── package.json            # Node.js dependencies

Quick Start

Prerequisites

  • Python 3.8+
  • Node.js 18+
  • npm or yarn

Installation

  1. Clone the repository (or navigate to the project folder)

  2. Copy environment file

    cp .env.example .env
  3. Run the startup script

    On Windows:

    start-dev.bat

    On Linux/Mac:

    chmod +x start-dev.sh
    ./start-dev.sh

    This will:

    • Create a Python virtual environment
    • Install backend dependencies
    • Install frontend dependencies
    • Start both servers
  4. Access the application

Manual Setup (Alternative)

If you prefer to run servers manually:

Terminal 1 - Backend:

cd backend
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
python -m uvicorn main:app --reload --host 0.0.0.0 --port 8000

Terminal 2 - Frontend:

npm install
npm run dev

API Endpoints

Upload

  • POST /api/upload - Upload an image file
  • GET /api/uploads/{file_id} - Get uploaded image
  • DELETE /api/upload/{file_id} - Delete uploaded image

OCR

  • POST /api/ocr - Run OCR (async)
  • POST /api/ocr/sync - Run OCR (sync)
  • GET /api/ocr/status/{task_id} - Get OCR task status
  • GET /api/ocr/languages - Get supported languages

Detection

  • POST /api/detect - Run detection (async)
  • POST /api/detect/sync - Run detection (sync)
  • GET /api/detect/status/{task_id} - Get detection status
  • GET /api/detect/models - Get available models
  • GET /api/detect/types - Get detection types

Inpainting

  • POST /api/inpaint - Run inpainting (async)
  • POST /api/inpaint/sync - Run inpainting (sync)
  • GET /api/inpaint/status/{task_id} - Get inpainting status
  • GET /api/inpaint/methods - Get available methods

WebSocket

  • WS /ws - Real-time updates and progress notifications

Development

Frontend Development

npm run dev          # Start dev server
npm run build        # Build for production
npm run preview      # Preview production build
npm run lint         # Run ESLint

Backend Development

cd backend
source venv/bin/activate

# Run with auto-reload
python -m uvicorn main:app --reload

# Run tests
pytest

Environment Variables

Variable Description Default
VITE_API_URL Backend API URL http://localhost:8000
VITE_WS_URL WebSocket URL ws://localhost:8000/ws
HOST Backend host 0.0.0.0
PORT Backend port 8000
DEBUG Debug mode true

Usage Guide

  1. Upload an Image

    • Click "Open..." or drag & drop a manga image
    • Supported formats: JPG, PNG, WebP, BMP, TIFF
  2. Detect Balloons

    • Click "Detect Balloons" to find speech balloons
    • Detections will appear as overlays on the image
  3. Run OCR

    • Select a region with the rectangle tool, or run on entire image
    • Click "Run OCR" to extract text
    • Results will show extracted text with confidence scores
  4. Clean/Inpaint

    • Select a region containing text
    • Click "Clean/Inpaint" to remove the text
    • The result will replace the original image
  5. Canvas Tools

    • Pan: Move around the image
    • Rectangle Select: Select regions for processing
    • Zoom: Zoom in/out

Production Deployment

Backend

cd backend
pip install -r requirements.txt
# Use a production ASGI server like gunicorn
pip install gunicorn
gunicorn main:app -w 4 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000

Frontend

npm run build
# Serve the dist/ folder with your web server (nginx, Apache, etc.)

Notes

  • The current implementation uses mock AI services for demonstration
  • To use real AI models, implement the actual model loading in:
    • backend/services/ocr_service.py
    • backend/services/inpaint_service.py
    • backend/services/detection_service.py

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors