Local Tesseract OCR adapter for Swarmauri with sync, async, and batch image-to-text workflows.
Project description
Swarmauri OCR Pytesseract
swarmauri_ocr_pytesseract is the Swarmauri OCR adapter for running local
Tesseract-powered image-to-text extraction through a consistent Swarmauri
OCRBase interface. It accepts file paths, raw bytes, or in-memory PIL images
and supports synchronous, asynchronous, and batch OCR workflows.
Why Use Swarmauri OCR Pytesseract
- Use the same OCR component shape across local and pipeline-based Swarmauri workflows.
- Run OCR on local infrastructure without routing images through a hosted API.
- Tune Tesseract language selection and engine flags for receipts, forms, scanned PDFs, screenshots, and other document images.
- Reuse the same component in parsing, ingestion, indexing, and agent workflows.
FAQ
What does this package do?
It wraps PyTesseract and the local Tesseract binary behind Swarmauri's OCR component interface.
Does it require a hosted API key?
No. It runs locally, but the host must have thetesseractexecutable and any required language packs installed.
What image inputs are supported?
File path strings, raw image bytes, andPIL.Image.Imageinstances.
Can it process multiple images concurrently?
Yes. Usebatch()for synchronous lists andabatch()for async execution with a concurrency limit.
Features
- Local OCR backed by PyTesseract and Tesseract OCR.
- Supports configurable
language,config, and explicittesseract_cmdresolution. - Accepts paths, bytes, and PIL image objects.
- Includes
extract_text,aextract_text,batch, andabatchmethods. - Can report installed OCR languages through
get_supported_languages(). - Supports Python 3.10, 3.11, 3.12, 3.13, and 3.14.
Installation
uv add swarmauri_ocr_pytesseract
pip install swarmauri_ocr_pytesseract
System requirement:
- Install the native
tesseractbinary and ensure it is available onPATH, or setTESSERACT_CMDto the executable location.
Usage
from swarmauri_ocr_pytesseract import PytesseractOCR
ocr = PytesseractOCR(language="eng", config="--psm 6")
text = ocr.extract_text("docs/invoice.png")
print(text)
Examples
OCR from image bytes
from pathlib import Path
from swarmauri_ocr_pytesseract import PytesseractOCR
ocr = PytesseractOCR(language="eng")
image_bytes = Path("receipts/ticket.png").read_bytes()
text = ocr.extract_text(image_bytes)
print(text)
OCR from a PIL image
from PIL import Image
from swarmauri_ocr_pytesseract import PytesseractOCR
image = Image.open("scans/form.png")
ocr = PytesseractOCR(language="eng", config="--oem 3 --psm 4")
print(ocr.extract_text(image))
Async batch OCR
import asyncio
from swarmauri_ocr_pytesseract import PytesseractOCR
ocr = PytesseractOCR(language="eng")
async def run():
results = await ocr.abatch(
["scans/page1.png", "scans/page2.png", "scans/page3.png"],
max_concurrent=2,
)
for index, text in enumerate(results, start=1):
print(index, text[:120])
asyncio.run(run())
List installed OCR languages
from swarmauri_ocr_pytesseract import PytesseractOCR
ocr = PytesseractOCR()
print(ocr.get_supported_languages())
Related Packages
Swarmauri Foundations
More Documentation
Best Practices
- Use
--psmand--oemoptions throughconfigto match the page layout you expect. - Install the correct
.traineddatalanguage packs for multilingual OCR. - Pre-process noisy or skewed scans before OCR to improve extraction quality.
- Use PDF parsers when a PDF already contains embedded text; use OCR when the PDF or image is scan-only.
License
This project is licensed under the Apache-2.0 License.
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 swarmauri_ocr_pytesseract-0.11.0.dev1.tar.gz.
File metadata
- Download URL: swarmauri_ocr_pytesseract-0.11.0.dev1.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
621b7129b04c433e80a72d1f6a7909e4d81d4b01cf4de502c9c7266116d154e9
|
|
| MD5 |
855de7e524b5117ab48c81200782944d
|
|
| BLAKE2b-256 |
550693528fc3ee7e5309edbee33261ce9ab895886a275b021c14cab33c30f23f
|
File details
Details for the file swarmauri_ocr_pytesseract-0.11.0.dev1-py3-none-any.whl.
File metadata
- Download URL: swarmauri_ocr_pytesseract-0.11.0.dev1-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40c53aa09b82dc933f358dbe83be163a7e5070b61bc93051789f3526c72c1b79
|
|
| MD5 |
0b0d652f47005aa35f0341eda6aa20d9
|
|
| BLAKE2b-256 |
b0fe3ed317eb0c26b15855dd3cb8725fbc41d30be841323e979cfb1aa35e6cbf
|