Page Extractor
Extracts a page from a photo, and warps it to a rectangular image using skimage.
Features
- Remove margin clutter from photos of pages, usually improved document processing.
- GroundingDINO detection model integration.
- SAM 2.1
- Customizable text prompt, e.g. to "receipt." or "invoice."
Getting Started
Prerequisites
- Python 3.10 or higher
Installation
Installing PyTorch Dependencies
Before installing pageextractor, install PyTorch:
pip install torch==2.4.1 torchvision==0.19.1 --extra-index-url https://download.pytorch.org/whl/cu124
Installation options
pip install -U git+https://github.com/UG-Team-Data-Science/pageextractor.git
Or:
git clone https://github.com/UG-Team-Data-Science/pageextractor && cd pageextractor
pip install -e .
Usage
from PIL import Image
from matplotlib import pyplot as plt
from pageextractor import PageExtractor
img = Image.open('example.png')
model = PageExtractor(sam_type='sam2.1_hiera_tiny', device='cuda')
mask, polygon, cropped = model.extract_page(img)
_, (ax0, ax1, ax2) = plt.subplots(1, 3, figsize=(30, 15))
ax0.imshow(img)
ax1.imshow(img)
ax1.plot(*polygon[[0,1,2,3,0]].T, 'r:')
ax1.imshow(1-mask, cmap='Blues', alpha=0.8 - 0.8*mask)
ax2.imshow(cropped)
Examples
Photo of a book page, unfortunately centerfold and page block are included
Photo of a letter
Acknowledgments
This project is based on/used the following repositories:
Metadata
Release files for pageextractor 0.1.10
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 |
|---|---|---|---|---|
| pageextractor-0.1.10.tar.gz | 10.1 kB | Without provenance | Details for pageextractor-0.1.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pageextractor-0.1.10-py3-none-any.whl | Python 3 | none | any | Details for pageextractor-0.1.10-py3-none-any.whl |
Total release size: 20.9 kB
Release files / pageextractor-0.1.10.tar.gz
| Download URL | pageextractor-0.1.10.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f417fdd81e1adf4e85164f1bd28cc327dd5c4d5fc70cc735275fe7f668e892dd
|
|
BLAKE2b-256 checksum How to use checksums |
3182033ff4a86d293ac61e1fac44415bc91bd859ef47277a39643f66d083a0d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.13
|
Release files / pageextractor-0.1.10-py3-none-any.whl
| Download URL | pageextractor-0.1.10-py3-none-any.whl |
|---|---|
| Size | 10.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
276002acebf1ce893ed167b804b7daa83071fc5f9254fe71438c8f71cbfd8b9d
|
|
BLAKE2b-256 checksum How to use checksums |
e13ec744d399728c95ca0ea94b6a46ec13ca123560fa5ff1ddb654b16629ba2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.13
|
Security for pageextractor 0.1.10
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.