CoolFace
Modelpublic

google/pix2struct-docvqa-large

sourceHugging Faceapache-2.0updated 3y agoView on Hugging Face
36likes414downloads
README.md96 linesDownload Raw Back to root
1---2language:3  - en4  - fr5  - ro6  - de7  - multilingual8pipeline_tag: visual-question-answering9inference: false10license: apache-2.011---12 13 14# Model card for Pix2Struct - Finetuned on Doc-VQA (Visual Question Answering over scanned documents) - large version15 16![model_image](https://s3.amazonaws.com/moonup/production/uploads/1678713353867-62441d1d9fdefb55a0b7d12c.png)17 18#  Table of Contents19 200. [TL;DR](#TL;DR)211. [Using the model](#using-the-model)222. [Contribution](#contribution)233. [Citation](#citation)24 25# TL;DR26 27Pix2Struct is an image encoder - text decoder model that is trained on image-text pairs for various tasks, including image captionning and visual question answering. The full list of available models can be found on the Table 1 of the paper:28 29![Table 1 - paper](https://s3.amazonaws.com/moonup/production/uploads/1678712985040-62441d1d9fdefb55a0b7d12c.png)30 31 32The abstract of the model states that: 33> Visually-situated language is ubiquitous—sources range from textbooks with diagrams to web pages with images and tables, to mobile apps with buttons and34forms. Perhaps due to this diversity, previous work has typically relied on domainspecific recipes with limited sharing of the underlying data, model architectures,35and objectives. We present Pix2Struct, a pretrained image-to-text model for36purely visual language understanding, which can be finetuned on tasks containing visually-situated language. Pix2Struct is pretrained by learning to parse37masked screenshots of web pages into simplified HTML. The web, with its richness of visual elements cleanly reflected in the HTML structure, provides a large38source of pretraining data well suited to the diversity of downstream tasks. Intuitively, this objective subsumes common pretraining signals such as OCR, language modeling, image captioning. In addition to the novel pretraining strategy,39we introduce a variable-resolution input representation and a more flexible integration of language and vision inputs, where language prompts such as questions40are rendered directly on top of the input image. For the first time, we show that a41single pretrained model can achieve state-of-the-art results in six out of nine tasks42across four domains: documents, illustrations, user interfaces, and natural images.43 44# Using the model 45 46## Converting from T5x to huggingface47 48You can use the [`convert_pix2struct_checkpoint_to_pytorch.py`](https://github.com/huggingface/transformers/blob/main/src/transformers/models/pix2struct/convert_pix2struct_checkpoint_to_pytorch.py) script as follows:49```bash50python convert_pix2struct_checkpoint_to_pytorch.py --t5x_checkpoint_path PATH_TO_T5X_CHECKPOINTS --pytorch_dump_path PATH_TO_SAVE51```52if you are converting a large model, run:53```bash54python convert_pix2struct_checkpoint_to_pytorch.py --t5x_checkpoint_path PATH_TO_T5X_CHECKPOINTS --pytorch_dump_path PATH_TO_SAVE --use-large55```56Once saved, you can push your converted model with the following snippet:57```python58from transformers import Pix2StructForConditionalGeneration, Pix2StructProcessor59 60model = Pix2StructForConditionalGeneration.from_pretrained(PATH_TO_SAVE)61processor = Pix2StructProcessor.from_pretrained(PATH_TO_SAVE)62 63model.push_to_hub("USERNAME/MODEL_NAME")64processor.push_to_hub("USERNAME/MODEL_NAME")65```66 67## Running the model68 69The instructions for running this model are totally similar to the instructions stated on [`pix2struct-aid-base`](https://huggingface.co/ybelkada/pix2struct-ai2d-base) model.70 71# Contribution72 73This model was originally contributed by Kenton Lee, Mandar Joshi et al. and added to the Hugging Face ecosystem by [Younes Belkada](https://huggingface.co/ybelkada).74 75# Citation76 77If you want to cite this work, please consider citing the original paper:78```79@misc{https://doi.org/10.48550/arxiv.2210.03347,80  doi = {10.48550/ARXIV.2210.03347},81  82  url = {https://arxiv.org/abs/2210.03347},83  84  author = {Lee, Kenton and Joshi, Mandar and Turc, Iulia and Hu, Hexiang and Liu, Fangyu and Eisenschlos, Julian and Khandelwal, Urvashi and Shaw, Peter and Chang, Ming-Wei and Toutanova, Kristina},85  86  keywords = {Computation and Language (cs.CL), Computer Vision and Pattern Recognition (cs.CV), FOS: Computer and information sciences, FOS: Computer and information sciences},87  88  title = {Pix2Struct: Screenshot Parsing as Pretraining for Visual Language Understanding},89  90  publisher = {arXiv},91  92  year = {2022},93  94  copyright = {Creative Commons Attribution 4.0 International}95}96```