Skip to main content

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...",
  ...
]

Metadata

Release files for async-image-extractor 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for async-image-extractor 1.1.0
File Size Uploaded
async_image_extractor-1.1.0.tar.gz 3.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for async-image-extractor 1.1.0
File Interpreter ABI Platform
async_image_extractor-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.5 kB

Release files / async_image_extractor-1.1.0.tar.gz

Download URL async_image_extractor-1.1.0.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
cb12be0d1cdce5d32bbdec053d799043dce9323904e5da67d922a79fb4227bd8
BLAKE2b-256 checksum
How to use checksums
9af453801520fb144875c538704026954439dae5a63a307e83ed2b4a16b16204
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.5

Release files / async_image_extractor-1.1.0-py3-none-any.whl

Download URL async_image_extractor-1.1.0-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bea6d0ffd245faaf1a1e4a755ff87d4cd1d7a923965fcd2dd47be31f1f062470
BLAKE2b-256 checksum
How to use checksums
120ac892ef8b4d9b6265a89cff8c3c680cfd12edd964e20c399829c6dcd90de8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.5

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page