ComfyUI Node

Is NSFW

Is this image safe to show?

By phyblas·Created 12 months ago·Updated 4 months ago· 17
Is NSFW
  • image
  • NSFW
  • score
model_name
threshold0.50

IsNsfw doesn't censor anything. That's the point. It looks at an image, runs a detector, and hands you a verdict - a true/false NSFW output plus the raw score behind it. That verdict is what you wire into a switch, a blur node, or a separate save path. It's the node you build workflows around, and honestly most of the nsfw-shorier pack is IsNsfw plus whatever happens when the answer is "yes."

How it works

The pack gives you eight detection models in one model_name dropdown: compvis (the default, and per the author the most accurate in testing), falconsai, adamcodd, umairrkhn, marqo, gantman, and nudenet (320) / nudenet (640). The first time you pick one it downloads itself - so don't panic if your first run hangs on a progress bar; subsequent runs use the cached copy.

compvis is worth knowing about, because it's the old Stable Diffusion safety checker - the CLIP-based filter that used to quietly swap "unsafe" generations in the original SD1.x pipeline. It's big (expect a heavy model download on first use), it's fussy in that classic CLIP way, and it's also genuinely decent at the job. It can run on CUDA, Apple MPS, or CPU.

The two inputs that matter

threshold (0–1, default 0.5) is the whole game. If score > threshold, the image is flagged NSFW. Lower the threshold and the detector gets trigger-happy - you'll catch more real content but also eat more false positives. Raise it and you'll let more stuff through. There is no free lunch here: the community consensus on this exact problem is that you tune the threshold knowing you'll lose some legit SFW images on the sensitive side.

model_name is the other one, and it matters more than people think. Different detectors use different score scales - what reads as 0.9 in one model might be 0.3 in another. If you switch models, re-tune the threshold. Don't assume 0.5 means the same thing across the list.

Outputs

  • NSFW (BOOLEAN) - feed this into a primitive switch or a logic gate to branch your graph.
  • score (FLOAT) - the raw 0–1 number. Log it if you want to audit how often the detector is firing.

Install

Same for the whole pack - ComfyUI Manager (search "nsfw-shorier") or:

cd ComfyUI/custom_nodes
git clone https://github.com/phyblas/nsfw-shorier_comfyui

then restart ComfyUI. Dependencies (transformers, onnxruntime, timm, torchvision, pillow, tqdm) install along with it.

Gotchas

  • First run is slow - that's the model download, not a hang.
  • If you switch detectors, your old threshold is probably wrong now.
  • compvis is the default for a reason, but if it's too conservative for anime art, none of these photo-trained models are going to feel great. NudeNet especially is trained on realistic photos and struggles with drawn content.
CategoryNSFW

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
model_nameCOMBO8 options: compvis, falconsai, adamcodd, umairrkhn, marqo, gantman, +2
thresholdFLOAT0.500–1

Outputs (2)

NameTypeDescription
NSFWBOOLEAN
scoreFLOAT