NIOBIUM: Nadia's Image Occlusion Booster Is UnManned - A CLI tool for extracting text and image-occlusion-style notes from images and PDFs for Anki
Project description
NIOBIUM: Nadia's Image Occlusion Booster Is UnManned
NIOBIUM is a small CLI tool for extracting text and image-occlusion-style notes from images and PDFs, and for preparing Anki-compatible outputs (via AnkiConnect or by creating an .apkg). This README shows common usages and examples for the command-line interface.
Trivia: What the actual heck is niobium?
Niobium is a stealthy gray metal that is absurdly strong, feather‑light and allergic to corrosion. Mostly mined in Brazil and Canada, it moonlights in super‑alloys for jet engines and superconducting MRI magnets. It even hides in the capacitors inside your phone and laptop.
So next time you're on a flight, fiddling with your phone on the way to an MRI conference, tip your hat to niobium, OR just give this repo a ⭐️.
Installation
Using pip
pip install anki-niobium
Using uv (faster alternative)
uv pip install anki-niobium
From source
git clone https://github.com/agahkarakuzu/niobium.git
cd niobium
pip install -e .
Requirements
- Python 3.8 or higher
- All dependencies are automatically installed with the package
Quick overview
The main entry point is the niobium command. It exposes a few mutually-exclusive input modes and a few mutually-exclusive output modes.
Inputs (one required):
-i, --image— absolute path to a single image file-dir, --directory— directory containing multiple images-pin, --single-pdf— absolute path to a single PDF
Outputs (one required):
-deck, --deck-name— name of the Anki deck where notes will be pushed (requires AnkiConnect)-pout, --pdf-img-out— output directory where images extracted from a PDF will be saved-apkg, --apkg-out— output directory where a generated.apkgwill be saved
Other useful flags:
-ioid, --io-model-id— ID of the built-in Image Occlusion model in Anki (optional, used with--apkg-out)-m, --merge-rects— whether to merge nearby detected rectangles (default: True)-mx, --merge-lim-x— horizontal merging threshold in pixels (default: 10)-my, --merge-lim-y— vertical merging threshold in pixels (default: 10)-l, --langs— comma-separated OCR languages (default:en)-g, --gpu— GPU index to use, or-1for CPU only (default: -1)-hdr, --add-header— add filename as a header (default: False)-basic, --basic-type— create basic Anki cards instead of image-occlusion notes (default: False)
Run niobium -h to see the help text with the current arguments.
Examples
Below are some concrete example commands (assumes you're in the project root and using zsh/bash):
- ⭐️ Run OCR and push image-occlusion notes to an Anki deck (via AnkiConnect)
This processes all images under a directory and pushes notes to the Anki deck named MyStudyDeck.
niobium --directory /absolute/path/to/images --deck-name MyStudyDeck
Notes:
- You may specify a deck name that doesn't yet exist; you'll be prompted to create it.
- Anki must be running with the AnkiConnect add-on enabled.
- The tool will detect text and create image-occlusion notes from detected regions.
- Extract images from a single PDF
This extracts embedded images from lecture.pdf into ./out_images.
niobium --single-pdf /absolute/path/to/lecture.pdf --pdf-img-out /absolute/path/to/out_images
Important: --single-pdf is required when using --pdf-img-out.
- Produce an
.apkgfile (offline export, NOT TESTED)
This processes a directory and writes an .apkg bundle suitable for import into Anki without requiring AnkiConnect at runtime.
niobium --directory /absolute/path/to/images --apkg-out /absolute/path/to/output_dir
Optional: include the Image Occlusion model id if you want the built-in model referenced in the package:
niobium --directory /absolute/path/to/images --apkg-out /absolute/path/to/output_dir --io-model-id 12345
- Create basic (front/back) Anki cards instead of image-occlusion notes
niobium --directory /absolute/path/to/images --deck-name MyStudyDeck --basic-type True
This comes in handy when you have a bunch of images in a folder (may be extracted from a PDF, see (2) above), and would like to create Q&A for each one of them.
- Tweak rectangle merging and OCR languages
If bounding boxes are too fragmented, increase the merge thresholds. To OCR multiple languages, provide a comma-separated list.
niobium --directory /absolute/path/to/images --deck-name MyStudyDeck --merge-lim-x 20 --merge-lim-y 20 --langs en,fr
Note: Rectangle merging and other heuristics are experimental. Nearby occlusion boxes may be merged unintentionally, or distinct boxes may remain separate. Adjust --merge-lim-x/--merge-lim-y or disable merging with --merge-rects to change the behavior.
If you come up with a more robust approach to this, feel free to send a PR!
- GPU usage
Pass --gpu 0 to attempt to use GPU 0. The default -1 runs on CPU.
niobium --directory /abs/path/to/images --deck-name MyStudyDeck --gpu 0
Common workflows
- Automatic creation of image-occlusion notes and push to Anki:
--directory+--deck-name(Anki must be running with anki-connect installed)--single-pdf+--deck-name(Anki must be running with anki-connect installed)
- Quick extraction from a PDF for manual review:
--single-pdf+--pdf-img-out
Troubleshooting
- If AnkiConnect calls fail, confirm Anki is running and AnkiConnect is installed and enabled.
- If OCR quality is poor, try adding the proper language code with
--langs(e.g.,en,es) and ensure Tesseract language packs are installed. - If many small boxes are produced, increase
--merge-lim-x/--merge-lim-yor set--merge-rects Falseto disable merging.
Development
Setting up for development
git clone https://github.com/agahkarakuzu/niobium.git
cd niobium
pip install -e .
Running tests
The package includes automated tests that run on each push via GitHub Actions. You can test locally:
# Test the CLI is available
niobium -h
# Test import
python -c "from niobium.cli import main; print('Import successful')"
Project structure
niobium/cli.py- Main CLI entry point with argument parsingniobium/io.py- Core I/O helpers and OCR functionalitypyproject.toml- Package configuration and dependencies
Contributing
If you'd like to contribute, open an issue or submit a pull request.
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
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 anki_niobium-0.2.3.tar.gz.
File metadata
- Download URL: anki_niobium-0.2.3.tar.gz
- Upload date:
- Size: 24.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdb2c05faac1009242a412c9cbabc33e9d018d73cda5900e69c66fc0760b37f3
|
|
| MD5 |
eb0d696b9f32e40852b55010a2172dff
|
|
| BLAKE2b-256 |
4b93760a683496f764953e5efb83a1cecaacd4ce4fe22ba5c101dea7f989ecff
|
Provenance
The following attestation bundles were made for anki_niobium-0.2.3.tar.gz:
Publisher:
publish-pypi.yml on agahkarakuzu/niobium
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anki_niobium-0.2.3.tar.gz -
Subject digest:
bdb2c05faac1009242a412c9cbabc33e9d018d73cda5900e69c66fc0760b37f3 - Sigstore transparency entry: 693109340
- Sigstore integration time:
-
Permalink:
agahkarakuzu/niobium@2c47356d9b3f526ee33c99f896b538c5e5529300 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/agahkarakuzu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@2c47356d9b3f526ee33c99f896b538c5e5529300 -
Trigger Event:
release
-
Statement type:
File details
Details for the file anki_niobium-0.2.3-py3-none-any.whl.
File metadata
- Download URL: anki_niobium-0.2.3-py3-none-any.whl
- Upload date:
- Size: 23.1 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 |
ae1d3d21e9d0c0fa075711b0e5034385ee1579eec89660863c5ddaae38ec9ce0
|
|
| MD5 |
7702c87647cd7dc601c6cb45b4428e28
|
|
| BLAKE2b-256 |
0d8e394d6d723b8a090b0f6f8efc2af74a689031319eca9299d136c2cb890ff2
|
Provenance
The following attestation bundles were made for anki_niobium-0.2.3-py3-none-any.whl:
Publisher:
publish-pypi.yml on agahkarakuzu/niobium
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anki_niobium-0.2.3-py3-none-any.whl -
Subject digest:
ae1d3d21e9d0c0fa075711b0e5034385ee1579eec89660863c5ddaae38ec9ce0 - Sigstore transparency entry: 693109344
- Sigstore integration time:
-
Permalink:
agahkarakuzu/niobium@2c47356d9b3f526ee33c99f896b538c5e5529300 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/agahkarakuzu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@2c47356d9b3f526ee33c99f896b538c5e5529300 -
Trigger Event:
release
-
Statement type: