Version v.0.43
includes a significant redesign of the Analyzer's default configuration. Key changes include:
- More powerful models for Document Layout Analysis and OCR.
- Expanded functionality.
- Less dependencies.
deepdoctection is a Python library that orchestrates Scan and PDF document layout analysis and extraction for RAG. It also provides a framework for training, evaluating and inferencing Document AI models.
Check the demo of a document layout analysis pipeline with OCR on π€ Hugging Face spaces.
- Document layout analysis and table recognition in PyTorch with Detectron2 and Transformers or Tensorflow and Tensorpack,
- OCR with support of Tesseract, DocTr and AWS Textract,
- Document and token classification with the LayoutLM family, LiLT and selected Bert-style including features like sliding windows.
- Text mining for native PDFs with pdfplumber,
- Language detection with fastText,
- Deskewing and rotating images with jdeskew.
- Fine-tuning and evaluation tools.
- Lot's of tutorials
Have a look at the introduction notebook for an easy start.
Check the release notes for recent updates.
import deepdoctection as dd
from IPython.core.display import HTML
from matplotlib import pyplot as plt
analyzer = dd.get_dd_analyzer() # instantiate the built-in analyzer similar to the Hugging Face space demo
df = analyzer.analyze(path = "/path/to/your/doc.pdf") # setting up pipeline
df.reset_state() # Trigger some initialization
doc = iter(df)
page = next(doc)
image = page.viz(show_figures=True, show_residual_layouts=True)
plt.figure(figsize = (25,17))
plt.axis('off')
plt.imshow(image)
HTML(page.tables[0].html)
print(page.text)
- Linux or macOS. Windows is not supported but there is a Dockerfile available.
- Python >= 3.9
- 2.2 <= PyTorch or 2.11 <= Tensorflow < 2.16. (For lower Tensorflow versions the code will only run on a GPU). Tensorflow support will be stopped from Python 3.11 onwards.
- To fine-tune models, a GPU is recommended.
Task | PyTorch | Torchscript | Tensorflow |
---|---|---|---|
Layout detection via Detectron2/Tensorpack | β | β (CPU only) | β (GPU only) |
Table recognition via Detectron2/Tensorpack | β | β (CPU only) | β (GPU only) |
Table transformer via Transformers | β | β | β |
Deformable-Detr | β | β | β |
DocTr | β | β | β |
LayoutLM (v1, v2, v3, XLM) via Transformers | β | β | β |
We recommend using a virtual environment.
For a simple setup which is enough to parse documents with the default setting, install the following:
PyTorch
pip install transformers
pip install python-doctr
pip install deepdoctection
TensorFlow
pip install tensorpack
pip install python-doctr
pip install deepdoctection
Both setups are sufficient to run the introduction notebook.
The following installation will give you ALL models available within the Deep Learning framework as well as all models that are independent of Tensorflow/PyTorch.
PyTorch
First install Detectron2 separately as it is not distributed via PyPi. Check the instruction here or try:
pip install detectron2@git+https://github.com/deepdoctection/detectron2.git
Then install deepdoctection with all its dependencies:
pip install deepdoctection[pt]
Tensorflow
pip install deepdoctection[tf]
For further information, please consult the full installation instructions.
Download the repository or clone via
git clone https://github.com/deepdoctection/deepdoctection.git
PyTorch
cd deepdoctection
pip install ".[pt]" # or "pip install -e .[pt]"
Tensorflow
cd deepdoctection
pip install ".[tf]" # or "pip install -e .[tf]"
Pre-existing Docker images can be downloaded from the Docker hub.
docker pull deepdoctection/deepdoctection:<release_tag>
Use the Docker compose file ./docker/pytorch-gpu/docker-compose.yaml
.
In the .env
file provided, specify the host directory where deepdoctection's cache should be stored.
Additionally, specify a working directory to mount files to be processed into the container.
docker compose up -d
will start the container. There is no endpoint exposed, though.
We thank all libraries that provide high quality code and pre-trained models. Without, it would have been impossible to develop this framework.
...you can easily support the project by making it more visible. Leaving a star or a recommendation will help.
Distributed under the Apache 2.0 License. Check LICENSE for additional information.