• Jupyter Notebook 99.4%
  • Python 0.5%
Find a file
2025-12-31 10:13:57 +00:00
.vscode fix: compatibility 2024-04-30 16:28:50 +02:00
test fix: don't crash on empty pages 2024-12-02 19:02:31 +01:00
.editorconfig chore: set .editorconfig 2025-04-21 23:20:37 +00:00
.gitignore fix: don't crash on empty pages 2024-12-02 19:02:31 +01:00
.gitlab-ci.yml fix: removed helm from ci 2025-09-18 10:39:49 +02:00
CHANGELOG.md chore(release): 3.1.1 2025-12-31 10:08:19 +00:00
CODEOWNERS chore: set CODEOWNERS 2025-04-22 00:26:18 +00:00
conftest.py feat: prepare for automated releases and tests 2024-04-04 09:39:22 +02:00
content_extraction.py chore: tracking tesserocr init 2025-09-04 14:00:08 +02:00
detect_language.py chore: don't require cover for __main__ 2025-01-02 17:03:14 +01:00
docker-compose.yaml chore: removed minio-init container now that baseworker upserts buckets 2025-12-03 13:27:21 +01:00
Dockerfile feat(deps): python 3.14.2 and kimiworker 8.0.3 2025-12-30 16:28:05 +01:00
language_map.py feat: get page content 2024-01-30 18:04:34 +01:00
LICENSE chore: add license 2025-04-15 00:17:24 +02:00
main.py fix: use bucket name from config for file result 2025-12-23 09:22:22 +01:00
parse.py chore: tracking tesserocr init 2025-09-04 14:00:08 +02:00
poetry.lock fix(deps): update dependency kimiworker to v8.0.4 2025-12-31 09:56:21 +00:00
pyproject.toml chore(release): 3.1.1 2025-12-31 10:08:19 +00:00
README.md fix: updated Dockerfile to use poetry instead of pip 2025-09-17 16:30:22 +02:00
renovate.json fix: dependencies now also release as fix 2025-09-11 11:41:40 +02:00
test.ipynb fix: update references (GitLab migration) 2025-04-07 15:29:54 +02:00
test_detect_language.py chore: added unit tests 2025-01-02 16:55:49 +01:00
test_main.py fix: updated unit test 2025-12-23 11:26:55 +01:00
test_parse.py chore: fixed parse tests 2025-09-16 13:58:43 +02:00

Extract Page Interpreted Content OCR

pipeline status coverage report Latest Release

A Python worker that extracts text content from page images using Tesseract OCR via the tesserocr Python wrapper. This worker processes document page images to extract text with confidence scores, language detection, and detailed text structure analysis.

Features

  • High-quality text extraction using Tesseract OCR engine
  • Automatic language detection for extracted text
  • Text structure analysis (text lines, words, block types)
  • Confidence scoring for extracted content
  • 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-interpreted-content-ocr.git
    cd page-interpreted-content-ocr
    
  2. Install system dependencies:

    macOS:

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

    Linux:

    apt-get update && apt-get install -y tesseract-ocr libtesseract-dev libleptonica-dev
    
  3. Install Poetry (dependency management):

    curl -sSL https://install.python-poetry.org | python3 -
    
  4. Install dependencies:

    poetry install
    
  5. Install shell plugin:

    poetry self add poetry-plugin-shell
    
  6. Activate virtual environment:

    poetry shell
    

Running the Worker

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

  2. Start the services:

    docker compose up
    
  3. Access the management interfaces:

    • RabbitMQ Console: http://localhost:15672/
    • MinIO Console: http://localhost:9001/
  4. 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

Required environment variables:

  • AMQP_HOST: RabbitMQ host (default: 127.0.0.1)
  • AMQP_PORT: RabbitMQ port (default: 5672)
  • AMQP_USER: RabbitMQ username
  • AMQP_PASS: RabbitMQ password
  • EXCHANGE: RabbitMQ exchange name (default: page-interpretedcontent)
  • MINIO_HOST: MinIO host (default: 127.0.0.1)
  • MINIO_PORT: MinIO port (default: 9000)
  • MINIO_ACCESS_KEY: MinIO access key
  • MINIO_SECRET_KEY: MinIO secret key
  • MINIO_USE_SSL: Use SSL for MinIO connection (default: False)

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

Testing and Development

Run the test suite:

pytest

The worker includes:

  • Unit tests for language detection (test_detect_language.py)
  • Unit tests for main worker functionality (test_main.py)
  • Unit tests for OCR parsing (test_parse.py)

How It Works

The worker processes page images through the following pipeline:

  1. Image Processing: Opens the provided page image using PIL
  2. OCR Analysis: Uses Tesseract OCR to analyze the image layout and extract text
  3. Language Detection: Automatically detects the language of extracted text
  4. Text Structure Analysis: Extracts detailed information about:
    • Text lines with bounding boxes and confidence scores
    • Individual words within each line
    • Block types (flowing text, headings, captions, etc.)
    • Text attributes and positioning
  5. Result Publishing: Returns structured content with confidence metrics

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-interpreted-content-ocr:latest

Documentation

License

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

Acknowledgements