ybelkada commited on
Commit
05444ad
1 Parent(s): 56e149d

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +97 -0
README.md ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - fr
5
+ - ro
6
+ - de
7
+ - multilingual
8
+ pipeline_tag: image-to-text
9
+ tags:
10
+ - image-captioning
11
+ license: apache-2.0
12
+ ---
13
+
14
+
15
+ # Model card for Pix2Struct - Finetuned on OCR-VQA (Visual Question Answering over book covers)
16
+
17
+ ![model_image](https://s3.amazonaws.com/moonup/production/uploads/1678713353867-62441d1d9fdefb55a0b7d12c.png)
18
+
19
+ # Table of Contents
20
+
21
+ 0. [TL;DR](#TL;DR)
22
+ 1. [Using the model](#using-the-model)
23
+ 2. [Contribution](#contribution)
24
+ 3. [Citation](#citation)
25
+
26
+ # TL;DR
27
+
28
+ Pix2Struct 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:
29
+
30
+ ![Table 1 - paper](https://s3.amazonaws.com/moonup/production/uploads/1678712985040-62441d1d9fdefb55a0b7d12c.png)
31
+
32
+
33
+ The abstract of the model states that:
34
+ > Visually-situated language is ubiquitous—sources range from textbooks with diagrams to web pages with images and tables, to mobile apps with buttons and
35
+ forms. Perhaps due to this diversity, previous work has typically relied on domainspecific recipes with limited sharing of the underlying data, model architectures,
36
+ and objectives. We present Pix2Struct, a pretrained image-to-text model for
37
+ purely visual language understanding, which can be finetuned on tasks containing visually-situated language. Pix2Struct is pretrained by learning to parse
38
+ masked screenshots of web pages into simplified HTML. The web, with its richness of visual elements cleanly reflected in the HTML structure, provides a large
39
+ source 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,
40
+ we introduce a variable-resolution input representation and a more flexible integration of language and vision inputs, where language prompts such as questions
41
+ are rendered directly on top of the input image. For the first time, we show that a
42
+ single pretrained model can achieve state-of-the-art results in six out of nine tasks
43
+ across four domains: documents, illustrations, user interfaces, and natural images.
44
+
45
+ # Using the model
46
+
47
+ ## Converting from T5x to huggingface
48
+
49
+ You 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:
50
+ ```bash
51
+ python convert_pix2struct_checkpoint_to_pytorch.py --t5x_checkpoint_path PATH_TO_T5X_CHECKPOINTS --pytorch_dump_path PATH_TO_SAVE
52
+ ```
53
+ if you are converting a large model, run:
54
+ ```bash
55
+ python convert_pix2struct_checkpoint_to_pytorch.py --t5x_checkpoint_path PATH_TO_T5X_CHECKPOINTS --pytorch_dump_path PATH_TO_SAVE --use-large
56
+ ```
57
+ Once saved, you can push your converted model with the following snippet:
58
+ ```python
59
+ from transformers import Pix2StructForConditionalGeneration, Pix2StructProcessor
60
+
61
+ model = Pix2StructForConditionalGeneration.from_pretrained(PATH_TO_SAVE)
62
+ processor = Pix2StructProcessor.from_pretrained(PATH_TO_SAVE)
63
+
64
+ model.push_to_hub("USERNAME/MODEL_NAME")
65
+ processor.push_to_hub("USERNAME/MODEL_NAME")
66
+ ```
67
+
68
+ ## Running the model
69
+
70
+ The instructions for running this model are totally similar to the instructions stated on [`pix2struct-aid-base`](https://huggingface.co/ybelkada/pix2struct-ai2d-base) model.
71
+
72
+ # Contribution
73
+
74
+ This 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).
75
+
76
+ # Citation
77
+
78
+ If you want to cite this work, please consider citing the original paper:
79
+ ```
80
+ @misc{https://doi.org/10.48550/arxiv.2210.03347,
81
+ doi = {10.48550/ARXIV.2210.03347},
82
+
83
+ url = {https://arxiv.org/abs/2210.03347},
84
+
85
+ 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},
86
+
87
+ keywords = {Computation and Language (cs.CL), Computer Vision and Pattern Recognition (cs.CV), FOS: Computer and information sciences, FOS: Computer and information sciences},
88
+
89
+ title = {Pix2Struct: Screenshot Parsing as Pretraining for Visual Language Understanding},
90
+
91
+ publisher = {arXiv},
92
+
93
+ year = {2022},
94
+
95
+ copyright = {Creative Commons Attribution 4.0 International}
96
+ }
97
+ ```