🚀 文檔圖像變換器(基礎大小模型)
文檔圖像變換器(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}
}
📦 模型信息
📎 示例展示