Nodes/ComfyUI Emotional Gallery/Load Cached Emotion · ComfyUI Emotional Gallery
ComfyUI Node

Load Cached Emotion · ComfyUI Emotional Gallery

Get the preview you already made back into a graph as an image

By nikminer·Created about a month ago·Updated 15 days ago· 0
Load Cached Emotion · ComfyUI Emotional Gallery
    • image
    • positive_prompt
    ◄profile_id►
    ◄emotionneutral►

    The gallery generates a wall of faces and caches them. EGLoadCachedEmotion - Load Cached Emotion · ComfyUI Emotional Gallery - is how you get one of those faces back out, as an IMAGE you can wire into the rest of ComfyUI.

    Two inputs, two outputs, no file picker. This is the node that turns the gallery from a reference sheet you look at into a reference sheet you build on.

    Why bother

    A cached expression is a finished, seed-pinned, LoRA-consistent portrait of your character in a specific mood. That's the raw material for everything downstream: an img2img pass that changes the outfit while keeping the face, a reference image for an edit model, an upscale, a contact sheet, a comparison grid.

    The reason it's worth a dedicated node rather than "just open the PNG in Load Image" is the second output. Alongside the pixels, it hands you the exact positive prompt that produced them - trigger words, base prompt and expression phrase, composed in that order. So you're not reverse-engineering which of your 150 expressions you clicked three days ago. The prompt travels with the image.

    How it works

    The pack caches under ComfyUI/user/emotional_gallery/<profile_id>/ - one directory per saved "set", which means model files + LoRA + prompts + strengths + seed + sampling settings, hashed into a 32-character id. Each directory holds a manifest.json plus one PNG and one WebP thumbnail per expression.

    This node reads that structure directly. It validates profile_id against ^[0-9a-f]{32}$, loads the manifest, checks that emotion exists in the set, resolves the PNG's path (refusing anything that escapes the set directory), and converts it:

    • Opens the PNG with PIL as RGB, converts to float32, divides by 255.
    • Returns it as a tensor with a leading batch dimension - a batch of one, [1, H, W, 3].
    • Returns manifest["images"][emotion]["prompt"] as the second output: the stored prompt string, not a re-derived one.

    IS_CHANGED returns the resolved image path. Point the node at a different emotion or set and it re-runs; leave it alone and ComfyUI caches as usual. Unlike the writer, there's no always-dirty NaN here.

    Worth noticing: it reads the full-size PNG, never the thumbnail. So what you get out is what was generated, not a 320px card.

    Inputs and outputs

    • profile_id - the set id, as a hex string. Defaults to empty, which fails.
    • emotion - the expression id within that set. Defaults to neutral.
    • image - the IMAGE, out to VAEEncode, VAEEncodeForInpaint, an IP-Adapter/reference node, or a save node.
    • positive_prompt - a STRING, out to CLIPTextEncode if you want to reproduce the framing that generated it.

    Finding the profile_id

    This is the practical sticking point. The gallery panel knows the id; the node wants it typed in. You can get it from the directory listing itself, since the folder name is the id:

    cd ComfyUI/user/emotional_gallery
    python3 - <<'PY'
    import json, glob
    for p in glob.glob("*/manifest.json"):
        m = json.load(open(p))
        s = m["settings"]
        print(m["id"], "|", s.get("lora_name"), "|", len(m["images"]), "cached |", s.get("base_prompt", "")[:40])
    PY
    

    That prints every set with its LoRA, its cache count and the start of its base prompt - enough to pick the right one in a few seconds. If you use a custom ComfyUI user directory, run it there instead.

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/nikminer/ComfyUI-Emotional-Gallery.git comfyui_emotional_gallery
    

    Restart, Ctrl+F5. No Python packages beyond what ComfyUI has, no model downloads. The pack installs the node and the gallery together; the panel is where the cache gets filled, so you do need to have generated at least one set before this node has anything to read.

    File name for updates: keep the folder as comfyui_emotional_gallery.

    Common issues

    ValueError about the profile id, or a bare traceback. The id is wrong or empty. An empty profile_id is the default state and always fails - copy a real one from the listing above.

    "Unknown expression" / file-not-found. The set exists but that emotion was never generated, or a Generate missing run is still queued. Open the panel and check the card is actually filled in.

    The image is there but the prompt looks like a different expression's. It isn't re-derived - it's whatever was stored when that PNG was made. If you edited the expression definition afterwards, the cached prompt is the old one. Regenerate the card to refresh both.

    It worked yesterday, now it can't find the set. Deleting a set moves it to user/emotional_gallery/.trash/, and restoring it is a panel action. Delete and regenerate with different settings and you land on a new id.

    CategoryEmotional Gallery

    Inputs (2)

    NameTypeDefaultDescription
    profile_idSTRING—
    emotionSTRINGneutral—

    Outputs (2)

    NameTypeDescription
    imageIMAGE—
    positive_promptSTRING—