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.dev10.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.dev10.tar.gz.

File metadata

  • Download URL: swarmauri_ocr_pytesseract-0.9.3.dev10.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","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.dev10.tar.gz
Algorithm Hash digest
SHA256 d3ea527b2a380f73b5d5afda4efd2debca603f65af746bf853fa30c8381f913d
MD5 d22a5664fa461ae632461b0b876abd28
BLAKE2b-256 2790aa4688bba86e0150e5bc88ba904795479bd6c0cc733c6a4d5eb01bf3ce9c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: swarmauri_ocr_pytesseract-0.9.3.dev10-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","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.dev10-py3-none-any.whl
Algorithm Hash digest
SHA256 4796a48ff6cbef9c5592124b220c36d337de318112492a03dd99bbdab9a4358e
MD5 cda0570f5a27f4a3453c5813838a2645
BLAKE2b-256 a153c666ca78a1584f375c0655993cbab5b46c1ce2d7b31d4c1e8f81336fc086

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