# InstructPix2Pix

**InstructPix2Pix** 是一个基于指令的图像编辑模型：给定一张输入图像和一条书面指令（例如“把橙子换成香蕉”或“把他变成赛博格”），一个条件扩散模型通过迭代扩散去噪步骤来生成编辑后的图像，而非单次前向传播，且无需针对每个样本进行微调或反演。<sup>[19](https://docs.openvino.ai/2024/notebooks/instruct-pix2pix-image-editing-with-output.html)</sup> 该模型由加州大学伯克利分校（University of California, Berkeley）的 Tim Brooks、Aleksander Holynski 和 [Alexei A. Efros](https://www.edgepedia.org/zh/alexei-a-efros) 创建，于 2022 年 11 月 17 日发布到 arXiv，并在 CVPR 2023 上作为亮点论文发表。<sup>[1](https://arxiv.org/abs/2211.09800)</sup><sup> • </sup><sup>[2](https://openaccess.thecvf.com/content/CVPR2023/html/Brooks_InstructPix2Pix_Learning_To_Follow_Image_Editing_Instructions_CVPR_2023_paper.html)</sup><sup> • </sup><sup>[3](https://www.deeplearning.ai/the-batch/instructpix2pix-for-text-to-image-editing-explained/)</sup>

| 关键事实 | 详情 |
|---|---|
| 作者与发表会议 | Tim Brooks、Aleksander Holynski（同等贡献）和 Alexei A. Efros，加州大学伯克利分校；CVPR 2023，第 18392–18402 页，亮点论文<sup>[2](https://openaccess.thecvf.com/content/CVPR2023/html/Brooks_InstructPix2Pix_Learning_To_Follow_Image_Editing_Instructions_CVPR_2023_paper.html)</sup><sup> • </sup><sup>[4](https://instruct-pix2pix.timothybrooks.com/)</sup> |
| 输入与输出 | 一张输入图像和一条文本指令；输出为编辑后的图像，通过迭代扩散去噪步骤生成，通常在数秒内完成<sup>[1](https://arxiv.org/abs/2211.09800)</sup> |
| 训练数据 | 454,445 个合成三元组（输入图像、指令、编辑后图像），由 GPT-3 和 Stable Diffusion 配合 Prompt-to-Prompt 生成；经 NSFW 过滤后为 451,990 个<sup>[5](https://github.com/timothybrooks/instruct-pix2pix)</sup> |
| 基础模型 | 从 Stable Diffusion v1.5 检查点微调而来；983M 参数<sup>[5](https://github.com/timothybrooks/instruct-pix2pix)</sup><sup> • </sup><sup>[6](https://doi.org/10.1145/3777411)</sup> |
| 引导 | 双无分类器引导，分别使用文本尺度 s_T 和图像尺度 s_I；发布的默认值为文本 7.5、图像 1.5<sup>[7](https://openaccess.thecvf.com/content/CVPR2023/papers/Brooks_InstructPix2Pix_Learning_To_Follow_Image_Editing_Instructions_CVPR_2023_paper.pdf)</sup><sup> • </sup><sup>[5](https://github.com/timothybrooks/instruct-pix2pix)</sup> |
| 硬件 | 参考快速入门在显存超过 18 GB 的 GPU 上测试<sup>[5](https://github.com/timothybrooks/instruct-pix2pix)</sup> |
| 后续工作 | 在人工标注的 MagicBrush 数据集上微调可显著提升编辑质量；Instruct-NeRF2NeRF 使用该模型编辑三维场景<sup>[8](https://arxiv.org/abs/2306.10012)</sup><sup> • </sup><sup>[9](https://arxiv.org/abs/2303.12789)</sup> |

## 编辑问题

基于指令的编辑要求模型只改变指令所指名的内容，保持图像其余部分不变，并接受以人们自然会写的方式表述的指令。早期的扩散编辑方法通常需要逐图像优化（例如反演和微调步骤，可能耗时数分钟），或需要手动指定编辑位置的掩码。InstructPix2Pix 则学习从（图像，指令）到编辑后图像的直接映射，因此推理时编辑在数秒内即可完成。<sup>[1](https://arxiv.org/abs/2211.09800)</sup><sup> • </sup><sup>[3](https://www.deeplearning.ai/the-batch/instructpix2pix-for-text-to-image-editing-explained/)</sup>

核心障碍在于训练数据：没有大型数据集将真实图像与指令及对应的编辑结果配对。作者通过使用另外两个预训练模型生成数据解决了这一问题，这一策略成为后来指令微调编辑器的模板。<sup>[1](https://arxiv.org/abs/2211.09800)</sup>

## 合成数据集生成

**两阶段生成。** 首先，微调 GPT-3，使其接收图像描述并生成文本三元组：描述图像的描述文本、编辑指令、以及描述编辑后图像的描述文本。微调集为 700 个手动编写的示例，涵盖广泛的编辑类型，输入提示从 LAION Improved Aesthetics 6.5+ 数据集中采样；作者通过 [OpenAI API](https://www.edgepedia.org/zh/openai-api) 对 GPT-3 的 Davinci 模型进行了单轮微调。其次，使用 [Stable Diffusion](https://www.edgepedia.org/zh/stable-diffusion) 配合 [Prompt-to-Prompt](https://www.edgepedia.org/zh/prompt-to-prompt) 将编辑前后的描述对转换为图像对，该方法促使来自相关提示的两次生成保持相似，因此编辑前后的图像主要在指令所指的属性上有所不同。<sup>[5](https://github.com/timothybrooks/instruct-pix2pix)</sup><sup> • </sup><sup>[3](https://www.deeplearning.ai/the-batch/instructpix2pix-for-text-to-image-editing-explained/)</sup>

发布的生成数据集包含 454,445 个示例，每个示例包含一张输入图像、一条编辑指令和一张输出编辑图像。对提示和图像进行 NSFW 内容过滤后，剩余 451,990 个示例。发布的两个版本在筛选方式上有所不同：在 CLIP 过滤数据集中，每对编辑图像生成 100 次，并根据 CLIP 指标保留最佳示例，得到 313,010 个示例，大小 436 GB；而随机采样数据集保留随机选择的示例，总计 727 GB。使用 GPT-3 生成文本数据集花费了数千美元，作者指出 Stable Diffusion 和 Prompt-to-Prompt 无法执行大型空间变换（如移动相机或交换物体位置），这限制了合成数据所能教授的内容。<sup>[5](https://github.com/timothybrooks/instruct-pix2pix)</sup>

## 模型与引导

InstructPix2Pix 是一个从 Stable Diffusion v1.5 检查点微调的潜在扩散模型。去噪网络接受两个条件：输入图像（经编码后在第一个卷积层通过额外输入通道与带噪潜变量拼接）和文本指令。由于存在两个条件，模型将无分类器引导（将去噪估计沿远离无条件预测、趋向有条件预测的方向外推）扩展为对文本和图像分别使用不同尺度的双重形式：<sup>[7](https://openaccess.thecvf.com/content/CVPR2023/papers/Brooks_InstructPix2Pix_Learning_To_Follow_Image_Editing_Instructions_CVPR_2023_paper.pdf)</sup><sup> • </sup><sup>[10](https://github.com/huggingface/diffusers/blob/main/examples/instruct_pix2pix/README.md)</sup>

\[ \tilde{e}_{\theta}(z_t, c_I, c_T) = e_{\theta}(z_t, \varnothing) + s_I \cdot \big( e_{\theta}(z_t, c_I, \varnothing) - e_{\theta}(z_t, \varnothing) \big) + s_T \cdot \big( e_{\theta}(z_t, c_I, c_T) - e_{\theta}(z_t, c_I, \varnothing) \big) \]

两个尺度控制不同的失效模式。较高的图像尺度 s_I 产生的编辑在空间结构上更接近输入图像；较高的文本尺度 s_T 产生更强烈的、遵循指令的编辑。仓库的调参建议直接由此而来：如果图像变化太小，降低 s_I 或提高 s_T；如果原始图像丢失太多，则反之。发布的默认值为 s_T = 7.5 和 s_I = 1.5。<sup>[7](https://openaccess.thecvf.com/content/CVPR2023/papers/Brooks_InstructPix2Pix_Learning_To_Follow_Image_Editing_Instructions_CVPR_2023_paper.pdf)</sup><sup> • </sup><sup>[5](https://github.com/timothybrooks/instruct-pix2pix)</sup>

由于模型仅在合成数据上训练却应用于真实照片，泛化能力是一个明确的设计目标，论文报告称其在推理时对真实图像和用户编写的指令均有效。<sup>[1](https://arxiv.org/abs/2211.09800)</sup>

## 使用与生态

作者发布了 PyTorch 代码、数据集、预训练检查点和托管演示；命令行工具通过诸如 `--edit "turn him into a cyborg"` 的调用编辑单张图像。该模型迅速被集成到 Hugging Face Diffusers 库中，作为 StableDiffusionInstructPix2PixPipeline，后来又有了基于 SDXL 的 768 分辨率变体，并被集成到 Stable Diffusion 的社区界面中。<sup>[5](https://github.com/timothybrooks/instruct-pix2pix)</sup><sup> • </sup><sup>[11](https://huggingface.co/docs/diffusers/main/api/pipelines/pix2pix)</sup>

训练配方被证明比特定检查点更具可移植性。MagicBrush 是一个基于真实图像构建的、包含超过 10,000 个人工标注编辑三元组的数据集，它在其数据上微调 InstructPix2Pix，并根据人工评估报告了显著更好的图像，表明合成数据噪声是原始模型的真实局限。Instruct-NeRF2NeRF 将该模型应用于三维：它使用 InstructPix2Pix 迭代编辑场景的照片，同时优化底层的神经辐射场，生成遵循指令的编辑后三维场景。其他工作将该方法适配于机器人动作预测和纠正文本到图像生成中的幻觉内容。<sup>[8](https://arxiv.org/abs/2306.10012)</sup><sup> • </sup><sup>[9](https://arxiv.org/abs/2303.12789)</sup><sup> • </sup><sup>[12](https://arxiv.org/abs/2507.14809)</sup><sup> • </sup><sup>[13](https://arxiv.org/abs/2407.10683)</sup>

## 局限与后续地位

合成训练分布塑造了模型擅长的领域。在一项针对域外自动触发相机拍摄的野生动物照片的 NeurIPS 研究中，发现 InstructPix2Pix 经常施加不真实的、类似喷绘的效果，或抹去原始图像的大部分信息，并将其归因于训练数据主要由对艺术图像的风格化修改组成；在该数据集上，其下游准确率为 76.23 ± 4.78%，而普通 img2img 编辑为 84.87 ± 1.92%。后来的基准工作还发现了多指令编辑以及无意中改变非预期区域方面的弱点，这推动了诸如建立在 IP2P 之上的注意力调制编辑等方法。<sup>[14](https://papers.neurips.cc/paper_files/paper/2023/file/f99f7b22ad47fa6ce151730cf8d17911-Paper-Conference.pdf)</sup><sup> • </sup><sup>[15](https://arxiv.org/abs/2312.10113)</sup>

InstructPix2Pix 仍然是编辑基准中的标准基线：CompBench 和 I2EBench 等评估将其纳入指令遵循测试模型之列，而一份 2026 年的[基于指令的图像编辑](https://www.edgepedia.org/zh/instruction-based-image-editing)综述将其视为扩散时代编辑器世代的里程碑。其资源占用也已降低：一种扩散压缩方法在保持输出质量的同时，将模型大小缩减了 39.2%，延迟降低了 81.4%。<sup>[16](https://comp-bench.github.io/)</sup><sup> • </sup><sup>[17](https://link.springer.com/article/10.1007/s44336-026-00034-3)</sup><sup> • </sup><sup>[18](https://arxiv.org/abs/2401.17547)</sup>

## References

1. [Brooks, Holynski, Efros (2022). InstructPix2Pix: Learning to Follow Image Editing Instructions. arXiv:2211.09800.](https://arxiv.org/abs/2211.09800)
2. [CVPR 2023 Open Access Repository: InstructPix2Pix, pp. 18392–18402.](https://openaccess.thecvf.com/content/CVPR2023/html/Brooks_InstructPix2Pix_Learning_To_Follow_Image_Editing_Instructions_CVPR_2023_paper.html)
3. [InstructPix2Pix for Text-to-Image Editing, Explained. DeepLearning.AI The Batch.](https://www.deeplearning.ai/the-batch/instructpix2pix-for-text-to-image-editing-explained/)
4. [InstructPix2Pix project page (UC Berkeley).](https://instruct-pix2pix.timothybrooks.com/)
5. [timothybrooks/instruct-pix2pix, GitHub repository README.](https://github.com/timothybrooks/instruct-pix2pix)
6. [Instruction Tuning for Large Language Models: A Survey. ACM Computing Surveys.](https://doi.org/10.1145/3777411)
7. [Brooks et al., CVPR 2023 paper PDF (Section 3.2.1, Classifier-free Guidance for Two Conditionings).](https://openaccess.thecvf.com/content/CVPR2023/papers/Brooks_InstructPix2Pix_Learning_To_Follow_Image_Editing_Instructions_CVPR_2023_paper.pdf)
8. [Zhang et al. (2023). MagicBrush: A Manually Annotated Dataset for Instruction-Guided Image Editing. arXiv:2306.10012.](https://arxiv.org/abs/2306.10012)
9. [Haque et al. (2023). Instruct-NeRF2NeRF: Editing 3D Scenes with Instructions. arXiv:2303.12789.](https://arxiv.org/abs/2303.12789)
10. [Hugging Face Diffusers: InstructPix2Pix training example README.](https://github.com/huggingface/diffusers/blob/main/examples/instruct_pix2pix/README.md)
11. [Hugging Face Diffusers: InstructPix2Pix pipeline documentation.](https://huggingface.co/docs/diffusers/main/api/pipelines/pix2pix)
12. [Light Future: Multimodal Action Frame Prediction via InstructPix2Pix. arXiv:2507.14809.](https://arxiv.org/abs/2507.14809)
13. [Addressing Image Hallucination in Text-to-Image Generation through Factual Image Retrieval. arXiv:2407.10683.](https://arxiv.org/abs/2407.10683)
14. [ALIA paper, NeurIPS 2023 (Choice of Image Editing Method section).](https://papers.neurips.cc/paper_files/paper/2023/file/f99f7b22ad47fa6ce151730cf8d17911-Paper-Conference.pdf)
15. [Guo, Lin (2023). Focus on Your Instruction: Fine-grained and Multi-instruction Image Editing by Attention Modulation. arXiv:2312.10113.](https://arxiv.org/abs/2312.10113)
16. [CompBench: Benchmarking Complex Instruction-guided Image Editing.](https://comp-bench.github.io/)
17. [Instruction-based image editing: a survey on data, models, evaluation, and applications. Vicinagearth (2026).](https://link.springer.com/article/10.1007/s44336-026-00034-3)
18. [Diffusion Model Compression for Image-to-Image Translation. arXiv:2401.17547.](https://arxiv.org/abs/2401.17547)
19. [Image Editing with InstructPix2Pix and OpenVINO, OpenVINO™ documentation](https://docs.openvino.ai/2024/notebooks/instruct-pix2pix-image-editing-with-output.html)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 现代人工智能：基础模型、生成式人工智能与人工智能产业 › Model families and named models › Image generation models

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/instructpix2pix

English original: https://www.edgepedia.org/instructpix2pix
