🚀 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},
}