Skip to main content

This package contains the AI models used by the Docling PDF conversion package

Project description

PyPI version PyPI - Python Version Poetry Code style: black Imports: isort pre-commit Models on Hugging Face License MIT

Docling IBM models

AI modules to support the Docling PDF document conversion project.

  • TableFormer is an AI module that recognizes the structure of a table and the bounding boxes of the table content.
  • Layout model is an AI model that provides among other things ability to detect tables on the page. This package contains inference code for Layout model.

Installation Instructions

MacOS / Linux

To install poetry locally, use either pip or homebrew.

To install poetry on a docker container, do the following:

ENV POETRY_NO_INTERACTION=1 \
    POETRY_VIRTUALENVS_CREATE=false

# Install poetry
RUN curl -sSL 'https://install.python-poetry.org' > install-poetry.py \
    && python install-poetry.py \
    && poetry --version \
    && rm install-poetry.py

To install and run the package, simply set up a poetry environment

poetry env use $(which python3.10)
poetry shell

and install all the dependencies,

poetry install # this will only install the deps from the poetry.lock

poetry install --no-dev # this will skip installing dev dependencies

To update or add new dependencies from pyproject.toml, rebuild poetry.lock

poetry update

MacOS Intel

When in development mode on MacOS with Intel chips, one can use compatible dependencies with

poetry update --with mac_intel

Pipeline Overview

Architecture

Datasets

Below we list datasets used with their description, source, and "TableFormer Format". The TableFormer Format is our processed version of the version of the original format to work with the dataloader out of the box, and to augment the dataset when necassary to add missing groundtruth (bounding boxes for empty cells).

Name Description URL
PubTabNet PubTabNet contains heterogeneous tables in both image and HTML format, 516k+ tables in the PubMed Central Open Access Subset PubTabNet
FinTabNet A dataset for Financial Report Tables with corresponding ground truth location and structure. 112k+ tables included. FinTabNet
TableBank TableBank is a new image-based table detection and recognition dataset built with novel weak supervision from Word and Latex documents on the internet, contains 417K high-quality labeled tables. TableBank

Models

TableModel04:

TableModel04 TableModel04rs (OTSL) is our SOTA method that using transformers in order to predict table structure and bounding box.

Configuration file

Example configuration can be found inside test tests/test_tf_predictor.py These are the main sections of the configuration file:

  • dataset: The directory for prepared data and the parameters used during the data loading.
  • model: The type, name and hyperparameters of the model. Also the directory to save/load the trained checkpoint files.
  • train: Parameters for the training of the model.
  • predict: Parameters for the evaluation of the model.
  • dataset_wordmap: Very important part that contains token maps.

Model weights

You can download the model weights and config files from the links:

Inference Tests

You can run the inference tests for the models with:

python -m pytest tests/

This will also generate prediction and matching visualizations that can be found here: tests\test_data\viz\

Visualization outlines:

  • Light Pink: border of recognized table
  • Grey: OCR cells
  • Green: prediction bboxes
  • Red: OCR cells matched with prediction
  • Blue: Post processed, match
  • Bold Blue: column header
  • Bold Magenta: row header
  • Bold Brown: section row (if table have one)

Demo

A demo application allows to apply the LayoutPredictor on a directory <input_dir> that contains png images and visualize the predictions inside another directory <viz_dir>.

First download the model weights (see above), then run:

python -m demo.demo_layout_predictor -i <input_dir> -v <viz_dir>

e.g.

python -m demo.demo_layout_predictor -i tests/test_data/samples -v viz/

Project details


Download files

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

Source Distribution

docling_ibm_models-2.0.6.tar.gz (58.6 kB view details)

Uploaded Source

Built Distribution

docling_ibm_models-2.0.6-py3-none-any.whl (65.9 kB view details)

Uploaded Python 3

File details

Details for the file docling_ibm_models-2.0.6.tar.gz.

File metadata

  • Download URL: docling_ibm_models-2.0.6.tar.gz
  • Upload date:
  • Size: 58.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for docling_ibm_models-2.0.6.tar.gz
Algorithm Hash digest
SHA256 b06bb8e426c8d53cb300b17a432120917a335390665302d82f311a3647ee1bca
MD5 02e90cef9b820e80e4b6a1d0a3c2be8e
BLAKE2b-256 d62f4b1c9622724b0779f56af84285837d4d40814feaa7a9c9051d79fab55e67

See more details on using hashes here.

File details

Details for the file docling_ibm_models-2.0.6-py3-none-any.whl.

File metadata

  • Download URL: docling_ibm_models-2.0.6-py3-none-any.whl
  • Upload date:
  • Size: 65.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for docling_ibm_models-2.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 1702b413353d18089511cb73fc325606eb3601b1406b1367a7c5070081f44af2
MD5 a18c79e9e759080500c82708e1dbd6e1
BLAKE2b-256 cc2ed83cae0bb698a3bc3ad37213bf6f549309bc1ff57ac718d4bd5f91e5efd8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page