metadata
title: My FastAPI App
emoji: π
colorFrom: blue
colorTo: purple
sdk: docker
sdk_version: 0.1.0
app_file: app.py
pinned: false
Manga OCR Translator
A powerful tool for translating manga, comics, and light novels using OCR (Optical Character Recognition) and machine translation.
Features
- Text Detection: Automatically detects text in manga images using PyTesseract
- Text Translation: Translates detected text to your preferred language
- PDF Support: Upload and translate entire PDF manga files
- URL Support: Translate manga directly from web URLs
- Modern UI: Clean, responsive Gumroad-like user interface
- Multiple Languages: Support for Japanese, Korean, Chinese, and more
Requirements
Before running the application, ensure you have the following installed:
- Python 3.8+
- Tesseract OCR - Must be installed and available in PATH
- Required Python packages from
requirements.txt
Installing Tesseract OCR
Windows
- Download the installer from UB Mannheim
- Install and add to PATH environment variable
- Default installation path:
C:\Program Files\Tesseract-OCR\tesseract.exe
macOS
brew install tesseract
Linux (Ubuntu/Debian)
sudo apt update
sudo apt install tesseract-ocr
sudo apt install libtesseract-dev
# Install language data packages as needed
sudo apt install tesseract-ocr-jpn tesseract-ocr-chi-sim tesseract-ocr-kor
Installation
- Clone the repository:
git clone https://github.com/yourusername/manga-ocr-translator.git
cd manga-ocr-translator
- Install Python dependencies:
pip install -r requirements.txt
- Set the Tesseract executable path in your environment (only if not in PATH):
# In your environment or at the top of utils/ocr.py
import pytesseract
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe' # Windows example
Usage
Starting the Server
Run the application:
python app.py
Then open a web browser and navigate to:
http://localhost:8000
Using the Web Interface
- Access the main page at
http://localhost:8000
- Choose either URL or PDF upload method
- Configure source and target languages
- Submit for translation
- View and download the translated images
API Endpoints
The application also provides API endpoints for integration:
- POST /translate/url - Translate manga from a URL
- POST /translate/pdf - Translate manga from a PDF file
- GET /api/info - Get API information
Development
Project Structure
manga-ocr-translator/
βββ app.py # Main FastAPI application
βββ requirements.txt # Python dependencies
βββ static/ # Static files
β βββ translated/ # Translated images output
β βββ ui/ # UI assets
β βββ index.html # Main UI page
β βββ styles.css # CSS styles
β βββ scripts.js # JavaScript functionality
βββ utils/ # Utility modules
βββ ocr.py # OCR functionality using pytesseract
βββ image.py # Image processing utilities
βββ pdf.py # PDF handling
βββ translation.py # Translation services
βββ web.py # Web scraping utilities
Configuration
You can configure the application by modifying the following files:
- app.py: Main application settings
- utils/ocr.py: OCR settings and language mapping
- requirements.txt: Package dependencies
Troubleshooting
Common Issues
- Tesseract not found: Ensure Tesseract is installed and the correct path is set
- Missing language data: Install additional language data packages for Tesseract
- Slow performance: Consider using a GPU for faster processing
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgements
- PyTesseract for OCR capabilities
- FastAPI for the web framework
- Pillow for image processing