Skip to main content

Swarmauri Tesseract Image to Text Model

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_ocr_pytesseract


Swarmauri OCR Pytesseract

OCR adapter for Swarmauri built on top of PyTesseract. Accepts paths, bytes, or PIL images, and exposes synchronous, async, and batch APIs for extracting text.

Features

  • Wraps Tesseract OCR via PyTesseract behind Swarmauri's OCRBase interface.
  • Supports multiple languages (language parameter) and custom Tesseract configs.
  • Handles individual, async, and batched OCR calls with optional concurrency limits.
  • Helper to list installed Tesseract languages through get_supported_languages().

Prerequisites

  • Python 3.10 or newer.
  • Tesseract OCR installed on the host (tesseract binary reachable on PATH or via TESSERACT_CMD).
  • pytesseract, Pillow, and related dependencies (installed automatically with this package).

Installation

# pip
pip install swarmauri_ocr_pytesseract

# poetry
poetry add swarmauri_ocr_pytesseract

# uv (pyproject-based projects)
uv add swarmauri_ocr_pytesseract

Quickstart

from swarmauri_ocr_pytesseract import PytesseractOCR

ocr = PytesseractOCR(language="eng")
text = ocr.extract_text("docs/invoice.png")
print(text)

Processing Image Bytes

from pathlib import Path
from swarmauri_ocr_pytesseract import PytesseractOCR

png_bytes = Path("receipts/ticket.png").read_bytes()
ocr = PytesseractOCR(language="eng", config="--psm 6")
print(ocr.extract_text(png_bytes))

Async and Batch APIs

import asyncio
from swarmauri_ocr_pytesseract import PytesseractOCR

ocr = PytesseractOCR(language="fra")

async def run_async():
    text = await ocr.aextract_text("scans/document_fr.png")
    print(text)

    texts = await ocr.abatch([
        "scans/page1.png",
        "scans/page2.png",
    ], max_concurrent=2)
    for page, content in enumerate(texts, start=1):
        print(f"Page {page}: {content[:80]}")

# asyncio.run(run_async())

List Available Languages

from swarmauri_ocr_pytesseract import PytesseractOCR

ocr = PytesseractOCR()
print(ocr.get_supported_languages())

Tips

  • Set TESSERACT_CMD if the binary lives outside standard locations (e.g., Windows installs).
  • Use appropriate page segmentation modes (--psm) and OCR engine modes (--oem) through the config parameter to improve quality.
  • Pre-process images (grayscale, thresholding) before passing them to the OCR for better accuracy.
  • When running in containers, ensure Tesseract language packs (.traineddata) are installed for the languages you plan to use.

Want to help?

If you want to contribute to swarmauri-sdk, read up on our guidelines for contributing that will help you get started.

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

swarmauri_ocr_pytesseract-0.9.3.dev3.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file swarmauri_ocr_pytesseract-0.9.3.dev3.tar.gz.

File metadata

  • Download URL: swarmauri_ocr_pytesseract-0.9.3.dev3.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","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

Hashes for swarmauri_ocr_pytesseract-0.9.3.dev3.tar.gz
Algorithm Hash digest
SHA256 b67e1485c4a01f9fa26fa85af49caa4f904be3136a6d7b53237a7c9ccc85b25c
MD5 2886477912b62a4e9311311a924d6e9f
BLAKE2b-256 173af5a38c6ddb28d93cf5e7c6a1bf3b5f7f77394457a13ce0781db935357eb3

See more details on using hashes here.

File details

Details for the file swarmauri_ocr_pytesseract-0.9.3.dev3-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_ocr_pytesseract-0.9.3.dev3-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","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

Hashes for swarmauri_ocr_pytesseract-0.9.3.dev3-py3-none-any.whl
Algorithm Hash digest
SHA256 4b00113e655ae05e9e1a1d507f15f830af51b32ec0d775648efe31db8bd46361
MD5 d5edf823c6fe652e2fb5045c14873583
BLAKE2b-256 2bdc0182607326d2903c4b2ad8c646c7ba356aec58f9b21c1eb896a5d4b9da91

See more details on using hashes here.

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