InstructPix2Pix
An instruction-following image editing model trained on a synthetic dataset generated by combining GPT-3 and Stable Diffusion.
Paper: InstructPix2Pix: Learning to Follow Image Editing Instructions
Authors: Tim Brooks, Aleksander Holynski, Alexei A. Efros · 2022
Read the paperThe Problem
Before InstructPix2Pix, editing an image with a text-to-image diffusion model was cumbersome. Users could not simply provide an instruction like "make the sky stormy" or "add a dog." Instead, they had to rely on complex workarounds: generating a completely new image from a highly engineered prompt, using masks to manually define an inpainting region, or running expensive per-image optimization (like Textual Inversion or DreamBooth). These approaches were slow, required significant human intervention, and didn't feel like conversational instruction-following. The main bottleneck preventing a simple instruction-following model was data: there was no large-scale dataset of (input image, text instruction, output image) triplets.
The Idea
The authors realized that while they lacked a human-annotated dataset for image editing, they had access to two powerful prior models: GPT-3, which understands text and instructions, and Stable Diffusion, which can synthesize images from text. By combining these models, they could generate a massive, high-quality synthetic dataset of image edits. They could then use this synthetic dataset to train a conditional diffusion model to follow instructions in a single forward pass, eliminating the need for per-image optimization or manual masking.
How It Works
Generating the Synthetic Dataset The data generation pipeline relies on two frozen, pre-trained models. First, GPT-3 is fine-tuned on a small set of human-written editing examples. It then generates thousands of triplets consisting of: an input caption, an edit instruction, and a resulting output caption. Second, Stable Diffusion is used alongside the Prompt-to-Prompt technique (which injects cross-attention maps from an original image into a new image to preserve structure). This pair of models takes the GPT-3 generated input/output captions and produces corresponding "before" and "after" images that share the same composition but reflect the edit.
Training the Diffusion Model Once the dataset is generated, the authors train a modified version of Stable Diffusion. Standard Stable Diffusion takes random noise and a text prompt. InstructPix2Pix adds additional input channels to the first convolutional layer of the UNet to accept the encoded "before" image.
Zero-Initialized Convolutions To leverage the pre-trained weights of Stable Diffusion without destroying them, the weights corresponding to the newly added image conditioning channels are initialized to zero. This allows the model to start training exactly as a standard text-to-image model and gradually learn to incorporate the image conditioning.
Why It Mattered
InstructPix2Pix demonstrated that a model could learn complex, open-ended image editing entirely from synthetic data. More importantly, it solved the UX bottleneck of diffusion editing: it allowed users to edit images in a single forward pass simply by typing an instruction, just as intuitively as chatting with an LLM. It was fast (requiring only seconds on a GPU) and generalized to real images and arbitrary instructions it had never seen during training.
What Came After
The zero-initialization technique for adding conditioning to diffusion models was concurrently formalized as ControlNet, which became the standard way to guide diffusion models. InstructPix2Pix's synthetic data pipeline inspired numerous subsequent works that use large language models and foundation models to bootstrap training data for specialized downstream tasks without human labeling. It also paved the way for more advanced instruction-following visual models, such as MagicBrush and various multimodal LLM editing frameworks.