Nodes/Comfyui-SAL-VTON/Random Image From Directory
ComfyUI Node

Random Image From Directory

Grab a random test photo (and mask) from a folder for SAL-VTON runs

By ratulrafsan·Created 2 years ago·Updated 2 years ago· 92
Random Image From Directory
    • IMAGE
    • MASK
    folder_path./input

    If you're testing a SAL-VTON clothing-swap workflow, you'll get tired fast of clicking through a folder of garment or model photos and re-wiring LoadImage every time. SV_random is the boring, useful fix: point it at a folder, hit queue, and it hands you back one random image (and a mask) from that folder each run. That's the whole job. It's not part of the try-on model - no landmark detection, no warping, no checkpoint loading - it's a directory browser wearing an IMAGE/MASK plug, shipped alongside the real SAL-VTON node so you have something to feed it with while you iterate.

    Think of it as a batch-testing convenience, not a production component. You'd wire it up while you're figuring out whether SAL-VTON handles your particular garments and body photos well, then swap in real, curated inputs (with a proper garment mask - see the SALVTON_Apply article) once you know what works.

    The one input that matters

    There's exactly one field, and it's the whole interface:

    • folder_path (STRING, default ./input) - where to pull images from. The default points at ComfyUI's own input/ directory; point it anywhere else (an absolute path, or a dataset folder of garment shots) to sample from that instead.

    No optional inputs, no toggles for file type or seed control - you take what the folder gives you.

    Outputs: IMAGE and MASK

    The node returns an IMAGE and a MASK. The pack's own docs don't spell out how the mask gets derived - whether it's reading a paired mask file sitting next to the source image, generating one on the fly, or something else - so treat it as a convenience pairing rather than a guaranteed, production-quality mask. That matters because SALVTON_Apply's garment_mask input is typed IMAGE, not MASK, so this node's MASK output doesn't drop straight into it anyway - you'd need a mask-to-image conversion in between, or you're better off generating the garment mask deliberately (rembg or SAM, per the pack's own recommendation) rather than relying on whatever SV_random happens to give you.

    How to install it

    Same pack, same steps as SALVTON_Apply - you get both nodes from one install. Via ComfyUI Manager: search "Comfyui-SAL-VTON", install, restart. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/ratulrafsan/Comfyui-SAL-VTON
    cd Comfyui-SAL-VTON
    pip install -r requirements.txt
    

    Make sure you're inside the ComfyUI venv when you run that pip install - the README calls this out explicitly, and it's an easy thing to skip if you've got multiple Python environments floating around.

    One thing worth knowing: SV_random itself doesn't need the three downloaded SAL-VTON checkpoints (landmark.pth, warp.pth, pytorch_model.bin). It's pure file I/O. You only need those once you wire its output into SALVTON_Apply, which - let's be honest - is the actual reason anyone installs this pack.

    Common issues & troubleshooting

    The path doesn't resolve where you expect. folder_path is evaluated relative to wherever the ComfyUI process is running from, not relative to your workflow file or your browser tab. If you're running on a hosted or serverless setup rather than a local install, remember the folder has to actually exist with files in it in that execution environment - a path that makes perfect sense on your laptop won't magically show up on a remote worker unless the files got there some other way.

    Empty or missing folder. If folder_path points at a directory with no images (or doesn't exist), there's nothing for the node to pick from and it has nothing to output - check the path is right and actually has image files in it before you assume the node is broken.

    Don't expect it to hand you a ready garment mask. As above - the MASK output here is a convenience, and SALVTON_Apply wants its mask fed in as an IMAGE anyway. If your results look off, check whether you're actually feeding SALVTON_Apply a proper garment mask or just whatever SV_random happened to attach.

    CategoryClothing - SAL-VTON

    Inputs (1)

    NameTypeDefaultDescription
    folder_pathSTRING./input

    Outputs (2)

    NameTypeDescription
    IMAGEIMAGE
    MASKMASK