SavePosEmbeds
Cache Your Image Embeddings So You Never Re-Encode
- pos_embed
- non_embedded_image_filenames
- cache_dir
Every time you push a reference image through an IP-Adapter encoder, you're spending GPU time to recompute the same vector you already computed last run. SavePosEmbeds is the write side of the fix: it takes a batch of IP-Adapter embeddings and writes each one to disk as a .pth file, keyed by the source image's name. Load them back later with Load_Embeddings_From_Folder and the encoder cost drops to zero.
Inputs:
pos_embed- an EMBEDS batch, one embedding per image. It requires exactly 3 dims ([batch, tokens, features]), so feed it from whatever produces image embeddings (an IP-Adapter encoder orRandom_Style_Mixture's output), not from a raw CLIP tensor.non_embedded_image_filenames- a LIST of the filenames that correspond to that batch, in order. This is where the filename gets turned into the cache key: the node strips paths and extensions, and saves each embedding as<image_id>.pth. The batch size must match the list length, and it asserts loudly if they don't.cache_dir- where the.pthfiles land. The default iseden_images/xander_big, an internal Eden.art dataset path you should replace with your own folder.
Output is a single cache_dir STRING - mostly so you can thread the folder path into the matching loader later without retyping it.
How it fits the workflow
The full loop in this pack is a tidy pipeline: FolderScanner gives you the list of unembedded filenames, you encode them to get pos_embed, SavePosEmbeds writes the cache, then Load_Embeddings_From_Folder reloads the whole stack and Random_Style_Mixture explores it. Once the cache exists, the encode step can be bypassed entirely - which matters when your reference set is large and your patience is short. The mechanism is unglamorous: torch.save per embedding, keyed by filename stem. Simple, and exactly right.
Installing it
Part of the Eden.art nodesuite, under Eden π±. ComfyUI Manager β search "Eden" β install, or:
cd ComfyUI/custom_nodes/
git clone https://github.com/edenartlab/eden_comfy_pipelines.git
cd eden_comfy_pipelines
pip install -r requirements.txt
Restart to load it.
Common issues
The batch-length assert is the main tripwire - if pos_embed and the filename list disagree, it errors rather than saving garbage, which is the right failure mode. The subtler one: get_id_from_filename uses the base name without extension, so two images named photo.png and photo.jpg in the same folder collide and silently overwrite each other. Keep filenames unique. And the usual embedding caveat: the cache is only valid for the encoder that made it - mixing CLIP-vision variants across save and load degrades results quietly, because the saved geometry belongs to the original encoder.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| pos_embed | EMBEDS | β | |
| cache_dir | STRING | eden_images/xander_big | β |
| non_embedded_image_filenames | LIST | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| cache_dir | STRING | β |