Back to Unilm

DiT: Self-Supervised Pre-Training for Document Image Transformer

dit/README.md

latest9.8 KB
Original Source

DiT: Self-Supervised Pre-Training for Document Image Transformer

DiT (Document Image Transformer) is a self-supervised pre-trained Document Image Transformer model using large-scale unlabeled text images for Document AI tasks, which is essential since no supervised counterparts ever exist due to the lack of human labeled document images.

<div align="center"> Model outputs with PubLayNet (left) and ICDAR 2019 cTDaR (right) </div>

What's New

Pretrained models

We provide two DiT weights pretrained on IIT-CDIP Test Collection 1.0. The models were pretrained with 224x224 resolution.

  • DiT-base: #layer=12; hidden=768; FFN factor=4x; #head=12; patch=16x16 (#parameters: 86M)
  • DiT-large: #layer=24; hidden=1024; FFN factor=4x; #head=16; patch=16x16 (#parameters: 304M)

Download checkpoints that are self-supervised pretrained on IIT-CDIP Test Collection 1.0:

Setup

First, clone the repo and install required packages:

git clone https://github.com/microsoft/unilm.git
cd unilm/dit
pip install -r requirements.txt

The required packages including: Pytorch version 1.9.0, torchvision version 0.10.0 and Timm version 0.5.4, etc.

For mixed-precision training, please install apex

git clone https://github.com/NVIDIA/apex
cd apex
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./

For object detection, please additionally install detectron2 library and shapely. Refer to the Detectron2's INSTALL.md.

bash
# Install `detectron2`
python -m pip install detectron2 -f \
  https://dl.fbaipublicfiles.com/detectron2/wheels/cu111/torch1.9/index.html

# Install `shapely`
pip install shapely

Fine-tuning on RVL-CDIP (Document Image Classification)

We summarize the validation results as follows. We also provide the fine-tuned weights. The detailed instructions to reproduce the results can be found at classification/README.md.

nameinitialized checkpointresolutionaccuracyweight
DiT-basedit_base_patch16_224224x22492.11link
DiT-largedit_large_patch16_224224x22492.69link

Fine-tuning on PubLayNet (Document Layout Analysis)

We summarize the validation results as follows. We also provide the fine-tuned weights. The detailed instructions to reproduce the results can be found at object_detection/README.md.

nameinitialized checkpointdetection algorithmmAPweight
DiT-basedit_base_patch16_224Mask R-CNN0.935link
DiT-largedit_large_patch16_224Mask R-CNN0.941link
DiT-basedit_base_patch16_224Cascade R-CNN0.945link
DiT-largedit_large_patch16_224Cascade R-CNN0.949link

Fine-tuning on ICDAR 2019 cTDaR (Table Detection)

We summarize the validation results as follows. We also provide the fine-tuned weights. The detailed instructions to reproduce the results can be found at object_detection/README.md.

Modern

nameinitialized checkpointdetection algorithmWeighted Average F1weight
DiT-basedit_base_patch16_224Mask R-CNN94.74link
DiT-largedit_large_patch16_224Mask R-CNN95.50link
DiT-basedit_base_patch16_224Cascade R-CNN95.85link
DiT-largedit_large_patch16_224Cascade R-CNN96.29link

Archival

nameinitialized checkpointdetection algorithmWeighted Average F1weight
DiT-basedit_base_patch16_224Mask R-CNN96.24link
DiT-largedit_large_patch16_224Mask R-CNN96.46link
DiT-basedit_base_patch16_224Cascade R-CNN96.63link
DiT-largedit_large_patch16_224Cascade R-CNN97.00link

Combined (Combine the inference results of Modern and Archival)

nameinitialized checkpointdetection algorithmWeighted Average F1weight
DiT-basedit_base_patch16_224Mask R-CNN95.30-
DiT-largedit_large_patch16_224Mask R-CNN95.85-
DiT-basedit_base_patch16_224Cascade R-CNN96.14-
DiT-largedit_large_patch16_224Cascade R-CNN96.55-

Citation

If you find this repository useful, please consider citing our work:

@misc{li2022dit,
    title={DiT: Self-supervised Pre-training for Document Image Transformer},
    author={Junlong Li and Yiheng Xu and Tengchao Lv and Lei Cui and Cha Zhang and Furu Wei},
    year={2022},
    eprint={2203.02378},
    archivePrefix={arXiv},
    primaryClass={cs.CV}
}

Acknowledgement

This repository is built using the timm library, the detectron2 library, the DeiT repository, the Dino repository, the BEiT repository and the MPViT repository.

Contact Information

For help or issues using DiT models, please submit a GitHub issue.

For other communications related to DiT, please contact Lei Cui ([email protected]), Furu Wei ([email protected]).