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.2.dev6.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.2.dev6.tar.gz.

File metadata

  • Download URL: swarmauri_ocr_pytesseract-0.9.2.dev6.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","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.2.dev6.tar.gz
Algorithm Hash digest
SHA256 9d318e1b3ffc3b27615ddfc4764a1548c21d90d21332972807cd364e362439ad
MD5 56f0ce66fba90bd2aad5e6d232aa4ba4
BLAKE2b-256 9ed76388fa039e77b11f6c5ddbbb6810115ca4ef74970c19be775feea63d6ecf

See more details on using hashes here.

File details

Details for the file swarmauri_ocr_pytesseract-0.9.2.dev6-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_ocr_pytesseract-0.9.2.dev6-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","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.2.dev6-py3-none-any.whl
Algorithm Hash digest
SHA256 0112c8da426511fe31911188b2b0213aa462329bcf52b6e16a297cc4718c62c3
MD5 ff472528470a90af2769de15e71acfd7
BLAKE2b-256 b062aaff268fcbaec5500a71f379fe7646b64987c3dc67e65c90e2585237a505

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