(04/04/2023) This Inference APP uses an ensemble of 2 Document Understanding models finetuned on the dataset DocLayNet base at paragraph level (chunk size of 512 tokens) and combined with XLM-RoBERTa base: LiLT base and LayoutXLM base.
This ensemble calculates the probabilities of each block from the outputs of the models for each label before selecting the label with the highest sum of the normalized probabilities.
\n", "Note: LiLT (Language-Independent Layout Transformer) and LayoutXLM: Multimodal Pre-training for Multilingual Visually-rich Document Understanding are Document Understanding models that use both layout and text in order to detect labels of bounding boxes. Combined with the model XML-RoBERTa base, this finetuned model has the capacity to understand any language. Finetuned on the dataset DocLayNet base, they can classifly any bounding box (and its OCR text) to 11 labels (Caption, Footnote, Formula, List-item, Page-footer, Page-header, Picture, Section-header, Table, Text, Title).
\n", "They rely on an external OCR engine to get words and bounding boxes from the document image. Thus, let's run in this APP an OCR engine (PyTesseract) to get the bounding boxes, then run the 2 models (already fine-tuned on the dataset DocLayNet base at paragraph level) on the individual tokens and then, normalized the sum of block probabilities as explained, and visualize the result at paragraph level!
\n", "It allows to get all pages of any PDF (of any language) with bounding boxes labeled at paragraph level and the associated dataframes with labeled data (bounding boxes, texts, labels) :-)
However, the inference time per page can be high when running the model on CPU due to the number of paragraph predictions to be made. Therefore, to avoid running this APP for too long, only the first 2 pages are processed by this APP. If you want to increase this limit, you can either clone this APP in Hugging Face Space (or run its notebook on your own plateform) and change the value of the parameter max_imgboxes
, or run the inference notebook \"Document AI | Inference at paragraph level by using the association of 2 Document Understanding models (LiLT and LayoutXLM base fine-tuned on DocLayNet base dataset)\" on your own platform as it does not have this limit.
Links to Document Understanding APPs:
More information about the DocLayNet datasets, the finetuning of the model and this APP in the following blog posts:
\n", "