ComfyUI Node

DB Load Node

Your reference image, but found by vector search instead of a folder

By Santat2023·Created 12 months ago·Updated 26 days ago· 0
DB Load Node
    • Pose image
    • Style image
    pose_query
    pose_collection
    style_query
    style_collection

    This is the retrieval half of a small RAG experiment. You feed it a text query, and it goes and finds you an actual image - not by matching a filename, but by embedding your text with CLIP, searching a Qdrant vector database, and pulling the top hit out of a MinIO/S3 bucket. Out come two IMAGE tensors, one meant for ControlNet (pose) and one for IP-Adapter (style).

    Honest framing first: this pack is a Russian-language diploma project ("RAG for illustrators"), a proof of concept rather than a production tool. It has effectively zero community footprint - nobody is sharing workflows built on it. You're not here because it's popular; you're here because it's the cleanest public example of the idea: use an LLM to split a prompt into search queries, then retrieve real references instead of guessing. Treat it as a blueprint you can steal from.

    How it works

    The DB Load Node takes the two query strings produced by its sibling, the LLM Node. For each one it runs the same pipeline, straight from the source (services/retrieval_service.py):

    1. ClipModel.embed_text() encodes your query with OpenAI's CLIP ViT-B/32 (this loads openai/clip from pip and downloads the weights on first use).
    2. Qdrant searches the collection you picked, limit=1 - the single nearest vector.
    3. It builds a key from the hit's ID plus its filename payload and fetches those bytes from S3 (get_image_bytes).
    4. The bytes get decoded into a standard ComfyUI float IMAGE tensor.

    The CLIP model is baked in - you don't choose it, and it's the same encoder family that embedded the images when they were indexed, which is the whole trick of this working at all.

    The inputs and outputs that matter

    Four inputs, all required:

    • pose_query and style_query - plain STRING sockets with forced inputs. They're designed to be wired from the LLM Node's pose_query / style_query outputs, not typed by hand.
    • pose_collection and style_collection - dropdowns listing the collections Qdrant actually has. Watch for the sentinel values: if Qdrant is unreachable when the node loads, the only choice is no_collections_found. If it's reachable but empty, you get empty_collection.

    Outputs: Pose image and Style image, both IMAGE. Wire pose into a ControlNet Apply node, style into an IP-Adapter Apply - that's the intended graph.

    Installing it

    Via ComfyUI Manager, search for the pack title ComfyUiRagCustomNodes, or clone it:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Santat2023/ComfyUiRagNodes.git
    

    Then restart ComfyUI and look under the MyNodes category. The hard part isn't the install, it's the surroundings: the node does nothing until you have Qdrant running on localhost:6333, MinIO on localhost:9000, and - critically - an actual indexed collection. Collections are created by the author's separate ImageManager app, which captions your images and embeds them; without it, there's nothing to search.

    There's no requirements.txt in the repo, so dependencies are on you: qdrant-client, boto3, openai-clip, requests, Pillow. Expect to pip install them yourself.

    Where people get burned

    • The MinIO credentials are hardcoded. In nodes/db_load_node.py the S3 client is created with minioadmin / minioadmin, http://localhost:9000, bucket images. There's no config for this - if your MinIO has real credentials, you're editing source.
    • The collection list is frozen at load time. INPUT_TYPES queries Qdrant when the node class loads, so a collection you create mid-session won't appear until you reload ComfyUI.
    • A missing collection just throws. Search a collection that doesn't exist and the node errors - there's no graceful "no results" path.
    • Search only ever returns the top-1 hit, so garbage in the index means garbage reference. The quality ceiling here is set by ImageManager's captions, not by anything in this node.

    If you just want a reference image in your graph, honestly, drag a file in. This node earns its keep only when you've built out the whole retrieval stack - and then it's a genuinely neat demo of the pattern.

    CategoryMyNodes

    Inputs (4)

    NameTypeDefaultDescription
    pose_querySTRING
    pose_collectionCOMBO1 options: no_collections_found
    style_querySTRING
    style_collectionCOMBO1 options: no_collections_found

    Outputs (2)

    NameTypeDescription
    Pose imageIMAGE
    Style imageIMAGE