ComfyUI Node

GPM Gallery Browser

The node that browses your image folder like a tiny app

By Mystic419·Created 6 months ago·Updated 24 days ago· 1
GPM Gallery Browser
    • image
    • person_prompt
    • scene_prompt
    ◄root_folder►
    ◄current_subfolder►
    ◄selected_image_rel►
    ◄visible_rows3►
    ◄person_prompt_text►
    ◄scene_prompt_text►
    ◄prompt_profileSDXL►
    ◄randomize_modeMANUAL►

    Most ComfyUI nodes are a box with a few wires. This one is a box with a thumbnail grid inside it. You point it at a folder of images, click a tile, and it hands you back the picture plus the two prompt halves somebody - or some VLM - wrote about it.

    It's the node in this pack you'll actually open every session, and it's also the one with the most hidden machinery. Five minutes here saves an hour of "why is my prompt output empty".

    What it's for

    If you do the sidecar thing, you already have folders where every image has a .json twin holding structured prompt text. The sidecar convention exists because it's bulk-editable and inspectable - you can see at a glance which image is missing a caption. GPM's twist is that the sidecar holds two prompt halves per family: a person part and a scene part.

    That split isn't decoration. Separating the subject from the environment is the cheap version of the discipline people keep rediscovering for scene control: attribute binding is what models actually get wrong, and person/place is the boundary it goes wrong across. It also means one photo with a great pose can be recombined with a dozen backgrounds, because the halves live in different fields.

    How it works

    The node serves its own listing (/gpm/gallery/list) rather than dumping a directory walk into the graph, so it behaves like a real filesystem browser: one folder at a time, folders sorted first, alphabetical. Navigation is walled in - you can't climb above the root you set. Clicking a tile reads the sibling JSON for the active profile and refills the text areas.

    Two surprises:

    Every widget is hidden. The front end hides root_folder, current_subfolder, selected_image_rel, visible_rows, person_prompt_text, scene_prompt_text, prompt_profile and randomize_mode, then draws its own controls instead - tile grid, rows selector, selection-mode dropdown, profile dropdown, back button, "Save to JSON". The widget values still exist and still matter, because that's what a queued or API-driven run reads, but you won't see them in the node body.

    Selection advances on queue, not on click. MANUAL means you pick tiles. SEQUENTIAL walks to the next visible image in folder order each execution. RANDOM shuffles the visible images and works through the whole shuffled list once before anything repeats. Both automated modes force a re-run every execution, and when they advance they load that image's prompts for you. Per-node state - folder, subfolder, position - is saved to gpm_gallery_state.json beside the pack's Python files.

    Inputs that matter, and the outputs

    • root_folder - absolute path to your top-level image folder. No root, no gallery.
    • current_subfolder - relative path; blank means root. Invalid values silently reset to root.
    • selected_image_rel - relative path of the selected image.
    • visible_rows - 1 to 6; how many rows of tiles show at once. Cosmetic, but 6 rows on a big node is how you actually scan a folder.
    • prompt_profile - SDXL, Pony or Natural Language. Picks the live key pair: sdxl_person/sdxl_scene, pony_person/pony_scene, or natural_person/natural_scene.
    • person_prompt_text / scene_prompt_text - the editable buffers. Type in them and the outputs change for that run; press Save to JSON and the active profile's two fields get written back to the sidecar, with every other key preserved.
    • randomize_mode - MANUAL, SEQUENTIAL or RANDOM.

    Outputs: image (a real IMAGE tensor - wire it into img2img, an upscaler, a video node), person_prompt and scene_prompt (STRING). The two strings go into GPM Prompt Combiner, or straight into a CLIPTextEncode.

    Install

    ComfyUI Manager, search Gallery Prompt Manager (Registry name gallery-prompt-manager), or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Mystic419/GPM-for-ComfyUI GPM
    cd GPM
    python -m pip install -r requirements.txt
    

    requirements.txt is Pillow and nothing else. llama-cpp-python is the pack's real dependency, which is what install.py exists for - you only need it if you're also scanning with the internal VLM nodes. If somebody else's scan already populated the folder, Pillow is genuinely the whole story. Restart ComfyUI either way.

    Where people get burned

    • The blank prompt. If the sidecar is missing, unreadable, or lacks keys for the profile you selected, the outputs are empty strings - no error. Nine times out of ten this is a folder scanned as Pony while the dropdown says SDXL.
    • A folder that moved. If root_folder doesn't exist or isn't a directory, the node drops its whole state rather than complaining.
    • Queued runs use saved state, not your widgets. Deliberate - it's how SEQUENTIAL automation advances - but editing selected_image_rel by hand won't stick unless the persisted state agrees.
    • Edits are per-run until you save. Changing the text areas changes that execution's outputs; nothing hits the file until Save to JSON, and that save only touches the active profile's pair.

    Worth saying plainly: this pack is new and has almost no community footprint yet, so there's no crowd that's already hit your weird edge case. Keep a test folder, run with SKIP_EXISTING until you trust it, and read the nodes.

    CategoryGPM

    Inputs (8)

    NameTypeDefaultDescription
    root_folderSTRING—
    current_subfolderSTRING—
    selected_image_relSTRING—
    visible_rowsINT31–6—
    person_prompt_textSTRING—
    scene_prompt_textSTRING—
    prompt_profileSTRINGSDXL—
    randomize_modeSTRINGMANUAL—

    Outputs (3)

    NameTypeDescription
    imageIMAGE—
    person_promptSTRING—
    scene_promptSTRING—