docling-ibm-models


Namedocling-ibm-models JSON
Version 1.1.7 PyPI version JSON
download
home_pageNone
SummaryThis package contains the AI models used by the Docling PDF conversion package
upload_time2024-09-05 17:36:28
maintainerNone
docs_urlNone
authorNikos Livathinos
requires_python<4.0,>=3.10
licenseMIT
keywords docling convert document pdf layout model segmentation table structure table former
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![PyPI version](https://img.shields.io/pypi/v/docling-ibm-models)](https://pypi.org/project/docling-ibm-models/)
![Python](https://img.shields.io/badge/python-3.10%20|%203.11%20|%203.12-blue)
[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![Models on Hugging Face](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Model-blue)](https://huggingface.co/ds4sd/docling-models/)
[![License MIT](https://img.shields.io/github/license/ds4sd/deepsearch-toolkit)](https://opensource.org/licenses/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
```


## Pipeline Overview
![Architecture](docs/tablemodel_overview_color.png)

## 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](https://developer.ibm.com/exchanges/data/all/pubtabnet/) |
| FinTabNet| A dataset for Financial Report Tables with corresponding ground truth location and structure. 112k+ tables included.| [FinTabNet](https://developer.ibm.com/exchanges/data/all/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](https://github.com/doc-analysis/TableBank) |

## Models

### TableModel04:
![TableModel04](docs/tbm04.png)
**TableModel04rs (OTSL)** is our SOTA method that using transformers in order to predict table structure and bounding box.


## Configuration file

Example configuration can be seen 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:

- [TableFormer Checkpoint](https://huggingface.co/ds4sd/docling-models/tree/main/model_artifacts/tableformer)
- [beehive_v0.0.5](https://huggingface.co/ds4sd/docling-models/tree/main/model_artifacts/layout/beehive_v0.0.5)

Place the downloaded files into `tests/test_data/model_artifacts/` directory.


## Inference Tests

This contains unit tests for Docling models.

First download the model weights (see above), then run:
```
./devtools/check_code.sh
```

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/
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "docling-ibm-models",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "docling, convert, document, pdf, layout model, segmentation, table structure, table former",
    "author": "Nikos Livathinos",
    "author_email": "nli@zurich.ibm.com",
    "download_url": "https://files.pythonhosted.org/packages/9d/fc/04c534a155067dce61c5d3f5ccc6049bbed7594919e1e3f0f07bcf8006b0/docling_ibm_models-1.1.7.tar.gz",
    "platform": null,
    "description": "[![PyPI version](https://img.shields.io/pypi/v/docling-ibm-models)](https://pypi.org/project/docling-ibm-models/)\n![Python](https://img.shields.io/badge/python-3.10%20|%203.11%20|%203.12-blue)\n[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)\n[![Models on Hugging Face](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Model-blue)](https://huggingface.co/ds4sd/docling-models/)\n[![License MIT](https://img.shields.io/github/license/ds4sd/deepsearch-toolkit)](https://opensource.org/licenses/MIT)\n\n# Docling IBM models\n\nAI modules to support the Docling PDF document conversion project.\n\n- TableFormer is an AI module that recognizes the structure of a table and the bounding boxes of the table content.\n- 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.\n\n\n## Installation Instructions\n\n### MacOS / Linux\n\nTo install `poetry` locally, use either `pip` or `homebrew`.\n\nTo install `poetry` on a docker container, do the following:\n```\nENV POETRY_NO_INTERACTION=1 \\\n    POETRY_VIRTUALENVS_CREATE=false\n\n# Install poetry\nRUN curl -sSL 'https://install.python-poetry.org' > install-poetry.py \\\n    && python install-poetry.py \\\n    && poetry --version \\\n    && rm install-poetry.py\n```\n\nTo install and run the package, simply set up a poetry environment\n\n```\npoetry env use $(which python3.10)\npoetry shell\n```\n\nand install all the dependencies,\n\n```\npoetry install # this will only install the deps from the poetry.lock\n\npoetry install --no-dev # this will skip installing dev dependencies\n```\n\nTo update or add new dependencies from `pyproject.toml`, rebuild `poetry.lock`\n```\npoetry update\n```\n\n\n## Pipeline Overview\n![Architecture](docs/tablemodel_overview_color.png)\n\n## Datasets\nBelow 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).\n\n\n| Name        | Description      | URL |\n| ------------- |:-------------:|----|\n| PubTabNet | PubTabNet contains heterogeneous tables in both image and HTML format, 516k+ tables in the PubMed Central Open Access Subset  | [PubTabNet](https://developer.ibm.com/exchanges/data/all/pubtabnet/) |\n| FinTabNet| A dataset for Financial Report Tables with corresponding ground truth location and structure. 112k+ tables included.| [FinTabNet](https://developer.ibm.com/exchanges/data/all/fintabnet/) |\n| 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](https://github.com/doc-analysis/TableBank) |\n\n## Models\n\n### TableModel04:\n![TableModel04](docs/tbm04.png)\n**TableModel04rs (OTSL)** is our SOTA method that using transformers in order to predict table structure and bounding box.\n\n\n## Configuration file\n\nExample configuration can be seen inside test `tests/test_tf_predictor.py`\nThese are the main sections of the configuration file:\n\n- `dataset`: The directory for prepared data and the parameters used during the data loading.\n- `model`: The type, name and hyperparameters of the model. Also the directory to save/load the\n  trained checkpoint files.\n- `train`: Parameters for the training of the model.\n- `predict`: Parameters for the evaluation of the model.\n- `dataset_wordmap`: Very important part that contains token maps.\n\n\n## Model weights\n\nYou can download the model weights and config files from the links:\n\n- [TableFormer Checkpoint](https://huggingface.co/ds4sd/docling-models/tree/main/model_artifacts/tableformer)\n- [beehive_v0.0.5](https://huggingface.co/ds4sd/docling-models/tree/main/model_artifacts/layout/beehive_v0.0.5)\n\nPlace the downloaded files into `tests/test_data/model_artifacts/` directory.\n\n\n## Inference Tests\n\nThis contains unit tests for Docling models.\n\nFirst download the model weights (see above), then run:\n```\n./devtools/check_code.sh\n```\n\nThis will also generate prediction and matching visualizations that can be found here:\n`tests\\test_data\\viz\\`\n\nVisualization outlines:\n- `Light Pink`: border of recognized table\n- `Grey`: OCR cells\n- `Green`: prediction bboxes\n- `Red`: OCR cells matched with prediction\n- `Blue`: Post processed, match\n- `Bold Blue`: column header\n- `Bold Magenta`: row header\n- `Bold Brown`: section row (if table have one)\n\n\n## Demo\n\nA demo application allows to apply the `LayoutPredictor` on a directory `<input_dir>` that contains\n`png` images and visualize the predictions inside another directory `<viz_dir>`.\n\nFirst download the model weights (see above), then run:\n```\npython -m demo.demo_layout_predictor -i <input_dir> -v <viz_dir>\n```\n\ne.g.\n```\npython -m demo.demo_layout_predictor -i tests/test_data/samples -v viz/\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "This package contains the AI models used by the Docling PDF conversion package",
    "version": "1.1.7",
    "project_urls": null,
    "split_keywords": [
        "docling",
        " convert",
        " document",
        " pdf",
        " layout model",
        " segmentation",
        " table structure",
        " table former"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6906671d85d6828884319f0b959cd77eea64f194eaa6c7ccd80d5379a586b261",
                "md5": "b8b7bb0f14c03f4a9935b34b89c62936",
                "sha256": "a118c9a3b7cdcd6ee6190f6475cb56ca1a1a52f7e6632932cf9d5de5217098aa"
            },
            "downloads": -1,
            "filename": "docling_ibm_models-1.1.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b8b7bb0f14c03f4a9935b34b89c62936",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 87803,
            "upload_time": "2024-09-05T17:36:27",
            "upload_time_iso_8601": "2024-09-05T17:36:27.112382Z",
            "url": "https://files.pythonhosted.org/packages/69/06/671d85d6828884319f0b959cd77eea64f194eaa6c7ccd80d5379a586b261/docling_ibm_models-1.1.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9dfc04c534a155067dce61c5d3f5ccc6049bbed7594919e1e3f0f07bcf8006b0",
                "md5": "ed38a87c40cace10eb0f047cab48681f",
                "sha256": "d4699f24e32c314ecd6fe89e9067f1abe8808f83dd9c13d05d423361e92edc7d"
            },
            "downloads": -1,
            "filename": "docling_ibm_models-1.1.7.tar.gz",
            "has_sig": false,
            "md5_digest": "ed38a87c40cace10eb0f047cab48681f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 77946,
            "upload_time": "2024-09-05T17:36:28",
            "upload_time_iso_8601": "2024-09-05T17:36:28.770301Z",
            "url": "https://files.pythonhosted.org/packages/9d/fc/04c534a155067dce61c5d3f5ccc6049bbed7594919e1e3f0f07bcf8006b0/docling_ibm_models-1.1.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-05 17:36:28",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "docling-ibm-models"
}
        
Elapsed time: 1.67929s