Nodes/Kandinsky 2.2 ComfyUI Plugin/Kandinsky2.2 Image Encoder
ComfyUI Node

Kandinsky2.2 Image Encoder

Turning a Reference Image Into Kandinsky 2.2 Image Embeddings

By vsevolod-oparin·Created 3 years ago·Updated about a year ago· 9
Kandinsky2.2 Image Encoder
  • encoder
  • image
  • PRIOR_LATENT

Kandinsky 2.2 is a two-stage model: a prior that produces image embeddings, and a decoder that turns them into pixels. This node is the bridge between the two worlds - it runs a CLIP image encoder over an actual image and spits out image_embeds in exactly the same PRIOR_LATENT format a text prompt produces. That symmetry is the whole trick, and it's what makes the model's image tricks work.

What it's for

Because an image embed and a text embed live in the same space, you can mix them with the pack's prior-averaging nodes, or feed an image's embed straight into the decoder as if it were a prompt. The pack's workflow-image-embed.json does exactly that: encode a reference image, encode a text prompt, average the two, and generate - a lightweight form of style/content transfer that was genuinely ahead of its time in 2023. The workflow-img2img.json uses the same encoder to feed the image's identity into the graph while the decoder handles the pixel-level transformation.

Note the division of labor: this node handles the embedding of the source image. The pixel-level source for img2img comes from a different node, comfy-kandinsky22-img-latents, which encodes the image with the MovQ VAE. They're complementary, not interchangeable.

Inputs and output

  • encoder - the IMAGE_ENCODER output from the Prior Loader.
  • image - any IMAGE, straight from LoadImage or anything else in your graph.

Output: image_embeds (PRIOR_LATENT). Feed it into the Unet Decoder's image_embeds port, or into a prior-averaging node to blend with text embeds.

Installing it

Same pack, same manual install (the README says it's not in ComfyUI Manager's list):

cd ComfyUI/custom_nodes
git clone https://github.com/vsevolod-oparin/comfyui-kandinsky22
cd comfyui-kandinsky22
python -s -m pip install -r requirements.txt

Plus the models in ComfyUI/models/checkpoints:

git clone --depth 1 https://huggingface.co/kandinsky-community/kandinsky-2-2-prior
git clone --depth 1 https://huggingface.co/kandinsky-community/kandinsky-2-2-decoder
git clone --depth 1 https://huggingface.co/kandinsky-community/kandinsky-2-2-controlnet-depth

Gotchas

  • Prior loader, not decoder loader. This node needs the IMAGE_ENCODER output from the Prior Loader. Both loaders share the "kandinsky" folder filter, so keep the dropdowns straight: prior folder in the prior loader, decoder folder in the decoder loader.
  • First load is slow. It loads the full prior pipeline in fp16 just to get at the image encoder, then offloads it to CPU. Subsequent uses in the same session are faster, but the first run feels like forever.
  • Same dependency warning as the rest of the pack. Pinned old diffusers commit and accelerate==0.27.2 in requirements.txt can collide with other nodes' requirements.
  • Vintage model. Kandinsky 2.2 stopped being community-relevant around mid-2024. The image-embed mixing here is still a fun, distinct workflow - just know you're playing with history.

If you want text plus image in one graph, the natural pattern is: Image Encoder → Prior Averaging 2, Text Encoder → Prior Averaging 2, Prior Averaging 2 → Unet Decoder. The pack's example workflows are the best guide.

Categoryconditioning

Inputs (2)

NameTypeDefaultDescription
encoderIMAGE_ENCODER
imageIMAGE

Outputs (1)

NameTypeDescription
PRIOR_LATENTPRIOR_LATENT