
此模型是 Pix2Struct 的预训练版本,仅用于微调。
Pix2Struct 是一个图像编码器 - 文本解码器模型,它在图像 - 文本对上进行训练,适用于多种任务,包括图像 captionning 和视觉问答。可用模型的完整列表可在论文的表 1 中找到:

该模型的摘要如下:
视觉场景语言无处不在——其来源包括带图表的教科书、带图像和表格的网页,以及带按钮和表单的移动应用程序。或许由于这种多样性,以往的研究通常依赖于特定领域的方法,而在基础数据、模型架构和目标方面的共享有限。我们提出了 Pix2Struct,这是一种用于纯视觉语言理解的预训练图像到文本模型,可在包含视觉场景语言的任务上进行微调。Pix2Struct 通过学习将网页的掩码截图解析为简化的 HTML 来进行预训练。网络凭借其丰富的视觉元素(这些元素清晰地反映在 HTML 结构中),提供了大量适合下游任务多样性的预训练数据来源。直观地说,这个目标包含了常见的预训练信号,如 OCR、语言建模、图像 captioning。除了新颖的预训练策略外,我们还引入了可变分辨率输入表示以及语言和视觉输入的更灵活集成,其中语言提示(如问题)直接渲染在输入图像之上。我们首次证明,单个预训练模型能够在四个领域(文档、插图、用户界面和自然图像)的九个任务中,有六个任务取得最先进的结果。
您可以按如下方式使用 convert_pix2struct_checkpoint_to_pytorch.py 脚本:
python convert_pix2struct_checkpoint_to_pytorch.py --t5x_checkpoint_path PATH_TO_T5X_CHECKPOINTS --pytorch_dump_path PATH_TO_SAVE如果您要转换大型模型,请运行:
python convert_pix2struct_checkpoint_to_pytorch.py --t5x_checkpoint_path PATH_TO_T5X_CHECKPOINTS --pytorch_dump_path PATH_TO_SAVE --use-large保存后,您可以使用以下代码片段推送转换后的模型:
from transformers import Pix2StructForConditionalGeneration, Pix2StructProcessor
model = Pix2StructForConditionalGeneration.from_pretrained(PATH_TO_SAVE)
processor = Pix2StructProcessor.from_pretrained(PATH_TO_SAVE)
model.push_to_hub("USERNAME/MODEL_NAME")
processor.push_to_hub("USERNAME/MODEL_NAME")该模型最初由Kenton Lee、Mandar Joshi等人贡献,并由Younes Belkada添加到Hugging Face生态系统中。
如果您想引用本研究成果,请考虑引用原始论文:
@misc{https://doi.org/10.48550/arxiv.2210.03347,
doi = {10.48550/ARXIV.2210.03347},
url = {https://arxiv.org/abs/2210.03347},
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},
keywords = {Computation and Language (cs.CL), Computer Vision and Pattern Recognition (cs.CV), FOS: Computer and information sciences, FOS: Computer and information sciences},
title = {Pix2Struct: Screenshot Parsing as Pretraining for Visual Language Understanding},
publisher = {arXiv},
year = {2022},
copyright = {Creative Commons Attribution 4.0 International}
}