🚀 文檔圖像變換器(大型模型)
文檔圖像變換器(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張圖像) |