Nodes/comfyui-CLIP-Search/CLIP Image Search
ComfyUI Node

CLIP Image Search

Type \"sunset over the ocean\" and actually find the image — this node searches your whole library with CLIP

By pointave·Created 4 months ago·Updated 4 months ago· 0
CLIP Image Search
    • Image
    • Path
    • all_result_paths

    You know the feeling: 4,000 images across three folders, and the exact reference you need is in there somewhere. The CLIP Image Search node (CLIPSearchNode, from pointave's comfyui-CLIP-Search pack) fixes that by letting you search your image library in plain language, right inside ComfyUI. Type "red car on a dirt road" and it shows you the matches. No external tool, no manual tagging, no renaming spree you'll abandon by Tuesday.

    Here's the thing that makes it work: it's not OCR, not tags, not filename matching. It's CLIP doing math. The same text encoder that reads your prompts understands that "sunset over the ocean" and a photo of an orange sky meeting a horizon are similar - they land near each other in embedding space. This node leans on exactly that, the way the KB's prompt-engineering and concepts essays explain CLIP's role in the whole SD ecosystem: an embedding is just a vector at a fixed dimensionality, and similarity is a dot product.

    How it works

    On "Embed Folder," the node walks the folder (with a subfolder toggle), runs every image through OpenAI's CLIP (ViT-L-14, pretrained laion2B-s32B-b82K - roughly 1.7 GB, downloaded to your HuggingFace cache on first use), and stashes the resulting embeddings in a .comfyui_clip_cache folder next to your images. That's the clever part: embedding is the slow step, but it runs once and is cached to disk, so every search after that is just encoding your query text and computing dot products. The cache invalidates automatically when the image count on disk changes; "Re-embed" forces a full refresh.

    The heavy lifting runs through open-clip-torch, a separate dependency this pack adds - which is why it's a one-pip-install situation rather than working out of the box.

    The controls and outputs

    Almost everything here lives in the node's own GUI rather than as input ports, so don't go looking for a folder widget on the canvas. In the panel you get: the folder path (with favorites), Embed Folder, a search box, the đźš« Exclude bar for filtering out unwanted matches, and a similarity threshold slider (default 0.15 - lower it if a search returns nothing). Results show in a masonry gallery; click one to make it the output.

    The actual wiring is on the output side, and there are three:

    • Image (IMAGE) - the selected (or randomly picked) image as a tensor, ready to pipe into any node.
    • Path (STRING) - the full file path of that image.
    • all_result_paths (STRING) - every matched path in one string. Small gotcha: the README calls this "newline-separated," but the current code hands back a JSON array - either way, feed it to a text node and you're set.

    There's also a 🎲 random button and a hidden random seed, so the node doubles as "pick me a random image from this folder" if that's your jam.

    Install

    Two routes, pick one:

    # ComfyUI Manager: search "comfyui-CLIP-Search" and install
    # or, manually:
    cd ComfyUI/custom_nodes
    git clone https://github.com/pointave/comfyui-CLIP-Search
    pip install open-clip-torch   # the one real dependency
    

    Restart ComfyUI. First search triggers the ~1.7 GB model download, so do it once before you need it, not mid-workflow.

    Where people get burned

    • VRAM. The author is upfront: the CLIP model can stay partially loaded after you're done, even after embedding. Hit the đź—‘ Unload Model button, or flip the ⏻ auto-unload toggle if you'd rather not think about it.
    • Huge folders. Embedding thousands of images takes a real while and will hog your GPU. The README's advice if you accidentally embed a monster folder: just restart ComfyUI. Fair.
    • The dependency. Forgot open-clip-torch? You'll hit an import error on load. That's the #1 install failure, and it's a one-liner to fix.
    • Nothing matches. That threshold slider is your friend - a too-high threshold on a broad query returns nothing, and the node silently falls back to the whole folder.

    It's not a full digital-asset manager - it's a single-node, "find the thing" tool for people who'd rather search than sort. For that, it genuinely works, and once the embeddings are cached, searches are effectively instant.

    Category🔍CLIP/Search

    Inputs (0)

    No inputs

    Outputs (3)

    NameTypeDescription
    ImageIMAGE—
    PathSTRING—
    all_result_pathsSTRING—