OCR application for reading manga in Japanese, made for AJATTers🇯🇵
Lancet
Lancet is an OCR application for reading manga in Japanese. It uses PyTorch models to recognize Japanese text in images. Lancet works best with Goldendict-ng or Rikaitan.
https://github.com/user-attachments/assets/8859adac-1bd8-435a-9c81-945f875dc205
User Guide
Prerequisites:
- Goldendict for looking up words in Japanese dictionaries.
- nsxiv for reading manga.
- Recommended: i3wm, dwm, or any X11-based WM or DE (i.e. not Wayland).
Launch Goldendict, then open a manga folder in nsxiv.
Start Lancet and wait for the OCR model to load.
Press the OCR shortcut (default Alt+O) to show the snipping window,
then drag and hold the mouse to perform OCR.
Lancet adds an icon to the system tray. Right‑click the icon to access actions, including Preferences, where you can change the OCR shortcut.
Anki screenshots
Lancet can attach a selected screen region to the Image field
of the newest Anki note added within the last day.
This replaces a separate screenshot utility for image-card creation.
-
Install and enable AnkiConnect, then launch Anki.
-
Create or add the target note.
-
Press
Alt+I(the default shortcut), choose the screen region, and Lancet appends the image to that note'sImagefield.Finish active Browser edits before attaching an image. AnkiConnect cannot synchronously confirm that the Browser has saved pending editor changes.
Preferences has an Anki tab with the AnkiConnect URL, optional API key,
target field, maximum image width/height, quality, and output format.
The shortcut can be changed on the Main tab with Lancet's other shortcuts.
Width and height are maximum bounds.
0 leaves an axis unconstrained, and images are never enlarged.
The API key is masked in Preferences
but stored in Lancet's plaintext JSON configuration file.
On POSIX systems, Lancet writes that file with owner-only permissions.
Literal localhost and numeric loopback AnkiConnect endpoints
bypass HTTP_PROXY and HTTPS_PROXY.
Custom remote endpoints retain normal proxy behavior.
The field separator controls the HTML placed before each appended image.
It defaults to <br> and may be empty.
Executable overrides
"Preferences" > "Advanced" lets you set the GoldenDict executable.
Leave it empty to use automatic discovery through your system PATH.
Installation
All operating systems
pipx install ajt-lancet
The lancet executable will be available in your $PATH.
Windows-like operating systems
Download lancet-windows.exe.
GNU/Linux
Download lancet-gnulinux.
System Requirements
Lancet depends on large Python libraries.
pipx installs everything in an isolated location (~/.local/share/pipx)
so you can cleanly uninstall with pipx uninstall later.
The PyTorch models are downloaded from HuggingFace and saved to ~/.cache/huggingface.
- Disk space: ~8 GiB (PyTorch and dependencies)
- RAM: at least 2 GiB
Wayland support
Wayland support has been tested on Sway 1.11. Wayland support is incomplete. It works best on Hyprland and Sway, but on other compositors you may face issues if you have multiple monitors. 🙏 Please suggest improvements via pull requests on GitHub.
Upgrading
Running pipx upgrade upgrades lancet to the latest version.
pipx upgrade ajt-lancet
Running pipx upgrade-all
upgrades all packages installed with pipx.
pipx upgrade-all
Development Setup
Since Ajatt-Tools is a distributed effort, we highly welcome new contributors!
Install the project in development mode to easily test and commit your changes using hatch.
-
Clone the repo.
-
Install hatch:
pipx install hatch pipx upgrade hatch -
CD into the repo and run:
hatch shell -
Inside the hatch shell run:
pip install -e . -
To run the app, run:
hatch run lancet
Try these libre code editors with python support:
Autostart
Add the lancet command to your autostart so Lancet launches at login.
Here's an example for i3wm:
exec --no-startup-id lancet
System keyboard shortcuts
On some setups (like Wayland), applications can't register global keyboard shortcuts, so Lancet's shortcuts won't work. You can define shortcuts in your Wayland compositor instead.
Below is an example for Sway.
Add the following to your ~/.config/sway/config:
The example also works for i3wm (~/.config/i3/config).
# Run OCR
bindsym --release $mod+o exec lancet ocr
# Run OCR with the speech-bubble detector
bindsym --release $mod+Shift+o exec lancet ocr --detect
# Take a screenshot
bindsym --release $mod+Print exec lancet screenshot
# Attach a selected screen region to the most recently added Anki note.
bindsym --release $mod+i exec lancet screenshot --add-to-anki
Announcements
Metadata
Release files for ajt-lancet 26.9.15.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ajt_lancet-26.9.15.0.tar.gz | 7.3 MB | With provenance | Details for ajt_lancet-26.9.15.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ajt_lancet-26.9.15.0-py3-none-any.whl | Python 3 | none | any | Details for ajt_lancet-26.9.15.0-py3-none-any.whl |
Total release size: 14.5 MB
Release files / ajt_lancet-26.9.15.0.tar.gz
| Download URL | ajt_lancet-26.9.15.0.tar.gz |
|---|---|
| Size | 7.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
18ab0d29670fa7c3455a147f4009aed8ab480a0d29b31cc2fb1000df966dc90d
|
|
BLAKE2b-256 checksum How to use checksums |
7b9bd6cb728b387e3d13c4e22d325f2f2788c9c1a9b819d9990720f3ec89de02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.
Transparency logRelease files / ajt_lancet-26.9.15.0-py3-none-any.whl
| Download URL | ajt_lancet-26.9.15.0-py3-none-any.whl |
|---|---|
| Size | 7.2 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5cb08142f057d89c5ae33b3f47e5395f32d8dcd6be790a18d1d1802ad2c8ac6d
|
|
BLAKE2b-256 checksum How to use checksums |
3e4f0e2542444ad6c6d97ecb90a9bc854b74371aaeeab8f54981c27fea20c2c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.
Transparency logSecurity for ajt-lancet 26.9.15.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for ajt_lancet-26.9.15.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.