🚀 文档图像变换器(基础大小模型)
文档图像变换器(DiT)是一种用于处理文档图像的模型,它在大规模图像数据上进行自监督预训练,能学习图像的内在表示,可用于提取对下游任务有用的特征,如文档图像分类、表格检测或文档布局分析等。
🚀 快速开始
文档图像变换器(DiT)模型在IIT - CDIP(Lewis等人,2006)上进行了预训练,该数据集包含4200万张文档图像。之后在RVL - CDIP上进行了微调,RVL - CDIP数据集由16个类别的40万张灰度图像组成,每个类别有25000张图像。它由Li等人在论文DiT: Self - supervised Pre - training for Document Image Transformer中提出,并首次在此仓库发布。请注意,DiT的架构与BEiT相同。
声明:发布DiT的团队没有为此模型编写模型卡片,此模型卡片由Hugging Face团队编写。
✨ 主要特性
模型描述
文档图像变换器(DiT)是一种类似BERT的变换器编码器模型,以自监督的方式在大量图像上进行预训练。该模型的预训练目标是基于掩码补丁,从离散变分自编码器(dVAE)的编码器中预测视觉标记。
图像以固定大小的补丁序列(分辨率为16x16)的形式呈现给模型,这些补丁经过线性嵌入。在将序列输入到变换器编码器的各层之前,还会添加绝对位置嵌入。
通过对模型进行预训练,它学习到图像的内在表示,可用于提取对下游任务有用的特征。例如,如果您有一个带标签的文档图像数据集,可以在预训练的编码器之上放置一个线性层,训练一个标准分类器。
预期用途和局限性
您可以使用原始模型将文档图像编码到向量空间,但它主要用于在文档图像分类、表格检测或文档布局分析等任务上进行微调。请查看模型中心,寻找针对您感兴趣的任务进行微调的版本。
💻 使用示例
基础用法
以下是如何在PyTorch中使用此模型的示例:
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-base-finetuned-rvlcdip")
model = AutoModelForImageClassification.from_pretrained("microsoft/dit-base-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}
}
📦 模型信息
📎 示例展示