Nodes/ComfyUI-GPT4V-Image-Captioner/Samin Load Image Batch
ComfyUI Node

Samin Load Image Batch

Stop hand-wiring one image at a time

By 438443467·Created 3 years ago·Updated about a year ago· 27
Samin Load Image Batch
    • image
    • filename_text
    • image_path
    • isTrue
    mode
    index0
    labelBatch 001
    path
    pattern*
    allow_RGBA_output
    rename_images
    image_number0
    filename_text_extension

    If you're captioning a dataset with this pack's GPT4V node, or running the same workflow over a folder of images, you do not want to be clicking "Load Image" for each file. This node is the batch front-end: point it at a folder, tell it how to step through the files, and it hands you an image plus its filename and path on every queue run. It's a slimmed-down cousin of WAS Suite's "Load Image Batch" - the code is literally derived from it - and it pairs beautifully with SanmiSaveImageToLocal to make a caption-one-folder loop.

    How it works

    You give it an absolute path and a glob pattern (default *). It scans the folder for images (jpeg, png, tiff, gif, bmp, webp), sorts the paths, and picks a file according to mode:

    • single_image - the file at index.
    • incremental_image - the next file each time the graph runs; it wraps around at the end.
    • number_image - finds the file whose name begins with the digits in image_number (it strips everything after the first comma, then any non-digits). This is the mode you use with Samin Counter.
    • random - a random file per run.

    The trick under the hood: it keeps its position per-label in a small JSON "database" (was_suite_settings.json) in the pack folder. Change the label and the counter resets - a handy way to run two independent scans over the same folder. It also applies EXIF orientation so phone photos come out the right way up.

    Inputs and outputs

    You'll realistically touch path, pattern, mode, index or image_number, and label. allow_RGBA_output (default false) converts to RGB - flip to true if you need transparency preserved. rename_images (with number_image mode) renumbers the files in the folder to 000.ext, 001.ext, ... so the digit lookup has something to match - it skips if files are already numeric, and it does rename on disk, so be careful.

    Outputs: image (the loaded IMAGE), filename_text (the file's basename, or without extension if you set the optional filename_text_extension to false), image_path (full path - only populated in number_image mode), and isTrue, which is 1 when a numbered image was found and 2 when it wasn't (in which case you get a 512×512 black image back). Wire isTrue into SanmiSaveImageToLocal's isTrue input and missing images silently skip the save - that's exactly what the pairing is for.

    Gotchas

    The node returns None for the image when a single/incremental/random lookup fails, which can blow up whatever's downstream - check your path and pattern first. The counter state is global, so two workflows sharing a label share a counter. And read this before you panic: the current repo no longer ships this node. The pack was rewritten in April 2025 and now contains only the GPT4V captioner; these "Sanmi Simple Nodes" live only in the repo's history (the old Load_Image_Batch.py). A fresh install won't show it in your node list.

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/438443467/ComfyUI-GPT4V-Image-Captioner
    

    Restart ComfyUI. No model downloads, and the dependency list is short (Pillow, torch, numpy). For the full folder-captioning loop you'd pair this with SanmiSaveImageToLocal and the captioner - and keep a copy of the old Load_Image_Batch.py around if you rely on it.

    CategorySanmi Simple Nodes/Simple NODE

    Inputs (9)

    NameTypeDefaultDescription
    modeCOMBO4 options: single_image, incremental_image, number_image, random
    indexINT00–150000
    labelSTRINGBatch 001
    pathSTRING
    patternSTRING*
    allow_RGBA_outputCOMBO2 options: false, true
    rename_imagesCOMBO2 options: false, true
    image_numberINT00–150000
    filename_text_extensionoptCOMBO2 options: true, false

    Outputs (4)

    NameTypeDescription
    imageIMAGE
    filename_textSTRING
    image_pathSTRING
    isTrueINT