Show the model the picture
Source: Hu Ye, Jun Zhang, Sibo Liu, Xiao Han, and Wei Yang, Tencent AI Lab. “IP-Adapter: Text Compatible Image Prompt Adapter for Text-to-Image Diffusion Models.” arXiv:2308.06721v1, 13 August 2023. https://arxiv.org/abs/2308.06721v1
A reference photo already says more than the paragraph you are willing to type. IP-Adapter is a 22-million-parameter add-on that lets a frozen Stable Diffusion take that photo as a prompt, and still keep text, custom checkpoints, and ControlNet.
You already have the picture. That is the annoying part. You want a chipped ceramic mug on a wooden table, side-lit, and the mug in your head is a specific one. Maybe it is sitting in a photo on your desktop. Stable Diffusion would rather you describe it. So you type “ceramic mug, chipped rim, warm side light, wooden table, shallow depth of field,” and you get a mug that is almost right, in a room that is wrong, with the handle on the other side.
Words throw away a lot. Anyone who has spent an afternoon prompt-engineering knows the saying the authors put in the abstract, and knows it is only half a joke: a picture really does carry more than the paragraph you are willing to type.
Hu Ye, Jun Zhang, Sibo Liu, Xiao Han, and Wei Yang, at Tencent AI Lab, published IP-Adapter in August 2023 to deal with that. The paper is IP-Adapter: Text Compatible Image Prompt Adapter for Text-to-Image Diffusion Models. The HTML version is at https://arxiv.org/html/2308.06721v1. The idea is plain. Leave the text-to-image model alone, and bolt on a small piece that can take a reference image as a prompt.
Two older ways, both awkward
People had tried this before, and the attempts had a pattern.
One camp fine-tuned the whole diffusion model so it listened to an image embedding instead of a caption. Stable Diffusion Image Variations does this by swapping text features for a CLIP image embedding. Stable unCLIP adds the image embedding into the time embedding. Both can follow a reference. Both are expensive, both forget how to be a normal text model, and neither drops cleanly onto the custom checkpoints people actually use, or onto ControlNet. DALL-E 2 had image prompts from the start, because it was built around CLIP image embeddings and a separate prior. Most of the popular open models were built the other way around. They expect text.
The other camp tried not to touch the big model. Take a CLIP image embedding, run it through a small network, stick it onto the text tokens, and hope the existing attention layers cope. T2I-Adapter’s style adapter works like that. So does the global controller in Uni-ControlNet. SeeCoder goes further and replaces the text encoder. These are cheap. They also tend to catch the mood of a reference and miss the rest. You get a cousin of the picture. You wanted the picture.
The image gets its own door
The authors think the miss happens in a specific place. In Stable Diffusion, cross-attention is how the caption gets into the UNet. The features of the image being drawn ask a question. That question is the query. The caption, already turned into CLIP text features, answers through key and value projections. Those projections spent their whole training life on text. If you concatenate image features onto text features and send them through the same projections, you are mostly teaching the image to impersonate a caption. Style survives that. Fine detail often does not.
IP-Adapter gives the image its own door.
For each of the 16 cross-attention layers in Stable Diffusion v1.5, they add a second cross-attention that only reads the image. The query stays shared, so the half-drawn picture is still the thing asking. The image gets its own key and value weights. Those weights are initialized as a copy of the text weights, which gives training a head start. The two answers are added together. During training, the original UNet is frozen. The CLIP image encoder is frozen too. The only new parameters are the image key and value projections, plus a small projection network in front of them. Together that is about 22 million parameters.
The projection is almost embarrassingly small. OpenCLIP ViT-H/14 reads the reference and emits one global embedding, a single vector trained to sit near matching captions. A linear layer and a layer norm stretch that vector into four tokens, the same width as the text tokens the UNet already expects. Four tokens. That is the entire image prompt.
Because the two attentions are separate, you can turn the image one up or down at inference time with a scalar they call lambda. At zero, the added term vanishes and you have the original text model back. Around one, the reference carries full weight. If you also type a caption, lambda is the balance between “look like this photo” and “but make it night, and put the mug by a window.” The paper’s multimodal examples are mostly this: keep the subject from the image, change clothes, place, or attributes with a short sentence. They say it behaves especially well on community checkpoints.
How they trained it
Training is ordinary diffusion training, on roughly 10 million image-text pairs drawn from LAION-2B and COYO-700M. One machine, eight V100s, a million steps, batch size 8 on each GPU, AdamW at a fixed learning rate of 0.0001. They drop the text, the image, or both, each with probability 0.05, so classifier-free guidance still works later. If the image condition is dropped, they zero out the CLIP embedding. At test time they sample with DDIM for 50 steps and a guidance scale of 7.5. Image-only runs use an empty caption and lambda of 1.
What the numbers actually say
The comparison that matters is on the COCO 2017 validation set: 5,000 images, four generations each, scores from CLIP ViT-L/14. CLIP-I is how close the result sits to the reference in CLIP’s image embedding. CLIP-T is CLIPScore against the caption that belonged to that reference, so it asks whether the result still means the same thing, not only whether it looks alike.
IP-Adapter lands at 0.828 CLIP-I and 0.588 CLIP-T. SD unCLIP, a full fine-tune of about 870 million trainable parameters, gets 0.810 and 0.584. SD Image Variations, similar size, drops to 0.760 and 0.548, which is what you would expect once the text pathway has been replaced. The lightweight adapters are in another league: Uni-ControlNet’s global controller at 0.736 CLIP-I, T2I-Adapter’s style adapter at 0.648, ControlNet Shuffle at 0.616, and Shuffle’s caption score is 0.421. On the other side, models trained from scratch still lead by a little. Open unCLIP, a DALL-E 2-style reproduction, scores 0.858 and 0.608 with 893 million parameters. Kandinsky 2.1 is close to that and even larger. Versatile Diffusion is almost a tie with IP-Adapter on both numbers, at 860 million parameters, and it is one of the few big models that can take text and image together.
Read that table without the abstract’s adjectives and it still says something sharp. A 22-million-parameter add-on matches or beats the fine-tunes, sits next to models trained from scratch, and keeps the three things those models give up: it can move to other checkpoints from the same base, it can sit beside ControlNet, and it can take a caption at the same time as a picture.
Train it once, then use it everywhere
They check reuse by dropping the same adapter, trained once, onto Realistic Vision v4, Anything v4, and ReV Animated, all fine-tunes of SD 1.5. The reference comes through, and so does the checkpoint. Anything v4 draws the subject in its anime style. The adapter also runs on SD 1.4, which is just an earlier point on the same model line. That reuse is the practical reason to freeze the UNet. You train the small piece against the base model, and the community checkpoints inherit it.
Structure control is the same story. ControlNet and T2I-Adapter plug in without another training run. Pose, depth, edges, segmentation: the image prompt supplies what the picture should look like, the structure model supplies where things sit. In their side-by-sides, IP-Adapter holds onto the reference more tightly than Shuffle, Reference-only, SeeCoder, or the other global adapters, while the pose or the depth map still reads. Image-to-image and inpainting come along because Stable Diffusion already has those paths through SDEdit. You use the image prompt where a caption used to go.
One caveat belongs next to the pretty figures. For the qualitative grids they generate four samples and keep the best. Face photos in the paper are synthetic. SeeCoder is shown with an extra scribble ControlNet, and ControlNet Reference-only is also given a BLIP caption. The numbers in the table are the fairer comparison. The pictures are there to show the kind of miss the numbers are averaging over: other adapters catch a palette and a subject category, and IP-Adapter more often catches the object.
The part they say is doing the work
They also ablate the part they claim is doing the work. A simpler adapter, image features concatenated with text and pushed through the original attention, was trained for 200,000 steps under the same setup. The results are softer and less faithful to the reference. Same data, same budget, the second attention path removed. That is the cleanest experiment in the paper.
There is a second variant, for people who find four global tokens too blunt. Instead of CLIP’s single embedding, they take the grid of features from the penultimate layer and let 16 learned tokens query that grid through a small transformer. The copies get tighter. They also inherit the layout of the reference, so you lose the freedom to invent a new composition. A pose map or a caption can pry that layout loose again. The global version behaves like a prompt. The fine-grained version behaves more like a careful copy, which is a different job.
Where it stops
The authors are direct about the ceiling, and it is worth believing them. IP-Adapter makes pictures that resemble the reference in content and style. DreamBooth and Textual Inversion, which fine-tune toward one specific subject, are a different tool. This adapter will give you a dog of that breed and coloring, often in that kind of light. A specific dog, scar and all, in a scene it has never seen, is outside what this adapter was built to do. If the job is “this exact product, every time,” the paper points you elsewhere. If the job is “I have a reference, I have a sentence, and I want to keep the checkpoint and the ControlNet I already like,” 22 million parameters is a very small thing to add.