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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
726c8e15eb5a2aa6145cb0e0e4260cd2b987a956af891b31c2579b3e58422ff2
|
|
| MD5 |
ff0427365dd1854a44dd987f89295eb1
|
|
| BLAKE2b-256 |
a017aed91d1ab470f826e830d6b92af9a7e74487d27928a7308224d0c103d569
|
Provenance
The following attestation bundles were made for manga_ocr_torchless-0.2.0.tar.gz:
Publisher:
publish.yml on liksunrice/manga-ocr-torchless
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
manga_ocr_torchless-0.2.0.tar.gz -
Subject digest:
726c8e15eb5a2aa6145cb0e0e4260cd2b987a956af891b31c2579b3e58422ff2 - Sigstore transparency entry: 1062924487
- Sigstore integration time:
-
Permalink:
liksunrice/manga-ocr-torchless@287d853bc79e740203ae455bfdd38aeff2d5342c -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/liksunrice
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@287d853bc79e740203ae455bfdd38aeff2d5342c -
Trigger Event:
push
-
Statement type:
File details
Details for the file manga_ocr_torchless-0.2.0-py3-none-any.whl.
File metadata
- Download URL: manga_ocr_torchless-0.2.0-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f978b3b6b694c223856efe6a7ae85bf0f8fe5f5aa5144c22ecf9b04c8b686c4
|
|
| MD5 |
2d33891331e510d209308d03d557bde7
|
|
| BLAKE2b-256 |
37773d4dbd515b712360dc95e4cdab8c8b851434c9399599f8e4280c77bd12c4
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
manga_ocr_torchless-0.2.0-py3-none-any.whl -
Subject digest:
1f978b3b6b694c223856efe6a7ae85bf0f8fe5f5aa5144c22ecf9b04c8b686c4 - Sigstore transparency entry: 1062924511
- Sigstore integration time:
-
Permalink:
liksunrice/manga-ocr-torchless@287d853bc79e740203ae455bfdd38aeff2d5342c -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/liksunrice
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@287d853bc79e740203ae455bfdd38aeff2d5342c -
Trigger Event:
push
-
Statement type: