• Python 90.3%
  • Jupyter Notebook 9.2%
  • Dockerfile 0.5%
Find a file
2025-12-31 10:15:02 +00:00
.vscode chore: enable tests 2024-04-17 13:03:25 +02:00
test chore: add test cases 2024-12-01 22:28:38 +01:00
.coveragerc chore: added coverage config 2025-01-13 10:39:57 +01:00
.editorconfig chore: set .editorconfig 2025-04-21 23:20:39 +00:00
.gitignore chore: added .venv to gitignore 2024-10-07 08:57:46 +02:00
.gitlab-ci.yml fix: removed helm from gitlab ci 2025-09-23 10:41:20 +02:00
bbox.py chore: remove obsolete function border_polygons 2024-12-01 22:41:47 +01:00
CHANGELOG.md chore(release): 3.1.1 2025-12-31 10:08:10 +00:00
CODEOWNERS chore: set CODEOWNERS 2025-04-22 00:26:21 +00:00
colors.py refactor: optimize getting top colors 2025-06-02 17:37:15 +02:00
docker-compose.yaml chore: removed minio-init container now that baseworker upserts buckets 2025-12-03 13:27:25 +01:00
Dockerfile feat(deps): python 3.14.2 and kimiworker 8.0.3 2025-12-30 16:28:05 +01:00
filters.py fix: revert to ContentDefinition 2024-11-14 11:42:39 +01:00
grid.py fix: improve performance 2024-11-28 11:03:35 +01:00
image.py feat: use pageImage attribute 2025-11-25 15:43:29 +01:00
LICENSE chore: add license 2025-04-15 00:16:00 +02:00
line_height_labels.py feat: label confidence between 0 and 1 2024-12-02 10:55:41 +01:00
line_heights.py chore: added unit tests 2025-01-13 18:00:26 +01:00
lines.py fix: correctly formatted fallback lines 2024-12-02 16:19:00 +00:00
main.py feat!: use configurable bucket names 2025-12-22 15:09:07 +01:00
neighbor_labels.py feat: label confidence between 0 and 1 2024-12-02 10:55:41 +01:00
outliers.py feat: remove bold detection based on color coverage 2024-04-25 16:27:23 +02:00
page_boundary_labels.py feat: label confidence between 0 and 1 2024-12-02 10:55:41 +01:00
poetry.lock fix(deps): update dependency kimiworker to v8.0.4 2025-12-31 09:56:14 +00:00
pyproject.toml chore(release): 3.1.1 2025-12-31 10:08:10 +00:00
README.md fix: updated README 2025-09-17 16:31:04 +02:00
renovate.json chore: migrated to poetry 2025-09-16 09:42:21 +02:00
test.ipynb fix: upload to correct worker-data bucket 2025-11-25 15:25:31 +01:00
test_bbox.py feat: add function to calculate intersection ratio 2024-12-01 22:18:11 +01:00
test_colors.py chore: add docstrings 2024-12-01 22:24:35 +01:00
test_filters.py fix: revert to ContentDefinition 2024-11-14 11:42:39 +01:00
test_grid.py chore: add tests for pairwise grid iterator 2024-12-01 22:42:55 +01:00
test_image.py chore: remove deprecated attribute 2025-12-15 15:34:33 +01:00
test_line_height_labels.py chore: added unit tests for coverage 2025-01-02 17:55:20 +01:00
test_line_heights.py chore: added unit tests 2025-01-13 18:00:26 +01:00
test_lines.py fix: correctly formatted fallback lines 2024-12-02 16:19:00 +00:00
test_main_generate_labels.py feat!: use configurable bucket names 2025-12-22 15:09:07 +01:00
test_main_job_handler.py feat!: use configurable bucket names 2025-12-22 15:09:07 +01:00
test_neighbor_labels.py chore: added unit tests for coverage 2025-01-02 17:55:20 +01:00
test_outliers.py feat: remove bold detection based on color coverage 2024-04-25 16:27:23 +02:00
test_page_boundary_labels.py chore: added unit tests for coverage 2025-01-02 17:55:20 +01:00
test_text_labels.py fix: list item like only when followed by non-whitespace characters 2025-09-11 14:36:21 +02:00
test_utils.py chore: use kimiworker 6.2.0 beta with shared attribute utilities 2025-12-09 08:56:13 +01:00
test_validations.py fix: list item like needs to be followed by alphanumeric characters 2025-09-11 14:49:10 +02:00
text_labels.py fix: changed confidence scale from 0-100 to 0-1 2025-04-01 16:15:03 +02:00
utils.py chore: use kimiworker 6.2.0 beta with shared attribute utilities 2025-12-09 08:56:13 +01:00
validations.py chore: put back type 2025-09-11 14:55:47 +02:00

Page Regions Image Processing

pipeline status coverage report Latest Release

A Python worker that detects page regions through advanced image processing techniques. This worker analyzes raw page images to identify and classify different content regions within documents by processing grid intersections, analyzing text overlaps, and applying computer vision algorithms.

Features

  • Advanced region detection using OpenCV and image processing
  • Grid-based intersection analysis for precise region boundaries
  • Text overlap detection with spatial indexing (STRtree)
  • Color analysis and background detection
  • Line height analysis and text classification
  • Integration with RabbitMQ for message queuing
  • MinIO support for object storage
  • Docker deployment ready

Getting Started

Local Installation

  1. Clone the repository:

    git clone https://gitlab.com/logius/nldoc/worker/page-regions-image-processing.git
    cd page-regions-image-processing
    
  2. Install dependencies:

    poetry install
    
  3. For macOS users, additional dependencies are required:

    brew install conda
    export PATH="/opt/homebrew/anaconda3/bin:$PATH"
    brew install tesseract
    conda install -c conda-forge tesserocr
    

Running the Worker

  1. Ensure Docker and Docker Compose are installed (Installation Guide)

  2. Start the services:

    docker compose up
    
  3. Use the included Jupyter notebook test.ipynb to perform end-to-end testing and visualization

  4. Access the management interfaces:

    • RabbitMQ Console: http://localhost:15672/
    • MinIO Console: http://localhost:9001/
  5. Once the docker compose up command has been exited using Ctrl+C, all containers relative to this instance will have shut down automatically.

Running Directly

To run the worker without Docker:

python3 main.py

For configuration options, refer to the Python base worker config.

Testing and Development

Use the included Jupyter notebook test.ipynb to visualize processing results on sample pages:

  1. Ensure all dependencies are installed (follow installation steps above)
  2. Launch Jupyter notebook
  3. Open test.ipynb and run the cells to process sample pages and visualize region detection

Run the test suite:

pytest

How It Works

The worker processes page images through several stages:

  1. Image Processing: Loads and preprocesses images using OpenCV
  2. Line Detection: Identifies structural lines in the document
  3. Grid Analysis: Creates intersection points from detected lines
  4. Region Formation: Groups intersections to form content regions
  5. Text Overlap Detection: Uses spatial indexing to find text within regions
  6. Classification: Applies various labeling algorithms to classify regions:
    • Text analysis and content type detection
    • Color analysis for backgrounds and text colors
    • Line height analysis for typography classification
    • Spatial relationship analysis between regions
    • Page boundary detection

Deployment

Docker Images

Pre-built Docker images are available in our container registry.

Run the latest version:

docker run --rm registry.gitlab.com/logius/nldoc/worker/page-regions-image-processing:latest

Documentation

License

This project is licensed under the European Union Public License 1.2 - see LICENSE for details.

Acknowledgements

  • OpenCV for computer vision and image processing capabilities
  • Shapely for geometric operations and spatial analysis
  • NumPy and SciPy for numerical computing