Cyrile's picture
Update README.md
965ba7e verified
|
raw
history blame
3.69 kB
metadata
library_name: transformers
license: apache-2.0
datasets:
  - ds4sd/DocLayNet
pipeline_tag: image-segmentation

DETR-layout-detection

We present the model cmarkea/detr-layout-detection, which allows extracting different layouts (Text, Picture, Caption, Footnote, etc.) from an image of a document. This is a fine-tuning of the model detr-resnet-50 on the DocLayNet dataset. This model can jointly predict masks and bounding boxes for documentary objects. It is ideal for processing documentary corpora to be ingested into an ODQA system.

This model allows extracting 11 entities, which are: Caption, Footnote, Formula, List-item, Page-footer, Page-header, Picture, Section-header, Table, Text, and Title.

Performance

In this section, we will assess the model's performance by separately considering semantic segmentation and object detection. In both cases, no post-processing was applied after estimation.

For semantic segmentation, we will use the F1-score to evaluate the classification of each pixel. For object detection, we will assess performance based on the Generalized Intersection over Union (GIoU) and the accuracy of the predicted bounding box class. The evaluation is conducted on 500 pages from the PDF evaluation dataset of DocLayNet.

Class f1-score (x100) GIoU (x100) accuracy (x100)
Background 91.69 NA NA
Caption 41.17 29.84 21.43
Footnote 0 24.42 0
Formula 66.74 43.28 66.30
List-item 55.41 42.39 85.63
Page-footer 70.95 -9.69 70.80
Page-header 53.28 37.41 66.85
Picture 68.66 64.90 93.31
Section-header 50.52 20.90 50.54
Table 70.31 69.28 70.40
Text 81.87 52.53 77.96
Title 0 31.90 0

Benchmark

Now, let's compare the performance of this model with other models.

Class f1-score (x100) GIoU (x100) accuracy (x100)
cmarkea/detr-layout-detection 84.23 43.84
cmarkea/dit-base-layout-detection 90.77 56.29 85.26

Direct Use

from transformers import AutoImageProcessor
from transformers.models.detr import DetrForSegmentation

img_proc = AutoImageProcessor.from_pretrained(
    "ArkeaIAF/detr-layout-detection"
)
model = DetrForSegmentation.from_pretrained(
    "ArkeaIAF/detr-layout-detection"
)

with torch.inference_mode():
    input_ids = img_proc(img, return_tensors='pt')
    output = model(**input_ids)

threshold=0.4

segmentation_mask = img_proc.post_process_segmentation(
    out_seg,
    threshold=threshold,
    target_sizes=[img.size[::-1]]
)

bbox_pred = img_proc.post_process_object_detection(
    output,
    threshold=threshold,
    target_sizes=[img.size[::-1]]
)

Citation

@online{DeDetrLay,
  AUTHOR = {Cyrile Delestre},
  URL = {https://huggingface.co/cmarkea/detr-base-layout-detection},
  YEAR = {2024},
  KEYWORDS = {Image Processing ; Transformers ; Layout},
}