ComfyUI Node

TK Batch Image Loader

The folder feeder that gets a batch captioning run started

By tackcrypto1031·Created 8 months ago·Updated 6 months ago· 2
TK Batch Image Loader
    • image_paths
    source_pathC:/input_images
    output_pathC:/output_images
    filename_prefiximage_
    resize_mpfalse
    img_mp1.0
    resize_pxfalse
    img_px1024

    TK Batch Image Loader is the front door of this pack, and it's deliberately not a normal image loader. It doesn't hand you IMAGE tensors to wire into a sampler. It reads every image in a folder, renames them image_1.png, image_2.png, … and copies them into an output folder, then hands you back a LIST of file paths. That list is exactly what the batch interrogators in this pack - TK QwenVL Interrogator, TK JoyCaption Interrogator, TK WD14 Tagger - want on their input. Think of it as a filesystem pipeline stage: you don't get pixels, you get a manifest.

    How it works

    It lists source_path for the usual extensions (jpg, jpeg, png, bmp, webp), sorts them alphabetically so order is stable, and processes each one in turn. Two notes on scope: it only reads the top level of the folder - no recursion into subdirectories - and the "renaming" is really a copy into output_path under the new name, not an in-place rename.

    There are two resize modes, and the pack's own UI code makes them mutually exclusive - flip one on and the other quietly switches off, so you can't feed both:

    • resize_mp - scales to a total pixel count, img_mp in megapixels (default 1.0). Handy for normalizing a mixed-resolution folder down to a uniform budget before a VLM eats it.
    • resize_px - scales the longest edge to img_px (default 1024), keeping aspect ratio.

    Both resize with PIL's LANCZOS, and if a resize throws an error the node falls back to a plain copy instead of killing your batch. If both toggles are off, this is a pure rename-and-copy stage.

    The inputs that matter

    You really only set three things:

    • source_path - where the original images live.
    • output_path - where renamed images land (created if missing).
    • filename_prefix - default image_, so you get image_1.png, image_2.png, …

    Everything else is optional resize behavior. The single output, image_paths (LIST), plugs straight into TK QwenVL Interrogator's image_paths input. On Windows, the defaults are C:/input_images and C:/output_images - if you don't change them, nothing happens and you'll wonder why.

    Installation

    cd ComfyUI/custom_nodes
    git clone https://github.com/tackcrypto1031/tk_comfyui_imageVL.git
    cd tk_comfyui_imageVL
    pip install -r requirements.txt
    

    Then restart ComfyUI. ComfyUI Manager works too - search the pack title tk_comfyui_imageVL. The loader itself only needs the base deps (Pillow is there), but the pack's requirements.txt pulls the full set (transformers, qwen-vl-utils, accelerate, huggingface-hub, sentencepiece, pandas, and onnxruntime for the tagger), so you get everything in one shot.

    Where people get burned

    • No subfolders. Throw a folder of folders at it and you'll only see the top level. Flatten first.
    • Resize re-encodes. If resize_mp or resize_px is on, the images in output_path are resized JPEG/PNGs, not originals. If you want byte-identical files, leave both toggles off.
    • Stale paths. This is a batch-stage node, not a sampler feeder. If you expected an IMAGE output to preview or upscale, grab the single-image nodes from this pack instead - or a normal Load Image.

    It's a simple tool doing a simple job, and for a folder of images headed into a VLM batch it's exactly the right opening move.

    CategoryTK/Image

    Inputs (7)

    NameTypeDefaultDescription
    source_pathSTRINGC:/input_images
    output_pathSTRINGC:/output_images
    filename_prefixSTRINGimage_
    resize_mpBOOLEANfalse
    img_mpFLOAT1.00.1–100
    resize_pxBOOLEANfalse
    img_pxINT102464–8192

    Outputs (1)

    NameTypeDescription
    image_pathsLIST