Nodes/Local Gallery/本地图库浏览器 (Local Gallery)
ComfyUI Node

本地图库浏览器 (Local Gallery)

Point one node at a folder and ComfyUI runs all of it

By wanet36·Created about a month ago·Updated 13 days ago· 0
本地图库浏览器 (Local Gallery)
    • images
    • prompts
    • filenames
    ◄folder_path►

    Core ComfyUI gives you LoadImage: one file, one dropdown, one prompt for the whole run. For a single render that's fine. For the other thing - a folder of 300 training images with .txt captions next to them, or a batch of old renders you want to upscale each with its own original prompt - it's useless. You end up duplicating nodes until the graph looks like a spreadsheet.

    Local Gallery is the fix: a real file browser painted inside the canvas. Waterfall grid of thumbnails, hover one and it shows the caption, click the ones you want, and the node spits them out as lists that downstream nodes chew through one at a time.

    What it is, and where it came from

    The __init__.py says it plainly: this is DanbooruGalleryNode with the data source swapped, from Danbooru's live tag API to a folder on disk.

    Which makes it a dataset tool more than a gallery tool. The same-basename sidecar convention - 0001.png plus 0001.txt - is the caption format every trainer reads, kohya through OneTrainer. Point this at a LoRA folder and you get a caption-aware preview panel and a batch driver in one. Fully offline, no key, no account.

    How it works

    The node is an output node with three list outputs. Your clicks live in a hidden widget the JavaScript panel writes into; the visible folder_path field holds the path list. On execute, run() builds a cross-folder index of sidecar names (so images in output/ can pair with captions in output/prompts/), loads each selected image into a [1,H,W,3] float32 tensor, reads the prompt from the sidecar, applies your tag exclusions, and returns parallel lists.

    OUTPUT_IS_LIST = (True, True, True) is the whole trick. ComfyUI doesn't batch these into one tensor - it runs everything downstream once per item, in click order. A KSampler wired to this fires N times with N different prompts, and mixed resolutions are fine, which is a real advantage over ImageBatch (that one demands matching dimensions).

    It invalidates its cache sensibly too: selection, image mtimes and sidecar mtimes all sit in the change signature. Edit a caption, queue, get the new text.

    The input and outputs that matter

    One input: folder_path - a multiline string holding image folder paths or single image paths; newlines, semicolons and pipes all separate them. In practice you won't type in it: the panel's settings (⚙) → browse flow writes into it and the widget is hidden in the UI. Typing still works when you're hand-building JSON.

    Outputs, all lists:

    • images → VAE Encode, or straight into an upscaler's image input.
    • prompts → CLIP Text Encode. This is the payoff: per-image prompts, correct pairing, no spreadsheet.
    • filenames → main filename, extension stripped. Convert SaveImage's filename_prefix to an input and wire this in; outputs come back named after their source.

    One behaviour worth knowing: filenames follows whichever tab you're parked on, and if you're on the prompt tab the node outputs prompts only with images empty. An empty list means the image branch downstream never runs, so "I selected captions and nothing happened" is usually that.

    Installing it

    Through Manager: search local-gallery or Local Gallery (it's on the Comfy Registry too, though a fresh release can take a few minutes to clear review). Or clone it:

    cd ComfyUI/custom_nodes
    git clone https://github.com/wanet36/ComfyUI-LocalGallery.git
    

    Restart, then right-click the canvas → local gallery → 本地图库浏览器 (Local Gallery).

    pyproject.toml lists dependencies = []. No pip step, no torch version roulette - it uses the Pillow/numpy/torch ComfyUI already has. The optional captioning tab borrows other packs (WD14-Tagger, z-tipo-extension, comfyUI-llama-TE plus a gguf in models/LLM), but none of that is needed to browse, select and output.

    Where people get burned

    The silent black image. Select nothing and the node returns a 64×64 black placeholder with an empty prompt and name instead of erroring. Same for any image larger than max_image_side (8192 default) - the README says those are "skipped", but the shipped code substitutes the placeholder, so you get a black square rather than a warning. Check for a mystery 64px frame before debugging your sampler.

    Your folder isn't there. It reads the filesystem of the machine running ComfyUI, not the one your browser is on - and the Windows folder-picker dialog pops on the server, too. The README explains the built-in browser exists precisely because portable python_embeded ships without tkinter.

    Missing prompts. Only same-basename sidecars count; embedded PNG metadata is deliberately ignored, which is right for datasets and surprising if you expected your old generation prompts to appear. A .txt with no matching image never shows in the grid - the status bar counts those, and the prompt tab has an orphan bucket for them. And the list is a scan-time snapshot: new renders need a re-scan, it doesn't watch the disk.

    Exposure. It registers unauthenticated HTTP routes that can list, read, trash and reveal files, and allowed_roots defaults to empty = any path on the box. Fine locally; if your ComfyUI port faces the internet, set allowed_roots and turn allow_delete off.

    Reach for it when your work involves folders. If you pick one image at a time, LoadImage is still the right node and this is just a nicer viewer.

    Categorylocal gallery

    Inputs (1)

    NameTypeDefaultDescription
    folder_pathSTRING图片文件夹路径 / 单张图片路径。支持多行,每行一个路径(换行、分号、竖线都能分隔)

    Outputs (3)

    NameTypeDescription
    imagesIMAGE—
    promptsSTRING—
    filenamesSTRING—