Compare Embeddings
How similar are these two images, actually? A single number says so
- clip_vision_output1
- clip_vision_output2
- SCORE
Compare Embeddings is the smallest useful node in this pack: two images in, one number out, and that number is how similar they are on a scale from 0.0 to 1.0. It's the "is this close enough?" check that the whole database-search machinery is secretly built on, and you'll reach for it whenever you want similarity without standing up a database.
Classic uses: dedupe a folder of generated images, sanity-check that two crops of the same photo really are the same scene, or threshold "does this reference match this output well enough to bother." The README's example is even simpler - wire it up, read the score, done.
How it works
Each input is a CLIP_VISION_OUTPUT from a CLIP Vision Encode node (load your two images, encode each with the same CLIP vision model). The node flattens both embedding vectors and computes cosine similarity - the dot product divided by the product of the two norms. That's the exact same math Image Searcher runs against a whole database, just between two single vectors.
The output is one SCORE float. It isn't a percentage and it isn't calibrated - it's a cosine similarity in CLIP space, so "0.9" means "very close by CLIP's reckoning" and values below maybe 0.5 mean "not really related." Both images should be encoded with the same CLIP vision model or the comparison is meaningless. That's the rule that bites people most.
To actually see the number you need something to display a FLOAT - the README suggests Crystools' "Show any value to console/display", which is the standard swiss-army display node, but any text/number preview works. You can also wire SCORE into math or logic nodes if you want to branch a workflow on it.
The inputs that matter
- clip_vision_output1 and clip_vision_output2 - two CLIP Vision Encode outputs, same model, and that's the whole list.
No settings to fiddle, no model to load here. The heaviest part is the two CLIP vision encodings themselves, which run on whatever device ComfyUI is using.
Installing it
Standard pack install. ComfyUI Manager → search "ClipVision_Tools" → install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/MoonMoon82/ClipVision_Tools
cd ClipVision_Tools
python -m pip install -r requirements.txt
Dependencies are just orjson and pillow-heif; no model download for the node itself, but you do need a CLIP vision model in ComfyUI/models/clip_vision to encode with.
Gotchas
- Model mixing: encode image A with bigG and image B with ViT-H and the score is close to garbage. Same encoder, always.
- CLIP vision ≠ face similarity: this measures general visual similarity in CLIP's terms. For "is it the same person" you want a face-embedding tool, not this - CLIP will happily call two portraits of different people "similar" if the composition matches.
- It's per-pair: for "which of 500 images is closest to this one" you'd need the database path (Image Searcher). This node is for one-off checks.
And one honest note: a score of 1.0 doesn't mean pixel-identical. Two different photos of the same sunset can both land near the top. Think of it as "CLIP thinks these are the same kind of thing," which is exactly what you usually want.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| clip_vision_output1 | CLIP_VISION_OUTPUT | — | |
| clip_vision_output2 | CLIP_VISION_OUTPUT | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| SCORE | FLOAT | — |