[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"tool-google-research--pix2struct":3,"similar-google-research--pix2struct":94},{"id":4,"github_repo":5,"name":6,"description_en":7,"description_zh":8,"ai_summary_zh":8,"readme_en":9,"readme_zh":10,"quickstart_zh":11,"use_case_zh":12,"hero_image_url":13,"owner_login":14,"owner_name":15,"owner_avatar_url":16,"owner_bio":17,"owner_company":7,"owner_location":7,"owner_email":7,"owner_twitter":7,"owner_website":18,"owner_url":19,"languages":20,"stars":33,"forks":34,"last_commit_at":35,"license":36,"difficulty_score":37,"env_os":38,"env_gpu":39,"env_ram":40,"env_deps":41,"category_tags":50,"github_topics":7,"view_count":53,"oss_zip_url":7,"oss_zip_packed_at":7,"status":54,"created_at":55,"updated_at":56,"faqs":57,"releases":93},6153,"google-research\u002Fpix2struct","pix2struct",null,"Pix2Struct 是一款由谷歌研究院开源的视觉语言理解模型，其核心理念是将“截图解析”作为预训练任务。简单来说，它能让 AI 像人类一样“看懂”屏幕截图，不仅识别图中的文字，还能理解按钮、图表等界面元素的结构与含义，并将其转化为可执行的代码或结构化描述。\n\n这一工具主要解决了传统模型难以深入理解复杂图形用户界面（GUI）的痛点。以往的系统往往只能进行简单的图像分类或文字提取，而 Pix2Struct 通过独特的预训练策略，实现了从像素到结构的端到端映射，显著提升了在图表问答、界面描述生成及屏幕操作自动化等下游任务中的表现。\n\nPix2Struct 特别适合人工智能研究人员和开发者使用。官方提供了 Base 和 Large 两种规模的预训练模型 checkpoint，并开放了完整的微调代码，支持用户在 TextCaps、ChartQA 等九个专业数据集上进行二次开发。虽然原始预训练数据未直接提供，但项目给出了基于公开 C4 数据集复现数据的完整方案。对于希望探索多模态大模型、构建智能助手或自动化测试工具的技术团队而言，Pix2Struct 提供了一个坚实且灵活的研究基座。","# Pix2Struct\nThis repository contains code for [Pix2Struct: Screenshot Parsing as Pretraining\nfor Visual Language Understanding](https:\u002F\u002Farxiv.org\u002Fabs\u002F2210.03347).\n\nWe release pretrained checkpoints for the Base and Large models and code for\nfinetuning them on the nine downstream tasks discussed in the paper.\nWe are unable to release the pretraining data, but they can be replicated using\nthe publicly available URLs released in the\n[C4 dataset](https:\u002F\u002Fwww.tensorflow.org\u002Fdatasets\u002Fcatalog\u002Fc4).\n\n# Getting Started\nClone the github repository, install the `pix2struct` package, and run\nthe tests to ensure that all dependencies were successfully installed.\n\n```\ngit clone https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Fpix2struct.git\ncd pix2struct\nconda create -n pix2struct python=3.9\nconda activate pix2struct\npip install -e .\"[dev]\" -f https:\u002F\u002Fstorage.googleapis.com\u002Fjax-releases\u002Flibtpu_releases.html\npytest\n```\n\nYou may first need to install Java (`sudo apt install default-jre`) and\n[conda](https:\u002F\u002Fconda.io\u002Fprojects\u002Fconda\u002Fen\u002Flatest\u002Fuser-guide\u002Finstall\u002Findex.html)\nif not already installed.\n\nWe will be using Google Cloud Storage (GCS) for data and model storage. For the\nremaining documentation we will assume that the path to your own bucket and\ndirectory is in the `PIX2STRUCT_DIR` environment variable:\n\n```\nexport PIX2STRUCT_DIR=\"gs:\u002F\u002F\u003Cyour_bucket>\u002F\u003Cpath_to_pix2struct_dir>\"\n```\n\nThe code for running experiments assumes this environment variable when looking\nfor the preprocessed data.\n\n# Data Preprocessing\n\nOur data preprocessing scripts are run with [Dataflow](https:\u002F\u002Fcloud.google.com\u002Fdataflow\u002Fdocs\u002Fquickstarts\u002Fcreate-pipeline-python)\nby default using the [Apache Beam library](https:\u002F\u002Fcloud.google.com\u002Fdataflow\u002Fdocs\u002Fconcepts\u002Fbeam-programming-model).\nThey can also be run locally by turning off flags appearing after `--`.\n\nFor the remaining documentation we will assume that GCP project information is\nin the following environment variables:\n\n```\nexport GCP_PROJECT=\u003Cyour_project_id>\nexport GCP_REGION=\u003Cyour_region>\n```\n\nBelow are the commands required to preprocess each dataset. The results will\nbe written to `$PIX2STRUCT_DIR\u002Fdata\u002F\u003Ctask_name>\u002Fpreprocessed\u002F`, which is the\nfile structure assumed in `tasks.py`.\n\n## TextCaps\n```\nmkdir -p data\u002Ftextcaps\ncd data\u002Ftextcaps\ncurl -O https:\u002F\u002Fdl.fbaipublicfiles.com\u002Ftextvqa\u002Fdata\u002Ftextcaps\u002FTextCaps_0.1_train.json\ncurl -O https:\u002F\u002Fdl.fbaipublicfiles.com\u002Ftextvqa\u002Fdata\u002Ftextcaps\u002FTextCaps_0.1_val.json\ncurl -O https:\u002F\u002Fdl.fbaipublicfiles.com\u002Ftextvqa\u002Fdata\u002Ftextcaps\u002FTextCaps_0.1_test.json\ncurl -O https:\u002F\u002Fdl.fbaipublicfiles.com\u002Ftextvqa\u002Fimages\u002Ftrain_val_images.zip\ncurl -O https:\u002F\u002Fdl.fbaipublicfiles.com\u002Ftextvqa\u002Fimages\u002Ftest_images.zip\nunzip train_val_images.zip\nrm train_val_images.zip\nunzip test_images.zip\nrm test_images.zip\ncd ..\ngsutil -m cp -r textcaps_data $PIX2STRUCT_DIR\u002Fdata\u002Ftextcaps\npython -m pix2struct.preprocessing.convert_textcaps \\\n  --textcaps_dir=$PIX2STRUCT_DIR\u002Fdata\u002Ftextcaps \\\n  --output_dir=$PIX2STRUCT_DIR\u002Fdata\u002Ftextcaps\u002Fprocessed \\\n  -- \\\n  --runner=DataflowRunner \\\n  --save_main_session \\\n  --project=$GCP_PROJECT \\\n  --region=$GCP_REGION \\\n  --temp_location=$PIX2STRUCT_DIR\u002Fdata\u002Ftemp \\\n  --staging_location=$PIX2STRUCT_DIR\u002Fdata\u002Fstaging \\\n  --setup_file=.\u002Fsetup.py\n```\n\n## ChartQA\n```\nmkdir -p data\u002Fchartqa\ncd data\u002Fchartqa\ngit clone https:\u002F\u002Fgithub.com\u002Fvis-nlp\u002FChartQA.git\ncp -r ChartQA\u002FChartQA\\ Dataset\u002F* .\u002F\nrm -rf ChartQA\ncd ..\ngsutil -m cp -r chartqa $PIX2STRUCT_DIR\u002Fdata\u002Fchartqa\npython -m pix2struct.preprocessing.convert_chartqa \\\n  --data_dir=$PIX2STRUCT_DIR\u002Fdata\u002Fchartqa \\\n  -- \\\n  --runner=DataflowRunner \\\n  --save_main_session \\\n  --project=$GCP_PROJECT \\\n  --region=$GCP_REGION \\\n  --temp_location=$PIX2STRUCT_DIR\u002Fdata\u002Ftemp \\\n  --staging_location=$PIX2STRUCT_DIR\u002Fdata\u002Fstaging \\\n  --setup_file=.\u002Fsetup.py\n```\n\n## RICO Images\nScreen2Words, RefExp, and Widget Captioning all require images from the RICO\ndataset. If you'd like to use any of these datasets, please process RICO images\nbefore proceeding.\n\n```\ncd data\nwget https:\u002F\u002Fstorage.googleapis.com\u002Fcrowdstf-rico-uiuc-4540\u002Frico_dataset_v0.1\u002Funique_uis.tar.gz\ntar xvfz unique_uis.tar.gz\nrm unique_uis.tar.gz\ngsutil -m cp -r combined $PIX2STRUCT_DIR\u002Fdata\u002Frico_images\n```\n\n## Widget Captioning\nIf you haven't already setup RICO, please do so before you proceed.\n\n```\nmkdir -p data\u002Fwidget_captioning\ncd data\u002Fwidget_captioning\ngit clone https:\u002F\u002Fgithub.com\u002Fgoogle-research-datasets\u002Fwidget-caption.git\ncp widget-caption\u002Fwidget_captions.csv .\u002F\ncp widget-caption\u002Fsplit\u002F*.txt .\u002F\nmv dev.txt val.txt\nrm -rf widget-caption\ncd ..\ngsutil -m cp -r widget_captioning $PIX2STRUCT_DIR\u002Fdata\u002Fwidget_captioning\npython -m pix2struct.preprocessing.convert_widget_captioning \\\n  --data_dir=$PIX2STRUCT_DIR\u002Fdata\u002Fwidget_captioning \\\n  --image_dir=$PIX2STRUCT_DIR\u002Fdata\u002Frico_images \\\n  -- \\\n  --runner=DataflowRunner \\\n  --save_main_session \\\n  --project=$GCP_PROJECT \\\n  --region=$GCP_REGION \\\n  --temp_location=$PIX2STRUCT_DIR\u002Fdata\u002Ftemp \\\n  --staging_location=$PIX2STRUCT_DIR\u002Fdata\u002Fstaging \\\n  --setup_file=.\u002Fsetup.py\n```\n\n## Screen2Words\nIf you haven't already setup RICO, please do so before you proceed.\n\n```\ncd data\ngit clone https:\u002F\u002Fgithub.com\u002Fgoogle-research-datasets\u002Fscreen2words.git\ngsutil -m cp -r screen2words $PIX2STRUCT_DIR\u002Fdata\u002Fscreen2words\npython -m pix2struct.preprocessing.convert_screen2words \\\n  --screen2words_dir=$PIX2STRUCT_DIR\u002Fdata\u002Fscreen2words \\\n  --rico_dir=$PIX2STRUCT_DIR\u002Fdata\u002Frico_images \\\n  -- \\\n  --runner=DataflowRunner \\\n  --save_main_session \\\n  --project=$GCP_PROJECT \\\n  --region=$GCP_REGION \\\n  --temp_location=$PIX2STRUCT_DIR\u002Fdata\u002Ftemp \\\n  --staging_location=$PIX2STRUCT_DIR\u002Fdata\u002Fstaging \\\n  --setup_file=.\u002Fsetup.py\n```\n\n## RefExp\nIf you haven't already setup RICO, please do so before you proceed.\n\n```\nmkdir -p data\u002Frefexp\ncd data\u002Frefexp\nwget https:\u002F\u002Fgithub.com\u002Fgoogle-research-datasets\u002Fuibert\u002Fraw\u002Fmain\u002Fref_exp\u002Ftrain.tfrecord\nwget https:\u002F\u002Fgithub.com\u002Fgoogle-research-datasets\u002Fuibert\u002Fraw\u002Fmain\u002Fref_exp\u002Fdev.tfrecord\nwget https:\u002F\u002Fgithub.com\u002Fgoogle-research-datasets\u002Fuibert\u002Fraw\u002Fmain\u002Fref_exp\u002Ftest.tfrecord\nmv dev.tfrecord val.tfrecord\ncd ..\ngsutil -m cp -r refexp $PIX2STRUCT_DIR\u002Fdata\u002Frefexp\npython -m pix2struct.preprocessing.convert_refexp \\\n  --data_dir=$PIX2STRUCT_DIR\u002Fdata\u002Frefexp \\\n  --image_dir=$PIX2STRUCT_DIR\u002Fdata\u002Frico_images \\\n  -- \\\n  --runner=DataflowRunner \\\n  --save_main_session \\\n  --project=$GCP_PROJECT \\\n  --region=$GCP_REGION \\\n  --temp_location=$PIX2STRUCT_DIR\u002Fdata\u002Ftemp \\\n  --staging_location=$PIX2STRUCT_DIR\u002Fdata\u002Fstaging \\\n  --setup_file=.\u002Fsetup.py\n```\n\n## DocVQA\n```\nmkdir -p data\u002Fdocvqa\ncd data\u002Fdocvqa\n```\nDownload DocVQA (Single Document Visual Question Answering) from\n[the official source](https:\u002F\u002Frrc.cvc.uab.es\u002F?ch=17&com=downloads) (requires\nregistration). The following steps assume that the train\u002Fval\u002Ftest.tar.gz files\nare in `data\u002Fdocvqa`.\n\n```\ntar xvf train.tar.gz\ntar xvf val.tar.gz\ntar xvf test.tar.gz\nrm -r *.tar.gz *\u002Focr_results\n\ncd ..\ngsutil -m cp -r docvqa $PIX2STRUCT_DIR\u002Fdata\u002Fdocvqa\npython -m pix2struct.preprocessing.convert_docvqa \\\n  --data_dir=$PIX2STRUCT_DIR\u002Fdata\u002Fdocvqa \\\n  -- \\\n  --runner=DataflowRunner \\\n  --save_main_session \\\n  --project=$GCP_PROJECT \\\n  --region=$GCP_REGION \\\n  --temp_location=$PIX2STRUCT_DIR\u002Fdata\u002Ftemp \\\n  --staging_location=$PIX2STRUCT_DIR\u002Fdata\u002Fstaging \\\n  --setup_file=.\u002Fsetup.py\n```\n\n## InfographicVQA\n```\nmkdir -p data\u002Finfographicvqa\ncd data\u002Finfographicvqa\n```\nDownload InfographicVQA Task 1 from [this](https:\u002F\u002Frrc.cvc.uab.es\u002F?ch=17&com=downloads)\nwebsite (requires registration). The following steps assume that the\n`train\u002Fval\u002Ftest.json` and the `zip` files are in `data\u002Finfographicvqa`.\n\n```\nfor split in train val test\ndo\n  unzip infographicVQA_${split}_v1.0_images.zip\n  mv infographicVQA_${split}_v1.0_images $split\n  mv infographicVQA_${split}_v1.0.json $split\u002F${split}_v1.0.json\ndone\nrm *.zip\n\ncd ..\ngsutil -m cp -r infographicvqa $PIX2STRUCT_DIR\u002Fdata\u002Finfographicvqa\npython -m pix2struct.preprocessing.convert_docvqa \\\n  --data_dir=$PIX2STRUCT_DIR\u002Fdata\u002Finfographicvqa \\\n  -- \\\n  --runner=DataflowRunner \\\n  --save_main_session \\\n  --project=$GCP_PROJECT \\\n  --region=$GCP_REGION \\\n  --temp_location=$PIX2STRUCT_DIR\u002Fdata\u002Ftemp \\\n  --staging_location=$PIX2STRUCT_DIR\u002Fdata\u002Fstaging \\\n  --setup_file=.\u002Fsetup.py\n```\n\n## OCR-VQA\n```\nmkdir -p data\u002Focrvqa\ncd data\u002Focrvqa\n```\nFollow instructions on the [OCR-VQA](https:\u002F\u002Focr-vqa.github.io\u002F) website to\ndownload the data into `data\u002Focrvqa` (requires crawling). The following steps\nassume that `data\u002Focrvqa` contains a directory called `images` and a file called\n`dataset.json`.\n\n```\ncd ..\ngsutil -m cp -r ocrvqa $PIX2STRUCT_DIR\u002Fdata\u002Focrvqa\npython -m pix2struct.preprocessing.convert_ocrvqa \\\n  --data_dir=$PIX2STRUCT_DIR\u002Fdata\u002Focrvqa \\\n  -- \\\n  --runner=DataflowRunner \\\n  --save_main_session \\\n  --project=$GCP_PROJECT \\\n  --region=$GCP_REGION \\\n  --temp_location=$PIX2STRUCT_DIR\u002Fdata\u002Ftemp \\\n  --staging_location=$PIX2STRUCT_DIR\u002Fdata\u002Fstaging \\\n  --setup_file=.\u002Fsetup.py\n```\n\n## AI2D\n```\nmkdir -p data\u002F\ncd data\u002F\nwget https:\u002F\u002Fai2-public-datasets.s3.amazonaws.com\u002Fdiagrams\u002Fai2d-all.zip\nunzip ai2d-all.zip\nrm ai2d-all.zip\ngsutil -m cp -r ai2d $PIX2STRUCT_DIR\u002Fdata\u002Fai2d\npython -m pix2struct.preprocessing.convert_ai2d \\\n  --data_dir=$PIX2STRUCT_DIR\u002Fdata\u002Fai2d \\\n  --test_ids_path=gs:\u002F\u002Fpix2struct-data\u002Fai2d_test_ids.csv \\\n  -- \\\n  --runner=DataflowRunner \\\n  --save_main_session \\\n  --project=$GCP_PROJECT \\\n  --region=$GCP_REGION \\\n  --temp_location=$PIX2STRUCT_DIR\u002Fdata\u002Ftemp \\\n  --staging_location=$PIX2STRUCT_DIR\u002Fdata\u002Fstaging \\\n  --setup_file=.\u002Fsetup.py\n```\n\n# Running experiments\n\nThe main experiments are implemented as a light wrapper around the\n[T5X](https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Ft5x) library. For brevity, we\nillustrate an example workflow of finetuning the pretrained base Pix2Struct\nmodel on the Screen2Words dataset. To scale up to larger setups, please see\nto the T5X documentation.\n\n## Setting up the TPU\n\nFollowing official [instructions](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Fjax-quickstart-tpu-vm)\nfor running JAX on a Cloud TPU VM, which allows you to directly `ssh` into the\nTPU host.\n\nIn this example, we are using a `v3-8` TPU:\n\n```\nTPU_TYPE=v3-8\nTPU_NAME=pix2struct-$TPU_TYPE\nTPU_ZONE=europe-west4-a\ngcloud compute tpus tpu-vm create $TPU_NAME \\\n  --zone=$TPU_ZONE \\\n  --accelerator-type=$TPU_TYPE \\\n  --version=tpu-vm-base\ngcloud compute tpus tpu-vm ssh $TPU_NAME --zone=$TPU_ZONE\n```\n\nOnce you have `ssh`ed into the TPU host, follow the \"Getting Started\"\ninstructions to install the `pix2struct` package.\n\n## Training\nThe following command will initiate the training loop, which consists of train\nsteps interleaved with evaluations on the validation set.\n\n```\npython -m t5x.train \\\n  --gin_search_paths=\"pix2struct\u002Fconfigs\" \\\n  --gin_file=\"models\u002Fpix2struct.gin\" \\\n  --gin_file=\"runs\u002Ftrain.gin\" \\\n  --gin_file=\"sizes\u002Fbase.gin\" \\\n  --gin_file=\"optimizers\u002Fadafactor.gin\" \\\n  --gin_file=\"schedules\u002Fscreen2words.gin\" \\\n  --gin_file=\"init\u002Fpix2struct_base_init.gin\" \\\n  --gin.MIXTURE_OR_TASK_NAME=\"'screen2words'\" \\\n  --gin.MODEL_DIR=\"'$PIX2STRUCT_DIR\u002Fexperiments\u002Fscreen2words_base'\" \\\n  --gin.TASK_FEATURE_LENGTHS=\"{'inputs': 4096, 'targets': 128}\" \\\n  --gin.BATCH_SIZE=32\n```\n\n## Evaluation\nThe following command evaluates the model on the test set. You will need to\nreplace the checkpoint path with the one that was actually selected based on the\nvalidation performance.\n\n```\npython -m t5x.eval \\\n  --gin_search_paths=\"pix2struct\u002Fconfigs\" \\\n  --gin_file=\"models\u002Fpix2struct.gin\" \\\n  --gin_file=\"runs\u002Feval.gin\" \\\n  --gin_file=\"sizes\u002Fbase.gin\" \\\n  --gin.MIXTURE_OR_TASK_NAME=\"'screen2words'\" \\\n  --gin.CHECKPOINT_PATH=\"'$PIX2STRUCT_DIR\u002Fexperiments\u002Fscreen2words_base\u002Fcheckpoint_286600'\" \\\n  --gin.EVAL_OUTPUT_DIR=\"'$PIX2STRUCT_DIR\u002Fexperiments\u002Ftest_exp\u002Ftest_eval'\" \\\n  --gin.EVAL_SPLIT=\"'test'\" \\\n  --gin.TASK_FEATURE_LENGTHS=\"{'inputs': 4096, 'targets': 128}\" \\\n  --gin.BATCH_SIZE=32\n```\n\n## Finetuned Checkpoints\nIn addition to the pretrained checkpoints released and specified in the\n`configs\u002Finit` directory. We also release checkpoints for the finetuned models\non all tasks below.\n\n| Task             | GCS Path (Base)                                               | GCS Path (Large)                                               |\n| -----------------| ------------------------------------------------------------- | -------------------------------------------------------------- |\n| TextCaps         | `gs:\u002F\u002Fpix2struct-data\u002Ftextcaps_base\u002Fcheckpoint_280400`          | `gs:\u002F\u002Fpix2struct-data\u002Ftextcaps_large\u002Fcheckpoint_180600`          |\n| ChartQA          | `gs:\u002F\u002Fpix2struct-data\u002Fchartqa_base\u002Fcheckpoint_287600`           | `gs:\u002F\u002Fpix2struct-data\u002Fcharqa_large\u002Fcheckpoint_182600`            |\n| WidgetCaptioning | `gs:\u002F\u002Fpix2struct-data\u002Fwidget_captioning_base\u002Fcheckpoint_281600` | `gs:\u002F\u002Fpix2struct-data\u002Fwidget_captioning_large\u002Fcheckpoint_181600` |\n| Screen2Words     | `gs:\u002F\u002Fpix2struct-data\u002Fscreen2words_base\u002Fcheckpoint_282600`      | `gs:\u002F\u002Fpix2struct-data\u002Fscreen2words_large\u002Fcheckpoint_183000`      |\n| RefExp           | `gs:\u002F\u002Fpix2struct-data\u002Frefexp_base\u002Fcheckpoint_290000`            | `gs:\u002F\u002Fpix2struct-data\u002Frefexp_large\u002Fcheckpoint_187800`            |\n| DocVQA           | `gs:\u002F\u002Fpix2struct-data\u002Fdocvqa_base\u002Fcheckpoint_284400`            | `gs:\u002F\u002Fpix2struct-data\u002Fdocvqa_large\u002Fcheckpoint_184000`            |\n| InfographicVQA   | `gs:\u002F\u002Fpix2struct-data\u002Finfographicvqa_base\u002Fcheckpoint_284000`    | `gs:\u002F\u002Fpix2struct-data\u002Finfographicvqa_large\u002Fcheckpoint_182000`    |\n| OCR-VQA          | `gs:\u002F\u002Fpix2struct-data\u002Focrvqa_base\u002Fcheckpoint_290000`            | `gs:\u002F\u002Fpix2struct-data\u002Focrvqa_large\u002Fcheckpoint_188400`           |\n| AI2D             | `gs:\u002F\u002Fpix2struct-data\u002Fai2d_base\u002Fcheckpoint_284400`              | `gs:\u002F\u002Fpix2struct-data\u002Fai2d_large\u002Fcheckpoint_184000`              |\n\nThese checkpoints are compatible with the eval command documented above and the\ntwo ways of performing inference mentioned below. Please ensure that the config\nfile under `configs\u002Fsizes` is set to be consistent with the checkpoint.\n\n\n## Inference\n\nWe provide two ways of performing inference. For testing and demoing purposes,\nthese may be run on CPU. In that case, please set the `JAX_PLATFORMS`\nenvironment variable to `cpu`.\n\n### Command-line example\n\nWe provide a minimal script for performing inference on a single example. This\npath has only been tested at extremely small scale and is not meant for\nlarger-scale inference. For large-scale inference, we recommend setting a custom\ntask with placeholder labels and running the evaluation script (`t5x.eval`) as\ndocumented above.\n\nIn the following example, we show the command for predicting the caption of an\nimage using a base-sized checkpoint finetuned on the TextCaps task. For a task\nthat also accepts textual prompts such as questions in VQA, you can also supply\nthe question via the `text` flag (in addition to specifying the image with the\n`image` flag).\n\n```\npython -m pix2struct.example_inference \\\n  --gin_search_paths=\"pix2struct\u002Fconfigs\" \\\n  --gin_file=models\u002Fpix2struct.gin \\\n  --gin_file=runs\u002Finference.gin \\\n  --gin_file=sizes\u002Fbase.gin \\\n  --gin.MIXTURE_OR_TASK_NAME=\"'placeholder_pix2struct'\" \\\n  --gin.TASK_FEATURE_LENGTHS=\"{'inputs': 2048, 'targets': 128}\" \\\n  --gin.BATCH_SIZE=1 \\\n  --gin.CHECKPOINT_PATH=\"'gs:\u002F\u002Fpix2struct-data\u002Ftextcaps_base\u002Fcheckpoint_280400'\" \\\n  --image=$HOME\u002Ftest_image.jpg\n```\n\n### Web Demo\n\nFor a more user-friendly demo, we also provide a web-based alternative of\ninference script above. While running this command, the web demo can be accessed\nat `localhost:8080` (or any port specified via the `port` flag), assuming you\nare running the demo locally. You can then upload your custom image and optional\nprompt instead of specifying it via the command line.\n\n```\npython -m pix2struct.demo \\\n  --gin_search_paths=\"pix2struct\u002Fconfigs\" \\\n  --gin_file=models\u002Fpix2struct.gin \\\n  --gin_file=runs\u002Finference.gin \\\n  --gin_file=sizes\u002Fbase.gin \\\n  --gin.MIXTURE_OR_TASK_NAME=\"'placeholder_pix2struct'\" \\\n  --gin.TASK_FEATURE_LENGTHS=\"{'inputs': 2048, 'targets': 128}\" \\\n  --gin.BATCH_SIZE=1 \\\n  --gin.CHECKPOINT_PATH=\"'gs:\u002F\u002Fpix2struct-data\u002Ftextcaps_base\u002Fcheckpoint_280400'\"\n```\n\n## Clean up\nWhen you are done with your TPU VM, remember to delete the instance:\n\n```\ngcloud compute tpus tpu-vm delete $TPU_NAME --zone=$TPU_ZONE\n```\n\n# Note\n\n*This is not an officially supported Google product.*\n","# Pix2Struct\n本仓库包含 [Pix2Struct：将截图解析作为视觉语言理解的预训练](https:\u002F\u002Farxiv.org\u002Fabs\u002F2210.03347) 的代码。\n\n我们发布了 Base 和 Large 模型的预训练检查点，以及在论文中讨论的九个下游任务上对其进行微调的代码。\n我们无法公开预训练数据，但可以使用 [C4 数据集](https:\u002F\u002Fwww.tensorflow.org\u002Fdatasets\u002Fcatalog\u002Fc4) 中发布的公开 URL 来复现这些数据。\n\n# 快速入门\n克隆 GitHub 仓库，安装 `pix2struct` 包，并运行测试以确保所有依赖项已成功安装。\n\n```\ngit clone https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Fpix2struct.git\ncd pix2struct\nconda create -n pix2struct python=3.9\nconda activate pix2struct\npip install -e .\"[dev]\" -f https:\u002F\u002Fstorage.googleapis.com\u002Fjax-releases\u002Flibtpu_releases.html\npytest\n```\n\n如果尚未安装，您可能需要先安装 Java (`sudo apt install default-jre`) 和 [conda](https:\u002F\u002Fconda.io\u002Fprojects\u002Fconda\u002Fen\u002Flatest\u002Fuser-guide\u002Finstall\u002Findex.html)。\n\n我们将使用 Google Cloud Storage (GCS) 来存储数据和模型。在后续文档中，我们假设您自己的存储桶和目录路径位于 `PIX2STRUCT_DIR` 环境变量中：\n\n```\nexport PIX2STRUCT_DIR=\"gs:\u002F\u002F\u003Cyour_bucket>\u002F\u003Cpath_to_pix2struct_dir>\"\n```\n\n运行实验的代码在查找预处理后的数据时会假定该环境变量的存在。\n\n# 数据预处理\n\n我们的数据预处理脚本默认使用 [Dataflow](https:\u002F\u002Fcloud.google.com\u002Fdataflow\u002Fdocs\u002Fquickstarts\u002Fcreate-pipeline-python)，基于 [Apache Beam 库](https:\u002F\u002Fcloud.google.com\u002Fdataflow\u002Fdocs\u002Fconcepts\u002Fbeam-programming-model) 运行。它们也可以通过关闭 `--` 后面的标志来在本地运行。\n\n在后续文档中，我们假设 GCP 项目信息位于以下环境变量中：\n\n```\nexport GCP_PROJECT=\u003Cyour_project_id>\nexport GCP_REGION=\u003Cyour_region>\n```\n\n以下是预处理每个数据集所需的命令。结果将被写入 `$PIX2STRUCT_DIR\u002Fdata\u002F\u003Ctask_name>\u002Fpreprocessed\u002F`，这是 `tasks.py` 中假定的文件结构。\n\n## TextCaps\n```\nmkdir -p data\u002Ftextcaps\ncd data\u002Ftextcaps\ncurl -O https:\u002F\u002Fdl.fbaipublicfiles.com\u002Ftextvqa\u002Fdata\u002Ftextcaps\u002FTextCaps_0.1_train.json\ncurl -O https:\u002F\u002Fdl.fbaipublicfiles.com\u002Ftextvqa\u002Fdata\u002Ftextcaps\u002FTextCaps_0.1_val.json\ncurl -O https:\u002F\u002Fdl.fbaipublicfiles.com\u002Ftextvqa\u002Fdata\u002Ftextcaps\u002FTextCaps_0.1_test.json\ncurl -O https:\u002F\u002Fdl.fbaipublicfiles.com\u002Ftextvqa\u002Fimages\u002Ftrain_val_images.zip\ncurl -O https:\u002F\u002Fdl.fbaipublicfiles.com\u002Ftextvqa\u002Fimages\u002Ftest_images.zip\nunzip train_val_images.zip\nrm train_val_images.zip\nunzip test_images.zip\nrm test_images.zip\ncd ..\ngsutil -m cp -r textcaps_data $PIX2STRUCT_DIR\u002Fdata\u002Ftextcaps\npython -m pix2struct.preprocessing.convert_textcaps \\\n  --textcaps_dir=$PIX2STRUCT_DIR\u002Fdata\u002Ftextcaps \\\n  --output_dir=$PIX2STRUCT_DIR\u002Fdata\u002Ftextcaps\u002Fprocessed \\\n  -- \\\n  --runner=DataflowRunner \\\n  --save_main_session \\\n  --project=$GCP_PROJECT \\\n  --region=$GCP_REGION \\\n  --temp_location=$PIX2STRUCT_DIR\u002Fdata\u002Ftemp \\\n  --staging_location=$PIX2STRUCT_DIR\u002Fdata\u002Fstaging \\\n  --setup_file=.\u002Fsetup.py\n```\n\n## ChartQA\n```\nmkdir -p data\u002Fchartqa\ncd data\u002Fchartqa\ngit clone https:\u002F\u002Fgithub.com\u002Fvis-nlp\u002FChartQA.git\ncp -r ChartQA\u002FChartQA\\ Dataset\u002F* .\u002F\nrm -rf ChartQA\ncd ..\ngsutil -m cp -r chartqa $PIX2STRUCT_DIR\u002Fdata\u002Fchartqa\npython -m pix2struct.preprocessing.convert_chartqa \\\n  --data_dir=$PIX2STRUCT_DIR\u002Fdata\u002Fchartqa \\\n  -- \\\n  --runner=DataflowRunner \\\n  --save_main_session \\\n  --project=$GCP_PROJECT \\\n  --region=$GCP_REGION \\\n  --temp_location=$PIX2STRUCT_DIR\u002Fdata\u002Ftemp \\\n  --staging_location=$PIX2STRUCT_DIR\u002Fdata\u002Fstaging \\\n  --setup_file=.\u002Fsetup.py\n```\n\n## RICO 图像\nScreen2Words、RefExp 和 Widget Captioning 都需要来自 RICO 数据集的图像。如果您想使用其中任何一个数据集，请在继续之前先处理 RICO 图像。\n\n```\ncd data\nwget https:\u002F\u002Fstorage.googleapis.com\u002Fcrowdstf-rico-uiuc-4540\u002Frico_dataset_v0.1\u002Funique_uis.tar.gz\ntar xvfz unique_uis.tar.gz\nrm unique_uis.tar.gz\ngsutil -m cp -r combined $PIX2STRUCT_DIR\u002Fdata\u002Frico_images\n```\n\n## Widget Captioning\n如果您尚未设置 RICO，请在继续之前完成此步骤。\n\n```\nmkdir -p data\u002Fwidget_captioning\ncd data\u002Fwidget_captioning\ngit clone https:\u002F\u002Fgithub.com\u002Fgoogle-research-datasets\u002Fwidget-caption.git\ncp widget-caption\u002Fwidget_captions.csv .\u002F\ncp widget-caption\u002Fsplit\u002F*.txt .\u002F\nmv dev.txt val.txt\nrm -rf widget-caption\ncd ..\ngsutil -m cp -r widget_captioning $PIX2STRUCT_DIR\u002Fdata\u002Fwidget_captioning\npython -m pix2struct.preprocessing.convert_widget_captioning \\\n  --data_dir=$PIX2STRUCT_DIR\u002Fdata\u002Fwidget_captioning \\\n  --image_dir=$PIX2STRUCT_DIR\u002Fdata\u002Frico_images \\\n  -- \\\n  --runner=DataflowRunner \\\n  --save_main_session \\\n  --project=$GCP_PROJECT \\\n  --region=$GCP_REGION \\\n  --temp_location=$PIX2STRUCT_DIR\u002Fdata\u002Ftemp \\\n  --staging_location=$PIX2STRUCT_DIR\u002Fdata\u002Fstaging \\\n  --setup_file=.\u002Fsetup.py\n```\n\n## Screen2Words\n如果您尚未设置 RICO，请在继续之前完成此步骤。\n\n```\ncd data\ngit clone https:\u002F\u002Fgithub.com\u002Fgoogle-research-datasets\u002Fscreen2words.git\ngsutil -m cp -r screen2words $PIX2STRUCT_DIR\u002Fdata\u002Fscreen2words\npython -m pix2struct.preprocessing.convert_screen2words \\\n  --screen2words_dir=$PIX2STRUCT_DIR\u002Fdata\u002Fscreen2words \\\n  --rico_dir=$PIX2STRUCT_DIR\u002Fdata\u002Frico_images \\\n  -- \\\n  --runner=DataflowRunner \\\n  --save_main_session \\\n  --project=$GCP_PROJECT \\\n  --region=$GCP_REGION \\\n  --temp_location=$PIX2STRUCT_DIR\u002Fdata\u002Ftemp \\\n  --staging_location=$PIX2STRUCT_DIR\u002Fdata\u002Fstaging \\\n  --setup_file=.\u002Fsetup.py\n```\n\n## RefExp\n如果您尚未设置 RICO，请在继续之前完成此步骤。\n\n```\nmkdir -p data\u002Frefexp\ncd data\u002Frefexp\nwget https:\u002F\u002Fgithub.com\u002Fgoogle-research-datasets\u002Fuibert\u002Fraw\u002Fmain\u002Fref_exp\u002Ftrain.tfrecord\nwget https:\u002F\u002Fgithub.com\u002Fgoogle-research-datasets\u002Fuibert\u002Fraw\u002Fmain\u002Fref_exp\u002Fdev.tfrecord\nwget https:\u002F\u002Fgithub.com\u002Fgoogle-research-datasets\u002Fuibert\u002Fraw\u002Fmain\u002Fref_exp\u002Ftest.tfrecord\nmv dev.tfrecord val.tfrecord\ncd ..\ngsutil -m cp -r refexp $PIX2STRUCT_DIR\u002Fdata\u002Frefexp\npython -m pix2struct.preprocessing.convert_refexp \\\n  --data_dir=$PIX2STRUCT_DIR\u002Fdata\u002Frefexp \\\n  --image_dir=$PIX2STRUCT_DIR\u002Fdata\u002Frico_images \\\n  -- \\\n  --runner=DataflowRunner \\\n  --save main session \\\n  --project=$GCP_PROJECT \\\n  --region=$GCP_REGION \\\n  --temp_location=$PIX2STRUCT_DIR\u002Fdata\u002Ftemp \\\n  --staging_location=$PIX2STRUCT_DIR\u002Fdata\u002Fstaging \\\n  --setup_file=.\u002Fsetup.py\n```\n\n## DocVQA\n```\nmkdir -p data\u002Fdocvqa\ncd data\u002Fdocvqa\n```\n从[官方来源](https:\u002F\u002Frrc.cvc.uab.es\u002F?ch=17&com=downloads)下载 DocVQA（单文档视觉问答）数据集（需注册）。以下步骤假设 `train\u002Fval\u002Ftest.tar.gz` 文件位于 `data\u002Fdocvqa` 目录中。\n\n```\ntar xvf train.tar.gz\ntar xvf val.tar.gz\ntar xvf test.tar.gz\nrm -r *.tar.gz *\u002Focr_results\n\ncd ..\ngsutil -m cp -r docvqa $PIX2STRUCT_DIR\u002Fdata\u002Fdocvqa\npython -m pix2struct.preprocessing.convert_docvqa \\\n  --data_dir=$PIX2STRUCT_DIR\u002Fdata\u002Fdocvqa \\\n  -- \\\n  --runner=DataflowRunner \\\n  --save_main_session \\\n  --project=$GCP_PROJECT \\\n  --region=$GCP_REGION \\\n  --temp_location=$PIX2STRUCT_DIR\u002Fdata\u002Ftemp \\\n  --staging_location=$PIX2STRUCT_DIR\u002Fdata\u002Fstaging \\\n  --setup_file=.\u002Fsetup.py\n```\n\n## InfographicVQA\n```\nmkdir -p data\u002Finfographicvqa\ncd data\u002Finfographicvqa\n```\n从[此](https:\u002F\u002Frrc.cvc.uab.es\u002F?ch=17&com=downloads)网站下载 InfographicVQA 任务 1 数据集（需注册）。以下步骤假设 `train\u002Fval\u002Ftest.json` 和 `zip` 文件位于 `data\u002Finfographicvqa` 目录中。\n\n```\nfor split in train val test\ndo\n  unzip infographicVQA_${split}_v1.0_images.zip\n  mv infographicVQA_${split}_v1.0_images $split\n  mv infographicVQA_${split}_v1.0.json $split\u002F${split}_v1.0.json\ndone\nrm *.zip\n\ncd ..\ngsutil -m cp -r infographicvqa $PIX2STRUCT_DIR\u002Fdata\u002Finfographicvqa\npython -m pix2struct.preprocessing.convert_docvqa \\\n  --data_dir=$PIX2STRUCT_DIR\u002Fdata\u002Finfographicvqa \\\n  -- \\\n  --runner=DataflowRunner \\\n  --save_main_session \\\n  --project=$GCP_PROJECT \\\n  --region=$GCP_REGION \\\n  --temp_location=$PIX2STRUCT_DIR\u002Fdata\u002Ftemp \\\n  --staging_location=$PIX2STRUCT_DIR\u002Fdata\u002Fstaging \\\n  --setup_file=.\u002Fsetup.py\n```\n\n## OCR-VQA\n```\nmkdir -p data\u002Focrvqa\ncd data\u002Focrvqa\n```\n按照[OCR-VQA](https:\u002F\u002Focr-vqa.github.io\u002F)网站上的说明，将数据下载到 `data\u002Focrvqa` 目录中（需爬取数据）。以下步骤假设 `data\u002Focrvqa` 包含一个名为 `images` 的目录和一个名为 `dataset.json` 的文件。\n\n```\ncd ..\ngsutil -m cp -r ocrvqa $PIX2STRUCT_DIR\u002Fdata\u002Focrvqa\npython -m pix2struct.preprocessing.convert_ocrvqa \\\n  --data_dir=$PIX2STRUCT_DIR\u002Fdata\u002Focrvqa \\\n  -- \\\n  --runner=DataflowRunner \\\n  --save_main_session \\\n  --project=$GCP_PROJECT \\\n  --region=$GCP_REGION \\\n  --temp_location=$PIX2STRUCT_DIR\u002Fdata\u002Ftemp \\\n  --staging_location=$PIX2STRUCT_DIR\u002Fdata\u002Fstaging \\\n  --setup_file=.\u002Fsetup.py\n```\n\n## AI2D\n```\nmkdir -p data\u002F\ncd data\u002F\nwget https:\u002F\u002Fai2-public-datasets.s3.amazonaws.com\u002Fdiagrams\u002Fai2d-all.zip\nunzip ai2d-all.zip\nrm ai2d-all.zip\ngsutil -m cp -r ai2d $PIX2STRUCT_DIR\u002Fdata\u002Fai2d\npython -m pix2struct.preprocessing.convert_ai2d \\\n  --data_dir=$PIX2STRUCT_DIR\u002Fdata\u002Fai2d \\\n  --test_ids_path=gs:\u002F\u002Fpix2struct-data\u002Fai2d_test_ids.csv \\\n  -- \\\n  --runner=DataflowRunner \\\n  --save_main_session \\\n  --project=$GCP_PROJECT \\\n  --region=$GCP_REGION \\\n  --temp_location=$PIX2STRUCT_DIR\u002Fdata\u002Ftemp \\\n  --staging_location=$PIX2STRUCT_DIR\u002Fdata\u002Fstaging \\\n  --setup_file=.\u002Fsetup.py\n```\n\n# 运行实验\n\n主要实验是基于[T5X](https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Ft5x)库的一个轻量级封装实现的。为简洁起见，我们以在 Screen2Words 数据集上微调预训练的 Pix2Struct 基础模型为例，展示一个工作流程。若要扩展到更大规模的设置，请参阅 T5X 文档。\n\n## 设置 TPU\n\n按照官方[说明](https:\u002F\u002Fcloud.google.com\u002Ftpu\u002Fdocs\u002Fjax-quickstart-tpu-vm)，在 Cloud TPU 虚拟机上运行 JAX，这样可以直接通过 `ssh` 登录到 TPU 主机。\n\n在本示例中，我们使用 `v3-8` TPU：\n\n```\nTPU_TYPE=v3-8\nTPU_NAME=pix2struct-$TPU_TYPE\nTPU_ZONE=europe-west4-a\ngcloud compute tpus tpu-vm create $TPU_NAME \\\n  --zone=$TPU_ZONE \\\n  --accelerator-type=$TPU_TYPE \\\n  --version=tpu-vm-base\ngcloud compute tpus tpu-vm ssh $TPU_NAME --zone=$TPU_ZONE\n```\n\n成功 `ssh` 到 TPU 主机后，按照“入门”说明安装 `pix2struct` 包。\n\n## 训练\n以下命令将启动训练循环，该循环由训练步骤与验证集上的评估交替进行组成。\n\n```\npython -m t5x.train \\\n  --gin_search_paths=\"pix2struct\u002Fconfigs\" \\\n  --gin_file=\"models\u002Fpix2struct.gin\" \\\n  --gin_file=\"runs\u002Ftrain.gin\" \\\n  --gin_file=\"sizes\u002Fbase.gin\" \\\n  --gin_file=\"optimizers\u002Fadafactor.gin\" \\\n  --gin_file=\"schedules\u002Fscreen2words.gin\" \\\n  --gin_file=\"init\u002Fpix2struct_base_init.gin\" \\\n  --gin.MIXTURE_OR_TASK_NAME=\"'screen2words'\" \\\n  --gin.MODEL_DIR=\"'$PIX2STRUCT_DIR\u002Fexperiments\u002Fscreen2words_base'\" \\\n  --gin.TASK_FEATURE_LENGTHS=\"{'inputs': 4096, 'targets': 128}\" \\\n  --gin.BATCH_SIZE=32\n```\n\n## 评估\n以下命令将在测试集上评估模型。您需要将检查点路径替换为根据验证性能实际选择的那个。\n\n```\npython -m t5x.eval \\\n  --gin_search_paths=\"pix2struct\u002Fconfigs\" \\\n  --gin_file=\"models\u002Fpix2struct.gin\" \\\n  --gin_file=\"runs\u002Feval.gin\" \\\n  --gin_file=\"sizes\u002Fbase.gin\" \\\n  --gin.MIXTURE_OR_TASK_NAME=\"'screen2words'\" \\\n  --gin.CHECKPOINT_PATH=\"'$PIX2STRUCT_DIR\u002Fexperiments\u002Fscreen2words_base\u002Fcheckpoint_286600'\" \\\n  --gin.EVAL_OUTPUT_DIR=\"'$PIX2STRUCT_DIR\u002Fexperiments\u002Ftest_exp\u002Ftest_eval'\" \\\n  --gin.EVAL_SPLIT=\"'test'\" \\\n  --gin.TASK_FEATURE_LENGTHS=\"{'inputs': 4096, 'targets': 128}\" \\\n  --gin.BATCH_SIZE=32\n```\n\n## 微调后的检查点\n除了在 `configs\u002Finit` 目录中发布并指定的预训练检查点外，我们还发布了以下所有任务上微调模型的检查点。\n\n| 任务             | GCS 路径（Base）                                               | GCS 路径（Large）                                               |\n| -----------------| ------------------------------------------------------------- | -------------------------------------------------------------- |\n| TextCaps         | `gs:\u002F\u002Fpix2struct-data\u002Ftextcaps_base\u002Fcheckpoint_280400`          | `gs:\u002F\u002Fpix2struct-data\u002Ftextcaps_large\u002Fcheckpoint_180600`          |\n| ChartQA          | `gs:\u002F\u002Fpix2struct-data\u002Fchartqa_base\u002Fcheckpoint_287600`           | `gs:\u002F\u002Fpix2struct-data\u002Fcharqa_large\u002Fcheckpoint_182600`            |\n| WidgetCaptioning | `gs:\u002F\u002Fpix2struct-data\u002Fwidget_captioning_base\u002Fcheckpoint_281600` | `gs:\u002F\u002Fpix2struct-data\u002Fwidget_captioning_large\u002Fcheckpoint_181600` |\n| Screen2Words     | `gs:\u002F\u002Fpix2struct-data\u002Fscreen2words_base\u002Fcheckpoint_282600`      | `gs:\u002F\u002Fpix2struct-data\u002Fscreen2words_large\u002Fcheckpoint_183000`      |\n| RefExp           | `gs:\u002F\u002Fpix2struct-data\u002Frefexp_base\u002Fcheckpoint_290000`            | `gs:\u002F\u002Fpix2struct-data\u002Frefexp_large\u002Fcheckpoint_187800`            |\n| DocVQA           | `gs:\u002F\u002Fpix2struct-data\u002Fdocvqa_base\u002Fcheckpoint_284400`            | `gs:\u002F\u002Fpix2struct-data\u002Fdocvqa_large\u002Fcheckpoint_184000`            |\n| InfographicVQA   | `gs:\u002F\u002Fpix2struct-data\u002Finfographicvqa_base\u002Fcheckpoint_284000`    | `gs:\u002F\u002Fpix2struct-data\u002Finfographicvqa_large\u002Fcheckpoint_182000`    |\n| OCR-VQA          | `gs:\u002F\u002Fpix2struct-data\u002Focrvqa_base\u002Fcheckpoint_290000`            | `gs:\u002F\u002Fpix2struct-data\u002Focrvqa_large\u002Fcheckpoint_188400`           |\n| AI2D             | `gs:\u002F\u002Fpix2struct-data\u002Fai2d_base\u002Fcheckpoint_284400`              | `gs:\u002F\u002Fpix2struct-data\u002Fai2d_large\u002Fcheckpoint_184000`              |\n\n这些检查点与上述文档中记录的评估命令以及下面提到的两种推理方式兼容。请确保 `configs\u002Fsizes` 下的配置文件与检查点保持一致。\n\n\n## 推理\n我们提供了两种推理方式。出于测试和演示目的，这些可以在 CPU 上运行。在这种情况下，请将 `JAX_PLATFORMS` 环境变量设置为 `cpu`。\n\n### 命令行示例\n我们提供了一个用于对单个样本进行推理的最小化脚本。该路径仅在极小规模下进行了测试，并不适合大规模推理。对于大规模推理，我们建议设置一个带有占位符标签的自定义任务，并按照上述文档运行评估脚本 (`t5x.eval`)。\n\n在下面的示例中，我们展示了使用在 TextCaps 任务上微调的 Base 尺寸检查点预测图像标题的命令。对于也接受文本提示的任务（如 VQA 中的问题），您还可以通过 `text` 标志提供问题（除了用 `image` 标志指定图像之外）。\n\n```\npython -m pix2struct.example_inference \\\n  --gin_search_paths=\"pix2struct\u002Fconfigs\" \\\n  --gin_file=models\u002Fpix2struct.gin \\\n  --gin_file=runs\u002Finference.gin \\\n  --gin_file=sizes\u002Fbase.gin \\\n  --gin.MIXTURE_OR_TASK_NAME=\"'placeholder_pix2struct'\" \\\n  --gin.TASK_FEATURE_LENGTHS=\"{'inputs': 2048, 'targets': 128}\" \\\n  --gin.BATCH_SIZE=1 \\\n  --gin.CHECKPOINT_PATH=\"'gs:\u002F\u002Fpix2struct-data\u002Ftextcaps_base\u002Fcheckpoint_280400'\" \\\n  --image=$HOME\u002Ftest_image.jpg\n```\n\n### Web 演示\n为了提供更友好的演示体验，我们还提供了上述推理脚本的基于 Web 的替代方案。运行此命令时，Web 演示可在 `localhost:8080`（或通过 `port` 标志指定的任何端口）访问，前提是您在本地运行演示。然后您可以上传自定义图像和可选提示，而不是通过命令行指定它们。\n\n```\npython -m pix2struct.demo \\\n  --gin_search_paths=\"pix2struct\u002Fconfigs\" \\\n  --gin_file=models\u002Fpix2struct.gin \\\n  --gin_file=runs\u002Finference.gin \\\n  --gin_file=sizes\u002Fbase.gin \\\n  --gin.MIXTURE_OR_TASK_NAME=\"'placeholder_pix2struct'\" \\\n  --gin.TASK_FEATURE_LENGTHS=\"{'inputs': 2048, 'targets': 128}\" \\\n  --gin.BATCH_SIZE=1 \\\n  --gin.CHECKPOINT_PATH=\"'gs:\u002F\u002Fpix2struct-data\u002Ftextcaps_base\u002Fcheckpoint_280400'\"\n```\n\n## 清理\n当您完成 TPU VM 的使用后，请记得删除实例：\n\n```\ngcloud compute tpus tpu-vm delete $TPU_NAME --zone=$TPU_ZONE\n```\n\n# 注意\n*这不是 Google 官方支持的产品。*","# Pix2Struct 快速上手指南\n\nPix2Struct 是一个将截图解析作为预训练任务的视觉语言理解模型。本指南帮助中国开发者快速完成环境搭建、数据预处理及模型微调。\n\n## 1. 环境准备\n\n在开始之前，请确保您的开发环境满足以下要求：\n\n*   **操作系统**: Linux (推荐 Ubuntu)\n*   **Python**: 3.9\n*   **依赖工具**:\n    *   [Conda](https:\u002F\u002Fconda.io\u002F) (用于环境管理)\n    *   Java JDK\u002FJRE (`sudo apt install default-jre`)\n    *   Git\n*   **云资源 (可选但推荐)**:\n    *   **Google Cloud Platform (GCP)**: 官方脚本默认使用 GCS 存储数据和模型，并使用 Dataflow 进行大规模数据预处理。\n    *   **TPU**: 训练和评估推荐使用 Cloud TPU VM。\n    *   *注：若仅进行本地小规模测试或推理，可跳过部分云配置，但数据预处理脚本默认依赖 Dataflow 参数。*\n\n## 2. 安装步骤\n\n### 2.1 克隆代码与创建环境\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Fpix2struct.git\ncd pix2struct\n\n# 创建并激活 Conda 环境\nconda create -n pix2struct python=3.9\nconda activate pix2struct\n\n# 安装 pix2struct 包及其开发依赖\n# 注意：需指定 JAX TPU 释放源\npip install -e .\"[dev]\" -f https:\u002F\u002Fstorage.googleapis.com\u002Fjax-releases\u002Flibtpu_releases.html\n\n# 运行测试以验证安装\npytest\n```\n\n### 2.2 配置环境变量\n\n项目依赖 Google Cloud Storage (GCS) 存储数据。请设置以下环境变量（替换为您自己的 Bucket 路径）：\n\n```bash\nexport PIX2STRUCT_DIR=\"gs:\u002F\u002F\u003Cyour_bucket>\u002F\u003Cpath_to_pix2struct_dir>\"\nexport GCP_PROJECT=\u003Cyour_project_id>\nexport GCP_REGION=\u003Cyour_region>\n```\n\n## 3. 基本使用\n\nPix2Struct 的核心工作流包括：**数据预处理** -> **模型微调 (Training)** -> **评估 (Evaluation)**。以下以 **Screen2Words** 任务为例展示最简流程。\n\n### 3.1 数据预处理\n\n大多数下游任务需要先将原始数据转换为模型可读格式。官方脚本默认使用 Apache Beam (Dataflow) 运行。\n\n**示例：准备 Screen2Words 数据**\n\n*前提：需先下载并处理 RICO 图像数据集（见原文 README \"RICO Images\" 章节）。*\n\n```bash\n# 1. 下载 Screen2Words 源码数据\nmkdir -p data\ncd data\ngit clone https:\u002F\u002Fgithub.com\u002Fgoogle-research-datasets\u002Fscreen2words.git\ngsutil -m cp -r screen2words $PIX2STRUCT_DIR\u002Fdata\u002Fscreen2words\n\n# 2. 运行预处理脚本\n# 注意：-- 之后的参数传递给 Dataflow Runner\npython -m pix2struct.preprocessing.convert_screen2words \\\n  --screen2words_dir=$PIX2STRUCT_DIR\u002Fdata\u002Fscreen2words \\\n  --rico_dir=$PIX2STRUCT_DIR\u002Fdata\u002Frico_images \\\n  -- \\\n  --runner=DataflowRunner \\\n  --save_main_session \\\n  --project=$GCP_PROJECT \\\n  --region=$GCP_REGION \\\n  --temp_location=$PIX2STRUCT_DIR\u002Fdata\u002Ftemp \\\n  --staging_location=$PIX2STRUCT_DIR\u002Fdata\u002Fstaging \\\n  --setup_file=.\u002Fsetup.py\n```\n\n*其他数据集（如 TextCaps, ChartQA, DocVQA 等）的预处理命令请参考原文 \"Data Preprocessing\" 章节对应部分。*\n\n### 3.2 模型微调 (Training)\n\nPix2Struct 基于 [T5X](https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Ft5x) 库构建。以下示例展示如何在 TPU 上微调 Base 模型。\n\n**第一步：设置 TPU 环境 (如果在本地 GPU\u002FCPU 运行可跳过此步，需调整 gin 配置)**\n\n```bash\nTPU_TYPE=v3-8\nTPU_NAME=pix2struct-$TPU_TYPE\nTPU_ZONE=europe-west4-a\n\n# 创建 TPU VM\ngcloud compute tpus tpu-vm create $TPU_NAME \\\n  --zone=$TPU_ZONE \\\n  --accelerator-type=$TPU_TYPE \\\n  --version=tpu-vm-base\n\n# 连接到 TPU 并在其中重复“安装步骤”\ngcloud compute tpus tpu-vm ssh $TPU_NAME --zone=$TPU_ZONE\n```\n\n**第二步：启动训练**\n\n```bash\npython -m t5x.train \\\n  --gin_search_paths=\"pix2struct\u002Fconfigs\" \\\n  --gin_file=\"models\u002Fpix2struct.gin\" \\\n  --gin_file=\"runs\u002Ftrain.gin\" \\\n  --gin_file=\"sizes\u002Fbase.gin\" \\\n  --gin_file=\"optimizers\u002Fadafactor.gin\" \\\n  --gin_file=\"schedules\u002Fscreen2words.gin\" \\\n  --gin_file=\"init\u002Fpix2struct_base_init.gin\" \\\n  --gin.MIXTURE_OR_TASK_NAME=\"'screen2words'\" \\\n  --gin.MODEL_DIR=\"'$PIX2STRUCT_DIR\u002Fexperiments\u002Fscreen2words_base'\" \\\n  --gin.TASK_FEATURE_LENGTHS=\"{'inputs': 4096, 'targets': 128}\" \\\n  --gin.BATCH_SIZE=32\n```\n\n### 3.3 模型评估 (Evaluation)\n\n训练完成后，使用以下命令在测试集上评估模型性能。请将 `CHECKPOINT_PATH` 替换为实际训练中表现最佳的检查点路径。\n\n```bash\npython -m t5x.eval \\\n  --gin_search_paths=\"pix2struct\u002Fconfigs\" \\\n  --gin_file=\"models\u002Fpix2struct.gin\" \\\n  --gin_file=\"runs\u002Feval.gin\" \\\n  --gin_file=\"sizes\u002Fbase.gin\" \\\n  --gin.MIXTURE_OR_TASK_NAME=\"'screen2words'\" \\\n  --gin.CHECKPOINT_PATH=\"'$PIX2STRUCT_DIR\u002Fexperiments\u002Fscreen2words_base\u002Fcheckpoint_286600'\" \\\n  --gin.EVAL_OUTPUT_DIR=\"'$PIX2STRUCT_DIR\u002Fexperiments\u002Ftest_exp\u002Ftest_eval'\" \\\n  --gin.EVAL_SPLIT=\"'test'\" \\\n  --gin.TASK_FEATURE_LENGTHS=\"{'inputs': 4096, 'targets': 128}\" \\\n  --gin.BATCH_SIZE=32\n```\n\n---\n*提示：如需加载官方提供的预训练权重进行微调，请查阅 `configs\u002Finit` 目录下的配置文件指引。*","某电商公司的无障碍改造团队正致力于将数千个历史商品活动页面的截图自动转化为符合 WCAG 标准的结构化 HTML 代码，以适配视障用户的屏幕阅读器。\n\n### 没有 pix2struct 时\n- **人工还原成本极高**：开发人员需对照截图手动编写 HTML 和 CSS，单个复杂活动页平均耗时 4 小时，且容易遗漏细节。\n- **传统 OCR 丢失布局逻辑**：使用常规 OCR 工具只能提取零散文字，无法识别图表数据关系、按钮层级及表单结构，导致生成的代码不可用。\n- **多模态理解能力缺失**：面对包含混合排版（如嵌入图表的商品对比图）的界面，现有规则引擎无法推断视觉元素背后的语义功能。\n- **维护迭代困难**：一旦前端设计风格变更，硬编码的规则库需全面重写，难以适应快速变化的 UI 趋势。\n\n### 使用 pix2struct 后\n- **截图一键转代码**：利用 pix2struct 的预训练模型，直接输入页面截图即可生成高保真的结构化 HTML 标记，单页处理时间缩短至秒级。\n- **精准还原视觉语义**：pix2struct 能深度理解图像中的空间布局，自动将图表转换为数据表格，将图标识别为带 aria-label 的功能按钮。\n- **泛化能力强**：基于海量网页截图预训练，pix2struct 无需针对新设计风格重新训练，即可准确解析各类现代前端布局。\n- **自动化流水线集成**：团队将 pix2struct 部署于 CI\u002FCD 流程中，每次设计稿更新即自动触发截图解析与无障碍代码生成，大幅降低回归测试成本。\n\npix2struct 通过将视觉感知转化为结构化语言，彻底打破了从“看图”到“懂图”的技术壁垒，让无障碍改造实现了规模化落地。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fgoogle-research_pix2struct_13971c6f.png","google-research","Google Research","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fgoogle-research_c23b2adf.png","","https:\u002F\u002Fresearch.google","https:\u002F\u002Fgithub.com\u002Fgoogle-research",[21,25,29],{"name":22,"color":23,"percentage":24},"Python","#3572A5",97.2,{"name":26,"color":27,"percentage":28},"HTML","#e34c26",2.6,{"name":30,"color":31,"percentage":32},"CSS","#663399",0.3,683,60,"2026-04-01T07:23:54","Apache-2.0",5,"Linux","未说明 (主要依赖 Google Cloud TPU，如 v3-8；本地运行需支持 JAX 的硬件)","未说明",{"notes":42,"python":43,"dependencies":44},"1. 该项目主要设计用于 Google Cloud Platform (GCP) 环境，数据预处理默认使用 Dataflow，模型训练推荐使用 Cloud TPU VM。2. 必须安装 Java (default-jre) 以支持数据处理流程。3. 需要配置 Google Cloud Storage (GCS) 用于存储数据和模型，并设置相应的环境变量 (PIX2STRUCT_DIR, GCP_PROJECT, GCP_REGION)。4. 虽然提供了本地运行数据预处理的选项（通过关闭特定标志），但核心实验流程高度依赖云端基础设施。","3.9",[45,46,47,48,49],"jax","t5x","apache-beam","pytest","conda",[51,52],"图像","其他",2,"ready","2026-03-27T02:49:30.150509","2026-04-10T15:33:19.091845",[58,63,68,73,78,83,88],{"id":59,"question_zh":60,"answer_zh":61,"source_url":62},27855,"如何在本地电脑上进行预训练或微调？","您可以使用 Hugging Face 提供的 Notebook 作为起点进行本地微调。参考链接：https:\u002F\u002Fgithub.com\u002Fhuggingface\u002Fnotebooks\u002Fblob\u002Fmain\u002Fexamples\u002Fimage_captioning_pix2struct.ipynb","https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Fpix2struct\u002Fissues\u002F48",{"id":64,"question_zh":65,"answer_zh":66,"source_url":67},27856,"无法通过 GCS 路径下载微调后的权重文件怎么办？","如果您使用的是项目官方代码，通常不需要显式下载检查点，代码可以直接从 GCS bucket 读取。如果必须下载，请检查您指定的目标路径是否正确。参考解决方案：https:\u002F\u002Fstackoverflow.com\u002Fquestions\u002F48776737\u002Fhow-to-copy-file-from-bucket-gcs-to-my-local-machine","https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Fpix2struct\u002Fissues\u002F17",{"id":69,"question_zh":70,"answer_zh":71,"source_url":72},27857,"在 macOS 上运行 `pip install -e .[dev]` 安装失败如何解决？","在 macOS 终端中，需要将命令修改为 `pip install -e .\"[dev]\" -f https:\u002F\u002Fstorage.googleapis.com\u002Fjax-releases\u002Flibtpu_releases.html`（注意引号的使用）。但请注意，该项目官方并不支持 macOS 系统。","https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Fpix2struct\u002Fissues\u002F13",{"id":74,"question_zh":75,"answer_zh":76,"source_url":77},27858,"设置 `GCP_PROJECT` 环境变量时应该填项目名称还是项目 ID？","应该填写 Google Cloud Platform 的项目 ID（Project ID），而不是显示名称（Display Name），两者并不总是相同，填错会导致构建错误。正确用法：`export GCP_PROJECT=\u003Cyour_project_ID>`","https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Fpix2struct\u002Fissues\u002F8",{"id":79,"question_zh":80,"answer_zh":81,"source_url":82},27859,"运行 RefExp 数据处理步骤时报 `missing FLAG.processed_dir` 错误如何解决？","该问题已在代码库中修复。如果遇到此错误，请确保拉取了最新代码。此前可通过在源代码 `pix2struct\u002Fpreprocessing\u002Fconvert_refexp.py` 第 40 行附近为 `processed_dir` 提供默认值（如 'processed'）来暂时解决。","https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Fpix2struct\u002Fissues\u002F7",{"id":84,"question_zh":85,"answer_zh":86,"source_url":87},27860,"微调后的模型权重在哪里可以下载？","微调后的检查点（checkpoints）已经发布。请访问项目 README 中的 \"Finetuned Checkpoints\" 章节获取下载链接和说明：https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Fpix2struct\u002Fblob\u002Fmain\u002FREADME.md#finetuned-checkpoints","https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Fpix2struct\u002Fissues\u002F5",{"id":89,"question_zh":90,"answer_zh":91,"source_url":92},27861,"预训练模型是否已发布？是否有推理示例？","是的，预训练模型已发布，配置位于 `configs\u002Finit` 目录下的配置文件中（例如基础模型配置：`pix2struct\u002Fconfigs\u002Finit\u002Fpix2struct_base_init.gin`）。 standalone 推理代码也已发布，具体操作指南请参阅 README 的 \"Inference\" 部分：https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Fpix2struct#inference","https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Fpix2struct\u002Fissues\u002F1",[],[95,107,115,123,132,141],{"id":96,"name":97,"github_repo":98,"description_zh":99,"stars":100,"difficulty_score":101,"last_commit_at":102,"category_tags":103,"status":54},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[104,105,51,106],"Agent","开发框架","数据工具",{"id":108,"name":109,"github_repo":110,"description_zh":111,"stars":112,"difficulty_score":101,"last_commit_at":113,"category_tags":114,"status":54},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[105,51,104],{"id":116,"name":117,"github_repo":118,"description_zh":119,"stars":120,"difficulty_score":53,"last_commit_at":121,"category_tags":122,"status":54},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108111,"2026-04-08T11:23:26",[105,51,104],{"id":124,"name":125,"github_repo":126,"description_zh":127,"stars":128,"difficulty_score":53,"last_commit_at":129,"category_tags":130,"status":54},6121,"gemini-cli","google-gemini\u002Fgemini-cli","gemini-cli 是一款由谷歌推出的开源 AI 命令行工具，它将强大的 Gemini 大模型能力直接集成到用户的终端环境中。对于习惯在命令行工作的开发者而言，它提供了一条从输入提示词到获取模型响应的最短路径，无需切换窗口即可享受智能辅助。\n\n这款工具主要解决了开发过程中频繁上下文切换的痛点，让用户能在熟悉的终端界面内直接完成代码理解、生成、调试以及自动化运维任务。无论是查询大型代码库、根据草图生成应用，还是执行复杂的 Git 操作，gemini-cli 都能通过自然语言指令高效处理。\n\n它特别适合广大软件工程师、DevOps 人员及技术研究人员使用。其核心亮点包括支持高达 100 万 token 的超长上下文窗口，具备出色的逻辑推理能力；内置 Google 搜索、文件操作及 Shell 命令执行等实用工具；更独特的是，它支持 MCP（模型上下文协议），允许用户灵活扩展自定义集成，连接如图像生成等外部能力。此外，个人谷歌账号即可享受免费的额度支持，且项目基于 Apache 2.0 协议完全开源，是提升终端工作效率的理想助手。",100752,"2026-04-10T01:20:03",[131,104,51,105],"插件",{"id":133,"name":134,"github_repo":135,"description_zh":136,"stars":137,"difficulty_score":101,"last_commit_at":138,"category_tags":139,"status":54},4487,"LLMs-from-scratch","rasbt\u002FLLMs-from-scratch","LLMs-from-scratch 是一个基于 PyTorch 的开源教育项目，旨在引导用户从零开始一步步构建一个类似 ChatGPT 的大型语言模型（LLM）。它不仅是同名技术著作的官方代码库，更提供了一套完整的实践方案，涵盖模型开发、预训练及微调的全过程。\n\n该项目主要解决了大模型领域“黑盒化”的学习痛点。许多开发者虽能调用现成模型，却难以深入理解其内部架构与训练机制。通过亲手编写每一行核心代码，用户能够透彻掌握 Transformer 架构、注意力机制等关键原理，从而真正理解大模型是如何“思考”的。此外，项目还包含了加载大型预训练权重进行微调的代码，帮助用户将理论知识延伸至实际应用。\n\nLLMs-from-scratch 特别适合希望深入底层原理的 AI 开发者、研究人员以及计算机专业的学生。对于不满足于仅使用 API，而是渴望探究模型构建细节的技术人员而言，这是极佳的学习资源。其独特的技术亮点在于“循序渐进”的教学设计：将复杂的系统工程拆解为清晰的步骤，配合详细的图表与示例，让构建一个虽小但功能完备的大模型变得触手可及。无论你是想夯实理论基础，还是为未来研发更大规模的模型做准备",90106,"2026-04-06T11:19:32",[140,51,104,105],"语言模型",{"id":142,"name":143,"github_repo":144,"description_zh":145,"stars":146,"difficulty_score":101,"last_commit_at":147,"category_tags":148,"status":54},4292,"Deep-Live-Cam","hacksider\u002FDeep-Live-Cam","Deep-Live-Cam 是一款专注于实时换脸与视频生成的开源工具，用户仅需一张静态照片，即可通过“一键操作”实现摄像头画面的即时变脸或制作深度伪造视频。它有效解决了传统换脸技术流程繁琐、对硬件配置要求极高以及难以实时预览的痛点，让高质量的数字内容创作变得触手可及。\n\n这款工具不仅适合开发者和技术研究人员探索算法边界，更因其极简的操作逻辑（仅需三步：选脸、选摄像头、启动），广泛适用于普通用户、内容创作者、设计师及直播主播。无论是为了动画角色定制、服装展示模特替换，还是制作趣味短视频和直播互动，Deep-Live-Cam 都能提供流畅的支持。\n\n其核心技术亮点在于强大的实时处理能力，支持口型遮罩（Mouth Mask）以保留使用者原始的嘴部动作，确保表情自然精准；同时具备“人脸映射”功能，可同时对画面中的多个主体应用不同面孔。此外，项目内置了严格的内容安全过滤机制，自动拦截涉及裸露、暴力等不当素材，并倡导用户在获得授权及明确标注的前提下合规使用，体现了技术发展与伦理责任的平衡。",88924,"2026-04-06T03:28:53",[105,51,104,149],"视频"]