Nodes/ComfyUI-HQ-Image-Save/Load Image And Prompt
ComfyUI Node

Load Image And Prompt

Load an image and its caption in one step

By spacepxl·Created 3 years ago·Updated 6 months ago· 102
Load Image And Prompt
    • image
    • prompt
    • filename
    filepathpath to directory
    index0

    This node is the counterpart to the pack's "Save Image And Prompt" nodes, and it exists for one clean reason: when you save an image next to a .txt file containing its prompt, eventually you want to load them together again. Point it at a folder, pick an index, and it hands you the image, the prompt text, and the filename - all three at once, no manual copy-paste.

    The workflow it enables: iterate on an image, save it with its prompt, then reload the pair to feed an img2img pass, review a batch, or check what you were thinking three days ago. And for training-data collection, it's the reader half of a dataset loop - the save nodes write the pairs, this node consumes them.

    How it works

    Give it a filepath (a directory) and an index (which file in that folder). It globs the folder for images - .jpg, .jpeg, .png, and .exr - sorts them, picks the one at index, then looks for a .txt file with the same base name and reads it as the prompt. Handles 8-bit, 16-bit, and float EXR sources and normalizes them to the 0–1 range the graph expects.

    Outputs: image (IMAGE), prompt (STRING), and filename (the full path, as a string - handy if you're logging or renaming downstream). Feed image into an img2img encoder or a VAE encode, feed prompt into a positive conditioning text box, and you've reconstructed the state of an old generation.

    The gotcha, and it's a real one

    There's no error handling around the .txt read. If a matching sidecar doesn't exist, the node throws, and it throws hard - no graceful "skip this one." So before you run it over a folder, make sure every image has its .txt beside it, or the load dies on the first gap. It also assumes the prompt file is exactly <image basename>.txt, so the naming convention matters; if your captions use a different suffix, they won't be found.

    Two more small things: the order is just alphabetical glob order, so index is stable but you're indexing a sorted list, not a natural frame order - know your folder. And while it can read EXR images, it doesn't tonemap them (no tonemap input); a linear EXR will come back looking flat, which is fine for processing and wrong for eyeballing.

    Install

    Same pack as the save side: ComfyUI Manager → search ComfyUI-HQ-Image-Save → install → restart, or git clone https://github.com/spacepxl/ComfyUI-HQ-Image-Save into custom_nodes/. Dependencies are imageio and opencv-python, no models.

    The natural pairing

    SaveImageAndPromptIncremental writes image + .txt pairs with colliding-proof numbering; this node reads them back. Together they're a training-data or archival pipeline with zero Python. The pair is under-documented (neither appears in the pack's README, which only covers the EXR/latent nodes), so you found them the same way everyone does - scrolling the node list.

    CategoryHQ-Image-Save

    Inputs (2)

    NameTypeDefaultDescription
    filepathSTRINGpath to directory
    indexINT0

    Outputs (3)

    NameTypeDescription
    imageIMAGE
    promptSTRING
    filenameSTRING