Skip to main content

doc-page-extractor

Document page extraction tool that converts page images into text layouts with pixel coordinates.

The default backend remains local DeepSeek-OCR for existing users. Version 1.1 also adds a unified OCR adapter layer with DeepSeek OpenAI-compatible Vendor support and Baidu cloud OCR support.

Installation

pip install doc-page-extractor

PyTorch is not installed automatically. You only need CUDA PyTorch when using the local DeepSeek-OCR backend.

Backends

Local DeepSeek-OCR

This is the default and keeps the existing API behavior:

from doc_page_extractor import create_page_extractor

extractor = create_page_extractor()

Install CUDA PyTorch before using this backend:

# CUDA 12.1
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121

# CUDA 11.8
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118

# CUDA 12.6
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu126

Check CUDA with:

nvidia-smi
python -c "import torch; print(torch.cuda.is_available())"

DeepSeek OCR Vendor

Use this backend when DeepSeek OCR is exposed through an OpenAI-compatible endpoint:

from doc_page_extractor import (
    DeepSeekVendorOCRConfig,
    create_deepseek_vendor_page_extractor,
)

extractor = create_deepseek_vendor_page_extractor(
    DeepSeekVendorOCRConfig.from_env()
)

Expected environment variables:

DOC_PAGE_EXTRACTOR_DEEPSEEK_VENDOR_BASE_URL=
DOC_PAGE_EXTRACTOR_DEEPSEEK_VENDOR_API_KEY=
DOC_PAGE_EXTRACTOR_DEEPSEEK_VENDOR_MODEL=deepseek-ocr
DOC_PAGE_EXTRACTOR_DEEPSEEK_VENDOR_TEMPERATURE=0.0
DOC_PAGE_EXTRACTOR_DEEPSEEK_VENDOR_TOP_P=0.7

Baidu Cloud OCR

Use this backend for Baidu Unlimited-OCR through Baidu Cloud:

from doc_page_extractor import BaiduCloudOCRConfig, create_baidu_page_extractor

extractor = create_baidu_page_extractor(BaiduCloudOCRConfig.from_env())

Expected environment variables:

DOC_PAGE_EXTRACTOR_BAIDU_AK=
DOC_PAGE_EXTRACTOR_BAIDU_SK=
DOC_PAGE_EXTRACTOR_BAIDU_BASE_URL=https://aip.baidubce.com

Extraction

All backends return the same PageExtractor shape:

from PIL import Image
from doc_page_extractor import ExtractionContext

context = ExtractionContext(check_aborted=lambda: False)

for page_image, layouts in extractor.extract(
    image=Image.open("page.png"),
    size="gundam",
    stages=1,
    context=context,
):
    for layout in layouts:
        print(layout.det, layout.text)

Layout keeps the original ref, det, and text fields. Version 1.1 adds optional metadata fields such as type, polygon, html, source, and raw for adapters that provide richer layout data.

Development

For contributors and developers, see Development Guide.

Useful local commands:

poetry run python test.py
poetry run pylint --disable=import-error doc_page_extractor
poetry run python scripts/ocr_sample.py --adapter both --image tests/images/friendly-title.png

Requirements

  • Python >= 3.10, < 3.14
  • CUDA-capable NVIDIA GPU only when using local DeepSeek-OCR
  • Remote OCR credentials only when using DeepSeek Vendor or Baidu Cloud OCR

Dependencies & Licenses

This project is licensed under the MIT License. The local DeepSeek-OCR backend depends on the DeepSeek-OCR model, which uses easydict (LGPLv3) for configuration management.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

doc_page_extractor-1.1.0.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

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

doc_page_extractor-1.1.0-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: doc_page_extractor-1.1.0.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.4 Darwin/25.5.0

File hashes

Hashes for doc_page_extractor-1.1.0.tar.gz
Algorithm Hash digest
SHA256 547240cb95e76b6c0a2caf6216826da61fe589c4e405113035f3579ca997efb3
MD5 12810dd6de2cc5fd044516fe432547e0
BLAKE2b-256 3c54eb7b6127ba2365994edc5f4316933a3a9ade267068310d159b39c5a03aca

See more details on using hashes here.

File details

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

File metadata

  • Download URL: doc_page_extractor-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.4 Darwin/25.5.0

File hashes

Hashes for doc_page_extractor-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 011765b9e839c48460cca0c7c5c0d52712201f1eb029c511b8b12346f1fe1d5b
MD5 04677d5ef8ba3da53e1bcd7681c428fb
BLAKE2b-256 38ea7637ec005862e049337e6b97b3226fcb1fb51f64cba5ba907970f1bf8020

See more details on using hashes here.

Release history Release notifications | RSS feed

1.2.0

2 files

1.1.1

2 files

This release

1.1.0 This release

2 files

1.0.12

2 files

1.0.11

2 files

1.0.10

2 files

1.0.9

2 files

1.0.8

2 files

1.0.7

2 files

1.0.6

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page