Skip to main content

Torchless optical character recognition for manga focused Japanese text, lightweight version of kha-white's manga-ocr

Project description

manga-ocr-torchless

A lightweight, torch-free version of the excellent manga-ocr by kha-white.

This package uses ONNX Runtime for inference, making it significantly faster to install and run on machines without a GPU, eliminating the multi-gigabyte dependency on PyTorch.

By default, this package uses mayocream's onnx export of the original manga-ocr package, but you can use any onnx export based on the manga-ocr package such as l0wgear's onnx export of jzhang533/manga-ocr-base.

Features

  • Lightweight: No PyTorch dependency (~2GB saved).
  • Parity: Achieves 100% character-level parity on the original test suite.
  • Fast: Optimized for CPU inference using ONNX, with support for Hardware Acceleration

Installation

pip install manga-ocr-torchless

Note: The required ONNX models (~400MB) will be automatically downloaded from HuggingFace on the first run, not during installation.

Usage

CLI

Process a single image:

manga_ocr path/to/image.jpg

Monitor clipboard (auto-OCR every time you copy an image):

manga_ocr -b

Watch a directory for new screenshots:

manga_ocr -d ./screenshots

Full CLI Options

Argument Description
image_path (Optional) Path to an image file to OCR.
-m, --model HuggingFace repo ID or local path to ONNX model.
-b, --background Run in background, reading from clipboard (requires pyperclip).
-d, --directory Watch directory for new images (requires watchdog).
--force-cpu Force CPU usage even if GPU accelerators are available.
-v, --verbose Increase output verbosity (shows DEBUG logs).
-q, --quiet Suppress all output except OCR results.
--delay Delay (in seconds) before reading new files in directory mode.

Python API

from manga_ocr import MangaOcr
from PIL import Image

mocr = MangaOcr()
img = Image.open('image.jpg')
text = mocr(img)
print(text)

Custom Models

You can use a different ONNX model by providing a HuggingFace repo ID or a local path to the constructor or via the --model flag in the CLI:

Python:

mocr = MangaOcr(pretrained_model_name_or_path="user/repo-id")
# OR
mocr = MangaOcr(pretrained_model_name_or_path="./local_model_directory")

CLI:

manga_ocr --model "user/repo-id" path/to/image.jpg

GPU Acceleration

By default, this package uses your CPU for inference. However, it automatically detects and uses hardware acceleration if you have the appropriate ONNX Runtime execution provider installed:

For NVIDIA GPUs (CUDA):

pip install onnxruntime-gpu

For Windows (DirectML - works on AMD, Intel, NVIDIA):

pip install onnxruntime-directml

For macOS (Apple Silicon / CoreML):

pip install onnxruntime-silicon # or standard onnxruntime which includes CoreML

For Intel CPUs/GPUs (OpenVINO):

pip install onnxruntime-openvino

Note: You may need to uninstall the standard onnxruntime first to avoid conflicts.

Acknowledgments

This project is a direct port of manga-ocr by kha-white. All credit for the model architecture and training belongs to them. This version simply swaps the backend to ONNX for a leaner distribution.

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

manga_ocr_torchless-0.2.0.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

manga_ocr_torchless-0.2.0-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file manga_ocr_torchless-0.2.0.tar.gz.

File metadata

  • Download URL: manga_ocr_torchless-0.2.0.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for manga_ocr_torchless-0.2.0.tar.gz
Algorithm Hash digest
SHA256 726c8e15eb5a2aa6145cb0e0e4260cd2b987a956af891b31c2579b3e58422ff2
MD5 ff0427365dd1854a44dd987f89295eb1
BLAKE2b-256 a017aed91d1ab470f826e830d6b92af9a7e74487d27928a7308224d0c103d569

See more details on using hashes here.

Provenance

The following attestation bundles were made for manga_ocr_torchless-0.2.0.tar.gz:

Publisher: publish.yml on liksunrice/manga-ocr-torchless

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file manga_ocr_torchless-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for manga_ocr_torchless-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1f978b3b6b694c223856efe6a7ae85bf0f8fe5f5aa5144c22ecf9b04c8b686c4
MD5 2d33891331e510d209308d03d557bde7
BLAKE2b-256 37773d4dbd515b712360dc95e4cdab8c8b851434c9399599f8e4280c77bd12c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for manga_ocr_torchless-0.2.0-py3-none-any.whl:

Publisher: publish.yml on liksunrice/manga-ocr-torchless

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page