Skip to main content

Async Gemini-based image text extractor

Project description

async_image_extractor

async_image_extractor is a Python package that uses Google's Gemini API to extract structured text from a batch of images. It supports async batch processing, customizable prompts, and model selection.


🚀 Features

  • 🔍 Extracts English text from images using Gemini.
  • ✅ Special handling for forms, checkboxes, and tables.
  • ⚡ Asynchronous batch processing for speed.
  • 🧠 Customizable prompt and model.
  • 📦 Easy to use and extend.

🧾 Input Format

Each image in the list should be a format accepted by the Gemini API:

  • Base64-encoded image string
  • File-like object
  • Raw image bytes
  • You can preprocess PIL or OpenCV images to bytes/base64 before passing

Installation

Install using pip

For the latest stable release:

pip install medimage-extractor

Usage

Initialize the extractor

from async_image_extractor import ImageTextExtractor
import asyncio
import time
from google import genai

# Setup Gemini client
# Setup Gemini client
client = genai.Client(api_key="GEMINI_API_KEY")

# Initialize extractor
extractor = ImageTextExtractor(
    client=client,
    model="gemini-2.0-flash",
    prompt="Extract all text from this medical image, preserving structure."
)

Run the extractor on a list of images

# images: a list of image objects (e.g., base64 strings or Gemini-compatible input)
results = asyncio.run(extractor.process_images(images))

The output will be in a list format, each item represents an image

[
  "Patient Name: James\nAge: 32\nDiagnosis: Diabetes \n...",
  "Results:\n- Glucose: High\n- Hemoglobin: Normal\n...",
  "Discharge Instructions:\nTake insulin twice a day.\nFollow up in 1 week.\n...",
  ...
]

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

async_image_extractor-1.1.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

async_image_extractor-1.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file async_image_extractor-1.1.0.tar.gz.

File metadata

  • Download URL: async_image_extractor-1.1.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for async_image_extractor-1.1.0.tar.gz
Algorithm Hash digest
SHA256 cb12be0d1cdce5d32bbdec053d799043dce9323904e5da67d922a79fb4227bd8
MD5 c114f00e8c654f98fe6ec2e129df4e71
BLAKE2b-256 9af453801520fb144875c538704026954439dae5a63a307e83ed2b4a16b16204

See more details on using hashes here.

File details

Details for the file async_image_extractor-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for async_image_extractor-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bea6d0ffd245faaf1a1e4a755ff87d4cd1d7a923965fcd2dd47be31f1f062470
MD5 9439ac5f828b7cd777e0218271eef613
BLAKE2b-256 120ac892ef8b4d9b6265a89cff8c3c680cfd12edd964e20c399829c6dcd90de8

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