Nodes/nsfw_no/Folders
ComfyUI Node

Folders

The folder loader that feeds this pack's NSFW gate — point it at a directory, get every image

By chaorenai·Created about a year ago·Updated about a year ago· 5
Folders
    • IMAGE
    • MASK
    • FILE PATH
    directory
    image_load_cap0
    start_index0
    load_alwaysfalse

    Folders is the sibling node in the nsfw_no pack, and the reason it exists is sitting right in the pack's example workflow: Folders → nsfw_No → SaveImage, screening every image in a directory in one pass. It's a batch folder loader - point it at a directory and it reads everything in there as a list of images, masks, and file paths.

    You already know this shape if you've used WAS Node Suite's batch loader or rgthree's Image Loader. This is the lean version that ships inside this pack, and it does the job with zero extra dependencies. Not a node you'll put in every workflow, but when you need to chew through a folder of PNGs it's exactly the tool.

    How it works. It lists the directory, keeps only .jpg, .jpeg, .png, .webp (the JXL support the author clearly toyed with is commented out in the source - don't expect JXL), sorts the files alphabetically, and loads each one with EXIF transpose applied so phone photos don't come out sideways. RGB conversion on load. If a file carries an alpha channel, that becomes an inverted mask (1 − alpha, so transparency reads as white); no alpha means a flat 64×64 zero mask. Each file also surfaces as a FILE PATH string, handy if you want the filename downstream.

    Three list outputs - IMAGE, MASK, FILE PATH. Wire IMAGE into nsfw_No's image input (the pack's whole reason to exist), or into SaveImage for a bulk render. MASK feeds compositing or upscaling stages; FILE PATH goes to a text/display node if you want to watch what's being processed.

    The inputs that matter:

    • directory - the one you must set. It's a plain string, no folder browser: paste something like C:\Users\you\output or /home/you/images.
    • image_load_cap - maximum images to load, 0 means no limit.
    • start_index - skip the first N sorted files, for resuming a partial batch.
    • load_always - the interesting one. ComfyUI caches aggressively and only re-runs nodes whose inputs changed; by default this node caches on a hash of its inputs, so files you drop into the folder won't be noticed until you touch the node. Flip load_always on and the node returns NaN from its IS_CHANGED, forcing a rerun every time - the standard always-dirty trick, with the standard cost: it invalidates the cache for everything downstream of it too. Leave it off unless you're actively adding files mid-run.

    Install. Same as the pack: ComfyUI Manager, search "nsfw_No", restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/chaorenai/nsfw_no
    

    Then restart ComfyUI. No model downloads for this node - the only heavyweight the pack pulls is transformers for the nsfw_No classifier.

    Where people get burned:

    • Empty or missing directory → hard FileNotFoundError. There's no UI picking, so a typo in the path is on you.
    • Not recursive. Subfolders are skipped - the code explicitly filters out anything that isn't a file.
    • Mask shape lies. Images without alpha get a 64×64 zero mask, images with alpha get a full-size one, so don't assume mask and image always match in size.
    • Sorting is by filename. 10.png sorts before 2.png. Zero-pad names if order matters to you.

    It's a small utility with a clear job, and in this pack it's really there to batch-feed the nsfw filter. Need recursive scanning, captions, or JXL and you'll outgrow it fast - that's WAS or rgthree territory. But for "screen this folder," it's right there and it works.

    Categorynsfw_No

    Inputs (4)

    NameTypeDefaultDescription
    directorySTRING
    image_load_capoptINT0
    start_indexoptINT00–18446744073709550000
    load_alwaysoptBOOLEANfalse

    Outputs (3)

    NameTypeDescription
    IMAGEIMAGE
    MASKMASK
    FILE PATHSTRING