Part of the Abstract Media Intelligence Platform
This module provides layout-aware OCR as part of a larger media processing system.
abstract_ocr focuses on extraction:
- multi-engine OCR (Tesseract / EasyOCR / PaddleOCR)
- column detection and region segmentation
- structured, position-aware text output
Full system: https://github.com/AbstractEndeavors/abstract-media-intelligence
abstract_ocr / layout_ocr — Layout-Aware OCR Pipeline
A structured OCR pipeline designed for layout-aware text extraction from complex documents, combining preprocessing, column detection, region classification, and ordered OCR assembly.
Built to handle:
- multi-column PDFs
- mixed-content layouts (text, figures, captions)
- noisy or scanned documents
- large-scale document ingestion pipelines
🔹 What This System Is
This is not a simple OCR wrapper — it is a typed, multi-stage processing pipeline:
- transforms raw images into structured page representations
- detects document layout (columns, headers, regions)
- classifies content blocks (text, figures, captions)
- applies OCR at the region level
- reconstructs output in correct reading order
The system is designed for deterministic, reproducible extraction rather than heuristic text scraping.
Pipeline Overview
PDF Input
↓
Slice / Decompose (images + text per page)
↓
OCR + Text Extraction (layout-aware engines)
↓
Metadata Generation
├─ summaries
├─ keywords
└─ descriptions
↓
Manifest Creation (per-page + per-document)
↓
HTML Generation
├─ PDF viewer pages
└─ gallery index pages
↓
Static Site Output (SEO-ready)
flowchart TD
A[Input Image / Page Image]
B[Preprocess\nDenoise + Binarize]
C[Layout Detection\nColumns + Header Cutoff]
D[Region Classification\nText / Figure / Caption]
E[Region OCR\nCrop + Tesseract]
F[Fallback OCR\nColumn-level OCR]
G[Reading Order Assembly]
H[Structured OCRResult\nBlocks + Raw Text + Layout]
A --> B --> C --> D --> E --> G --> H
D -->|No usable regions| F --> G
🔹 Core Capabilities
-
Layout Detection
- Column detection via vertical projection valleys
- Header segmentation via density scanning
- Multi-column classification (single / dual / mixed)
-
Region Classification
- Connected-component analysis
- Density-based classification (text vs figure vs caption)
- Column-aware region assignment
-
Region-Level OCR
- OCR applied per detected block (not full-page)
- Adaptive Tesseract configuration by region type
- Automatic fallback to column-level OCR when detection fails
-
Reading Order Reconstruction
- Column-aware ordering
- Top-to-bottom sequencing within columns
- Header/body/caption prioritization
-
Typed Pipeline Execution
- All steps validated via explicit input/output types
- Registry-driven execution model
- No implicit coupling between pipeline stages
🔹 Architecture
The pipeline is built around a step registry + type-safe execution chain:
-
Each step declares:
- input type
- output type
-
The pipeline validates compatibility before execution
-
Execution is explicit, deterministic, and observable
Example chain:
["preprocess", "detect_layout", "ocr_regions"]
Each step is independently replaceable and composable.
🔹 Key Design Decisions
Typed Data Flow
All intermediate results are structured dataclasses:
PageImagePreprocessedImageLayoutDetectionOCRResult
No ad-hoc dictionaries — ensures:
- traceability
- consistency
- debuggability
Layout-First OCR
OCR is applied after structure is understood, not before.
This prevents:
- column interleaving
- incorrect reading order
- misclassification of content
Fallback Over Failure
If region detection fails:
- system falls back to column-level OCR
- ensures output is still usable
Determinism Over Heuristics
- explicit thresholds (config-driven)
- no hidden behavior
- reproducible results across runs
🔹 Why This Exists
Traditional OCR pipelines:
- ignore layout
- operate on full pages
- produce inconsistent reading order
- fail silently on complex documents
This system:
- understands document structure
- isolates regions before OCR
- enforces reading order
- produces structured outputs suitable for downstream systems
🔹 Example Use Cases
- PDF → structured text extraction
- research document ingestion pipelines
- financial filings parsing
- multi-column article extraction
- preprocessing for NLP / LLM pipelines
- search indexing and document analysis
🔹 Integration Context
This module is designed to plug into:
- document ingestion systems
- OCR + NLP pipelines (e.g. abstract_hugpy)
- search and indexing systems
- large-scale document processing workflows
🔹 Design Philosophy
- Structure before extraction
- Determinism over convenience
- Typed pipelines over implicit flows
- Fallback over failure
Metadata
Release files for abstract-ocr 0.0.1.71
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| abstract_ocr-0.0.1.71.tar.gz | 52.3 kB | Without provenance | Details for abstract_ocr-0.0.1.71.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| abstract_ocr-0.0.1.71-py3-none-any.whl | Python 3 | none | any | Details for abstract_ocr-0.0.1.71-py3-none-any.whl |
Total release size: 125.2 kB
Release files / abstract_ocr-0.0.1.71.tar.gz
| Download URL | abstract_ocr-0.0.1.71.tar.gz |
|---|---|
| Size | 52.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e8ca1d985989e9402bd32561bd6a87a55107af52f26cca010547882781039958
|
|
BLAKE2b-256 checksum How to use checksums |
01804aac0dbaf813025d9cf02983a8d54ee8b8018c7636ee3e0bc9c3964ab47c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / abstract_ocr-0.0.1.71-py3-none-any.whl
| Download URL | abstract_ocr-0.0.1.71-py3-none-any.whl |
|---|---|
| Size | 72.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fd657f9a30ba2928ecb1b5d1fea7af6f27f89a984dfa18d48820af7c80468d2c
|
|
BLAKE2b-256 checksum How to use checksums |
b5b520b9d08f9666366b158bebcc4a9a80e0111b934ff1617840f16c1208cb64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for abstract-ocr 0.0.1.71
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.