ybelkada HF staff commited on
Commit
ce7a82c
1 Parent(s): 8bdba8c

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +87 -0
README.md ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 TextCaps
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. [Results](#results)
24
+ 3. [Contribution](#contribution)
25
+ 4. [Citation](#citation)
26
+
27
+ # TL;DR
28
+
29
+ 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:
30
+
31
+ ![Table 1 - paper](https://s3.amazonaws.com/moonup/production/uploads/1678712985040-62441d1d9fdefb55a0b7d12c.png)
32
+
33
+
34
+ The abstract of the model states that:
35
+ > Visually-situated language is ubiquitous—sources range from textbooks with diagrams to web pages with images and tables, to mobile apps with buttons and
36
+ forms. Perhaps due to this diversity, previous work has typically relied on domainspecific recipes with limited sharing of the underlying data, model architectures,
37
+ and objectives. We present Pix2Struct, a pretrained image-to-text model for
38
+ purely visual language understanding, which can be finetuned on tasks containing visually-situated language. Pix2Struct is pretrained by learning to parse
39
+ 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
40
+ 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,
41
+ we introduce a variable-resolution input representation and a more flexible integration of language and vision inputs, where language prompts such as questions
42
+ are rendered directly on top of the input image. For the first time, we show that a
43
+ single pretrained model can achieve state-of-the-art results in six out of nine tasks
44
+ across four domains: documents, illustrations, user interfaces, and natural images.
45
+
46
+ # Using the model
47
+
48
+ ## Converting from T5x to huggingface
49
+
50
+ 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:
51
+ ```bash
52
+ python convert_pix2struct_checkpoint_to_pytorch.py --t5x_checkpoint_path PATH_TO_T5X_CHECKPOINTS --pytorch_dump_path PATH_TO_SAVE
53
+ ```
54
+ if you are converting a large model, run:
55
+ ```bash
56
+ python convert_pix2struct_checkpoint_to_pytorch.py --t5x_checkpoint_path PATH_TO_T5X_CHECKPOINTS --pytorch_dump_path PATH_TO_SAVE --use-large
57
+ ```
58
+ Once saved, you can push your converted model with the following snippet:
59
+ ```python
60
+ from transformers import Pix2StructForConditionalGeneration, Pix2StructProcessor
61
+
62
+ model = Pix2StructForConditionalGeneration.from_pretrained(PATH_TO_SAVE)
63
+ processor = Pix2StructProcessor.from_pretrained(Pix2StructForConditionalGeneration)
64
+
65
+ model.push_to_hub("USERNAME/MODEL_NAME")
66
+ processor.push_to_hub("USERNAME/MODEL_NAME")
67
+ ```
68
+
69
+ ## Running the model
70
+
71
+ TODO
72
+
73
+ # Results
74
+
75
+ TODO
76
+
77
+ # Introduction to UL2
78
+
79
+ TODO
80
+
81
+ # Fine-tuning
82
+
83
+ TODO
84
+
85
+ # Contribution
86
+
87
+ 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).