
本模型是 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}
}