
vision-encoder-decoder (image text to text)
Multimodal915 ops224.3M params
An image-to-text model that pairs a Transformer vision encoder with an autoregressive language model decoder.
Multimodal · 915 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
About this model's family
VisionEncoderDecoderModel is a general image-to-text architecture in the Transformers library: a Transformer-based vision model is the encoder and a language model is the decoder. The vision side can be a model such as ViT, BEiT, DeiT or Swin, and the text side a model such as RoBERTa, GPT2, BERT or DistilBERT.
In image captioning, for example, the encoder encodes the image and an autoregressive language model then generates the caption; optical character recognition is the other application the library names. When the model is assembled from a pretrained encoder and a pretrained decoder, the cross-attention layers might be randomly initialized, depending on the decoder, so it has to be fine-tuned on a downstream task. Training needs only two inputs to compute a loss: the images and the token ids of the target text.
The idea of initializing image-to-text models from pretrained checkpoints was shown to work in the TrOCR paper, and TrOCR is an instance of VisionEncoderDecoderModel. TrOCR is an end-to-end text recognition approach built from pre-trained image Transformer and text Transformer models, which its paper reports outperformed the models it was compared with on printed, handwritten and scene text recognition tasks. In TrOCR the encoder can be initialized with pre-trained ViT-style models and the decoder with pre-trained BERT-style models.
Key idea. VisionEncoderDecoderModel combines any pretrained Transformer-based vision encoder with any pretrained language model decoder to form an image-to-text model, an approach TrOCR showed effective for text recognition.
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
@misc{li2022trocrtransformerbasedopticalcharacter,
title={TrOCR: Transformer-based Optical Character Recognition with Pre-trained Models},
author={Minghao Li and Tengchao Lv and Jingye Chen and Lei Cui and Yijuan Lu and Dinei Florencio and Cha Zhang and Zhoujun Li and Furu Wei},
year={2022},
eprint={2109.10282},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2109.10282},
}