Nodes/nsfw_no/nsfw_No
ComfyUI Node

nsfw_No

An on-rail NSFW gate for ComfyUI that swaps in your own fallback image

By chaorenai·Created about a year ago·Updated about a year ago· 5
nsfw_No
  • image
  • backup_image
  • IMAGE
score0.90

The name is a small lie: nsfw_No doesn't refuse anything. It looks at each image flowing through, asks a classifier "is this nsfw?", and if the answer is yes it quietly swaps in an image of your choosing - a placeholder, a logo, a black box - before the batch moves on. It's a gate, not a censor, and it needs no API key and no config file.

Why you'd reach for it: you've got a pipeline that occasionally wanders into content you don't want saved to disk, shown to a client, or output at all. Maybe you're screening a folder of generations before publishing, maybe you're building a workflow a non-technical person will run unattended, maybe you just want a guardrail so whatever lands in your output folder is something you're comfortable looking at. It's a niche job, and honestly most people in this hobby are doing the opposite of filtering - but when you need a filter, you want it boring.

How it works. Under the hood it's one Hugging Face transformers image-classification pipeline pointed at Falconsai/nsfw_image_detection. That's a ViT fine-tuned on nsfw content, and it's not an obscure model: it's the same classifier the official Flux repo ships as its safety gate, at a threshold of 0.85. So the mechanism is battle-tested, which is exactly what you want from a filter. The checkpoint (~340MB) auto-downloads to your HF cache on first use; after that it's held in memory, so subsequent passes cost nothing.

For each image in the batch the node runs the classifier and flags it as nsfw if the "nsfw" label's confidence beats your score threshold. Flagged images are replaced with the fallback; the rest pass through untouched. Batch size and order are preserved - nothing is dropped, nothing is reordered.

The inputs that matter:

  • image - your batch. Feed it an image loader's output or a decoded KSampler batch.
  • score - the confidence threshold, 0.0–1.0, default 0.9. Higher means "only the obvious stuff gets flagged." Note the default is stricter than the 0.85 Black Forest Labs uses; if borderline content keeps sneaking through, drop it toward 0.7.
  • backup_image - the fallback, and the one real gotcha. Only the first frame of it is ever used, and the node stacks its output as a single tensor, so if your fallback's resolution doesn't match the input batch you'll get a shape-mismatch error. Size your placeholder to match the pipeline's output resolution.

One IMAGE output - wire it straight into SaveImage, or keep it in the graph and pass the filtered batch onward.

Install. ComfyUI Manager: search "nsfw_No", install, restart. Manual:

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

Restart ComfyUI. The only dependency you don't already have is transformers - Manager reads the pack's requirements and installs it for you; if you install by hand, pip install transformers first.

Where people get burned:

  • First run downloads ~340MB. On an offline or firewall'd box it fails with an opaque transformers error. Warm the cache once by running it online before you need it.
  • The classifier runs on CPU. The node never passes a device to the pipeline, so a few hundred images from a folder loader will take real time - seconds per image. Fine for a handful, slow for a mass sweep.
  • It's a heuristic, not a guarantee. ViT fine-tunes like this both false-positive (flags a swimsuit) and false-negative (misses something). Don't bolt this in front of a public API and call it moderation - treat it as a "keep me out of trouble" filter.
  • It replaces, it doesn't blur or crop. Whatever gets flagged is swapped wholesale for your fallback image. If you wanted to mask a region instead, this isn't the node.

Small pack, single purpose, kept dead simple by its author (xiaodu / chaorenai on GitHub). If "swap nsfw images for a placeholder" is your exact need, this does it in one node - no key, no config beyond a threshold.

Categorynsfw_No

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
scoreFLOAT0.900–1
backup_imageIMAGE

Outputs (1)

NameTypeDescription
IMAGEIMAGE