Skip to main content

A document layout pipeline for detecting tables, images, and structured extraction.

Project description

readgrid

readgrid is a Python package for document layout analysis and content extraction.
It lets you upload scanned documents, automatically detect tables and images, manually adjust bounding boxes for all document elements, and extract clean structured output using LLMs.


✨ Features

  • Stage 1 – Upload & Detect

    • Upload document images in batch mode.
    • Automatically detect tables (red boxes) and images (green boxes).
    • Manually draw bounding boxes for columns (blue boxes), headers (orange boxes), and footers (magenta boxes).
    • Interactive editor supports multiple boxes per type with add/edit/delete functionality.
  • Stage 2 – Coordinate Testing

    • Verify detected regions with side-by-side previews.
    • Test either existing detections or custom coordinates.
    • Works with all box types (tables, images, columns, headers, footers).
  • Stage 3 – Content Extraction

    • Extract structured JSON output with layout-aware reading order.
    • Supports multi-column layouts (single, two, three, four columns).
    • Replace detected tables with clean HTML <table> tags.
    • Insert [image] placeholders with captions in correct reading order.
    • Proper header/footer separation from main content.
    • Supports LaTeX formatting for mathematical equations.
    • Customizable output fields with inclusion/exclusion options.
  • Utility Functions

    • pretty_print_page_with_image() – inspect extracted results with annotated images.
    • show_comparison_view() – compare annotated vs. reconstructed content with multiple view modes.
    • cleanup_pipeline() – reset all artifacts.
    • editor() – interactive JSON correction with LLM assistance and diff visualization.

🚀 Installation

pip install readgrid

🛠️ Usage

Stage 1: Upload, Detect, and Edit

from readgrid import stage_1

stage_1()

Stage 2: Test Coordinates

from readgrid import stage_2

stage_2(
    row_id="ID_1",
    box_type="tables",
    box_index=0
)

Stage 3: Extract with Gemini

from readgrid import stage_3

stage_3(api_key="YOUR_API_KEY")

✏️ Editor

from readgrid import editor

# Basic usage - will prompt for API key
editor(row_id="ID_1")

# With all options
editor(
    row_id="ID_1",
    api_key="YOUR_API_KEY",
    model="gemini-2.0-flash",
    clean=True,        # Auto-clean tables, LaTeX, newlines
    font_size=12       # Adjust display size
)

Features:

  • Currently supports just JSON file types.
  • Automatic cleaning of tables, LaTeX formatting, and broken words
  • Side-by-side view: original image vs. current JSON
  • Conversational interface: "Add newline after Table 1" or "Fix the header"
  • Real-time diff view (unified or side-by-side with color coding)
  • Undo/reset functionality
  • Saves corrections back to final_outputs/

📦 Requirements


📄 License

MIT License. See LICENSE for details.

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

readgrid-0.2.4.tar.gz (27.8 kB view details)

Uploaded Source

Built Distribution

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

readgrid-0.2.4-py3-none-any.whl (26.6 kB view details)

Uploaded Python 3

File details

Details for the file readgrid-0.2.4.tar.gz.

File metadata

  • Download URL: readgrid-0.2.4.tar.gz
  • Upload date:
  • Size: 27.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for readgrid-0.2.4.tar.gz
Algorithm Hash digest
SHA256 30168d930ad9c96c5fc92ef4b09526fe141e8324bf9dced1870f0985e2e9d9f4
MD5 8eddb5e7aebc9e5407474bc68cf4381e
BLAKE2b-256 48161f3e8d395ee4716a9cd8132f53cad56166e13da4300f088ff0c24e96b0ad

See more details on using hashes here.

File details

Details for the file readgrid-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: readgrid-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 26.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for readgrid-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9dc12d6081fea89c2ff6c1cf272740e4877a2159e8b55265f7b516ea9a41b796
MD5 a4e56b63c8034cbf1b9d7be3c77db4fb
BLAKE2b-256 0a1c046bfea062c54d877d713c642bd7fa07edf827520438248134bcd67cde2b

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