🚀 DETR-layout-detection
我们推出了模型 cmarkea/detr-layout-detection
,该模型可从文档图像中提取不同的布局元素(如文本、图片、标题、脚注等)。此模型是在 DocLayNet 数据集上对 detr-resnet-50 模型进行微调得到的。它能够同时预测文档对象的掩码和边界框,非常适合处理要导入开放域问答(ODQA)系统的文档语料库。
该模型可以提取 11 种实体,分别为:标题、脚注、公式、列表项、页面页脚、页面页眉、图片、章节标题、表格、文本和标题。
✨ 主要特性
- 可从文档图像中提取多种布局元素。
- 基于
detr-resnet-50
模型在 DocLayNet
数据集上微调。
- 能同时预测文档对象的掩码和边界框。
- 适用于处理要导入 ODQA 系统的文档语料库。
📚 详细文档
性能评估
在本节中,我们将分别从语义分割和目标检测两个方面评估模型的性能。在这两种情况下,估计后均未进行后处理。
对于语义分割,我们将使用 F1 分数来评估每个像素的分类情况。对于目标检测,我们将基于广义交并比(GIoU)和预测边界框类别的准确率来评估性能。评估是在 DocLayNet
的 PDF 评估数据集的 500 页上进行的。
类别 |
F1 分数(x100) |
GIoU(x100) |
准确率(x100) |
背景 |
95.82 |
NA |
NA |
标题 |
82.68 |
74.71 |
69.05 |
脚注 |
78.19 |
74.71 |
74.19 |
公式 |
87.25 |
76.31 |
97.79 |
列表项 |
81.43 |
77.0 |
90.62 |
页面页脚 |
82.01 |
69.86 |
96.64 |
页面页眉 |
68.32 |
77.68 |
88.3 |
图片 |
81.04 |
81.84 |
90.88 |
章节标题 |
73.52 |
73.46 |
85.96 |
表格 |
78.59 |
85.45 |
90.58 |
文本 |
91.93 |
83.16 |
91.8 |
标题 |
70.38 |
74.13 |
63.33 |
基准测试
现在,让我们将该模型的性能与其他模型进行比较。
💻 使用示例
基础用法
from transformers import AutoImageProcessor
from transformers.models.detr import DetrForSegmentation
img_proc = AutoImageProcessor.from_pretrained(
"cmarkea/detr-layout-detection"
)
model = DetrForSegmentation.from_pretrained(
"cmarkea/detr-layout-detection"
)
img: PIL.Image
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(
output,
threshold=threshold,
target_sizes=[img.size[::-1]]
)
bbox_pred = img_proc.post_process_object_detection(
output,
threshold=threshold,
target_sizes=[img.size[::-1]]
)
示例展示

📄 许可证
本项目采用 apache-2.0
许可证。
📚 引用信息
@online{DeDetrLay,
AUTHOR = {Cyrile Delestre},
URL = {https://huggingface.co/cmarkea/detr-layout-detection},
YEAR = {2024},
KEYWORDS = {Image Processing ; Transformers ; Layout},
}