🚀 文档图像变换器(大型模型)
文档图像变换器(Document Image Transformer,简称DiT)是一种预训练模型,可用于处理文档图像。它基于Transformer架构,在大规模文档图像数据集上进行预训练,能有效提取文档图像的特征,适用于文档图像分类、表格检测和文档布局分析等任务。
🚀 快速开始
文档图像变换器(DiT)模型在IIT - CDIP(Lewis等人,2006)上进行了预训练,该数据集包含4200万张文档图像。之后,它在RVL - CDIP上进行了微调,RVL - CDIP数据集由40万张灰度图像组成,分为16个类别,每个类别有25000张图像。该模型由Li等人在论文DiT: Self - supervised Pre - training for Document Image Transformer中提出,并首次在此仓库中发布。需要注意的是,DiT的架构与BEiT相同。
声明:发布DiT的团队并未为此模型编写模型卡片,此模型卡片由Hugging Face团队编写。
✨ 主要特性
- 自监督预训练:文档图像变换器(DiT)是一种基于Transformer编码器的模型(类似BERT),以自监督的方式在大量图像上进行预训练。模型的预训练目标是基于掩码补丁,从离散变分自编码器(dVAE)的编码器中预测视觉标记。
- 图像特征学习:图像以固定大小的补丁序列(分辨率为16x16)呈现给模型,这些补丁经过线性嵌入。在将序列输入到Transformer编码器层之前,还会添加绝对位置嵌入。通过预训练,模型学习到图像的内部表示,可用于提取对下游任务有用的特征。
💻 使用示例
基础用法
from transformers import AutoImageProcessor, AutoModelForImageClassification
import torch
from PIL import Image
image = Image.open('path_to_your_document_image').convert('RGB')
processor = AutoImageProcessor.from_pretrained("microsoft/dit-large-finetuned-rvlcdip")
model = AutoModelForImageClassification.from_pretrained("microsoft/dit-large-finetuned-rvlcdip")
inputs = processor(images=image, return_tensors="pt")
outputs = model(**inputs)
logits = outputs.logits
predicted_class_idx = logits.argmax(-1).item()
print("Predicted class:", model.config.id2label[predicted_class_idx])
📚 详细文档
预期用途与限制
你可以使用原始模型将文档图像编码到向量空间,但它主要用于在文档图像分类、表格检测或文档布局分析等任务上进行微调。你可以查看模型中心,寻找针对你感兴趣的任务进行微调的版本。
BibTeX引用信息
@article{Lewis2006BuildingAT,
title={Building a test collection for complex document information processing},
author={David D. Lewis and Gady Agam and Shlomo Engelson Argamon and Ophir Frieder and David A. Grossman and Jefferson Heard},
journal={Proceedings of the 29th annual international ACM SIGIR conference on Research and development in information retrieval},
year={2006}
}
属性 |
详情 |
模型类型 |
文档图像变换器(DiT),基于Transformer编码器架构(类似BERT) |
训练数据 |
预训练数据:IIT - CDIP(包含4200万张文档图像);微调数据:RVL - CDIP(包含40万张灰度图像,分为16个类别,每个类别25000张图像) |