Nodes/comfyui-dreambait-nodes/Compare Image Similarity πŸ”
ComfyUI Node

Compare Image Similarity πŸ”

Find the look-alike in your image folder

By drmbtΒ·Created 2 years agoΒ·Updated 7 months agoΒ· 6
Compare Image Similarity πŸ”
  • input_image
  • image
  • mask
  • FILE_PATH
  • FILE_NAME
  • SIMILARITY_SCORE
β—„folder_pathβ€”β–Ί
β—„similarity_methodcosineβ–Ί
β—„resize_imagesfalseβ–Ί
β—„return_best_n1β–Ί
β—„use_cachetrueβ–Ί
β—„force_refresh_cachefalseβ–Ί
β—„debug_modefalseβ–Ί

Compare Image Similarity answers a surprisingly common question: "I have this image, and I have a folder of a thousand others - which ones look the most like it?" You feed it one image and a folder path, and it returns the closest matches as actual IMAGE outputs, plus the file paths and similarity scores so you know exactly what you got and why.

What it actually does

The inputs are mercifully few: input_image, folder_path, and the settings that matter:

  • similarity_method - cosine (angle between feature vectors, the default) or euclidean (distance-based). Cosine is the usual pick; it's more forgiving of brightness/scale differences.
  • return_best_n - how many top matches to return (1–100).
  • resize_images - default False, meaning matches come back at original resolution. That's the author's recommendation, and it's right: the search can run on tiny thumbnails while you still get full-quality output.
  • use_cache / force_refresh_cache - embeddings are cached to ComfyUI's temp directory (keyed by a hash of the folder path) so re-running the same search on the same folder is instant. force_refresh_cache nukes the cache if files changed but the cache didn't notice.

Outputs: image, mask (an empty mask in the shape of the image, ready for compositing), FILE_PATH, FILE_NAME, and SIMILARITY_SCORE.

The honest caveat

Here's the part the README doesn't shout: this isn't a learned semantic embedding. The source resizes every image to 224Γ—224 and flattens the pixels into a raw feature vector - no CLIP, no ViT, no neural network. That means it's good at finding visually similar images: near-duplicates, same composition, same color grading, crops of the same shot. It will not understand that a beach photo and a "sunset, sand, ocean" painting are conceptually related - for that you'd need a CLIP-based matcher. If your use case is "dedupe my output folder" or "find the original this was edited from," it's great. If you expected semantic similarity, set expectations accordingly. The caching is real though: use_cache bakes a pickle of all the folder features, so subsequent runs on the same folder skip the re-encode entirely.

Installing and using

It ships in the drmbt/comfyui-dreambait-nodes grab-bag. ComfyUI Manager: search "comfyui-dreambait-nodes". Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/drmbt/comfyui-dreambait-nodes

then restart ComfyUI. Note the pack bundles heavy deps (transformers, bitsandbytes, librosa) that this node never touches - that's the cost of the bundle. If you hit a wall, the debug_mode toggle exists for exactly this: it dumps detailed logging so you can see which folder files failed to load (corrupt images get skipped with a warning, not a crash).

Worth it if you keep a big reference folder. Just remember it's pixel-similarity, not a semantic search.

Categoryimage

Inputs (8)

NameTypeDefaultDescription
input_imageIMAGEβ€”
folder_pathSTRINGPath to folder containing images to search through.
similarity_methodCOMBOcosineMethod to calculate similarity: cosine for angle-based similarity, euclidean for distance-based.
resize_imagesBOOLEANfalseIf True, resize output images to match input image dimensions. If False, keep original dimensions (recommended).
return_best_nINT11–100Return the N most similar images.
use_cacheBOOLEANtrueUse cached embeddings for faster processing. Cache is only recalculated if folder contents change.
force_refresh_cacheBOOLEANfalseForce recalculation of embeddings regardless of cache.
debug_modeBOOLEANfalseEnable detailed debug logging for troubleshooting.

Outputs (5)

NameTypeDescription
imageIMAGEβ€”
maskMASKβ€”
FILE_PATHSTRINGβ€”
FILE_NAMESTRINGβ€”
SIMILARITY_SCOREFLOATβ€”