
ImageProjection
Diffusion and generative4 ops3.2M params
IP-Adapter's linear-plus-LayerNorm projection that turns a CLIP image embedding into prompt tokens.
Diffusion and generative · 1 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
About this model's family
ImageProjection is the small front door of IP-Adapter, a lightweight adapter that gives a pretrained text-to-image diffusion model the ability to take an image as a prompt. The adapter leans on a CLIP image encoder and uses its single global embedding, which the paper says is well aligned with captions and carries both the content and the style of the picture. That one vector is what the module traced here receives, and its job is to unfold it into a short sequence of four feature tokens whose width matches the text features the diffusion model already expects. Architecturally it is plain, a linear layer followed by Layer Normalization.
The projected tokens matter because of where they go next: IP-Adapter's key design is a decoupled cross-attention mechanism that keeps separate cross-attention layers for text features and image features. For every cross-attention layer in the UNet, the authors add a new one that attends only to the image features, and during training only these new layers are trained while the original UNet stays frozen. The reasoning is that merging image features and text features into the existing cross-attention layer only aligns the image features to the text features and can miss image-specific information. The whole adapter, projection network and new attention modules together, amounts to about 22M trainable parameters. The paper reports that this small adapter performs comparably or even better than a fully fine-tuned image prompt model.
Because the base diffusion model is never modified, the trained adapter transfers to custom models fine-tuned from the same base and works alongside structural control tools such as ControlNet. At inference a weight factor lets you dial the image branch up or down, and at zero the model becomes the original text-to-image diffusion model again. The paper's experiments use OpenCLIP ViT-H/14 as the image encoder. The repository notes that IP-Adapter is available in Diffusers thanks to the Diffusers team. It also flags a practical quirk: because CLIP's default image processor center crops, IP-Adapter works best for square images and will miss information outside the center of non-square ones.
Key idea. IP-Adapter adds image prompt capability to a pretrained text-to-image diffusion model through a decoupled cross-attention mechanism that separates cross-attention layers for text features and image features. The traced ImageProjection module is the adapter's projection network, which consists of a linear layer and a Layer Normalization.
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
@misc{ye2023ipadaptertextcompatibleimage,
title={IP-Adapter: Text Compatible Image Prompt Adapter for Text-to-Image Diffusion Models},
author={Hu Ye and Jun Zhang and Sibo Liu and Xiao Han and Wei Yang},
year={2023},
eprint={2308.06721},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2308.06721},
}