Nodes/ComfyUI-Image-Safety-Gate/Image Safety Gate (NSFW)
ComfyUI Node

Image Safety Gate (NSFW)

It won't censor a thing — and that's the point

By monkeykim111·Created 2 months ago·Updated 2 months ago· 0
Image Safety Gate (NSFW)
  • images
  • IMAGE
  • nsfw
wd_varianteva02-large
sensitivity0.6
nsfw_threshold0.35
nsfl_threshold0.50

The name is a slight lie. Image Safety Gate doesn't gate, block, blur, or censor anything - it runs three separate safety classifiers over your image and hands you a single boolean. What you do with that nsfw flag is your job, and honestly that's the useful part.

ComfyUI ships with no content policy at all. If you're running a big batch queue unattended, building a gallery, or pointing a bot at a queue of generations, you are the moderation. This node is the moderation half of that pipeline, and it's deliberately tuned for anime / illustration output - which is exactly where generic CLIP safety checkers are at their most useless, tripping on a slightly low-cut top while sleeping through things they should catch.

How it works: three models, OR'd together

This is not one classifier. It's three, combined conservatively so any one flag wins:

  1. SmilingWolf's wd-tagger v3 (ONNX, the same Danbooru-trained tagger people use for auto-captioning). Here it reads the rating_questionable + rating_explicit probabilities and compares the sum to nsfw_threshold. This is the signal that handles anime NSFW without illustration false positives.
  2. CompVis/stable-diffusion-safety-checker - the classic CLIP concept-similarity checker from the SD1.x days, the same one the old ComfyUI-safety-checker node used, with the same sensitivity slider. It catches concept matches WD might miss, and it deliberately runs on CPU to reproduce the original node's exact numbers.
  3. OwenElliott/image-safety-classifier-s, a SwiftFormer that outputs NSFL/NSFW/SFW. The clever bit: this node reads only the NSFL (gore/violence) probability. The NSFW dimension over-triggers on illustrations, but NSFL stays calm on anime and lights up on actual gore - something WD can't separate cleanly, since Danbooru files blood and killing under "safe."

Then it's a boolean OR: block if any of the three flags. Conservative on purpose.

The inputs that matter

  • images - your IMAGE tensor, standard stuff.
  • wd_variant - five WD v3 variants. The default eva02-large is the most accurate but pulls ~1.6GB; vit is ~400MB and fast. All output the same rating layout, so switching variants doesn't force you to retune thresholds.
  • sensitivity - the CLIP slider. 0.5 is roughly the explicit-nudity threshold; 1.0 starts catching lingerie-level content. Default 0.6.
  • nsfw_threshold - the WD sum of questionable+explicit, default 0.35. Above 0.50 is high-confidence NSFW; 0.30–0.50 is borderline.
  • nsfl_threshold - the gore signal, default 0.5. Drop it toward 0.15 and you start catching light blood/wound content.

Two outputs: IMAGE (your input, unmodified - again, no censoring happens here) and nsfw, a single boolean for the whole batch. Ten images in, one bad frame → True. That's the batch behavior, not a bug.

Where people get burned

  • "It's not blocking anything." Right - it can't. This is a data node, not a filter. Wire the nsfw boolean into a logic/switch node to abort a queue, or into a text/preview node to log a warning. The pixels never change.
  • The first run looks hung. All three models download on first use into ComfyUI/models/safety_checker/ - the default variant alone is 1.6GB. Watch the console for [image-safety-gate] Downloading .... If you already have the files from the old ComfyUI-safety-checker or a WD tagger pack, they get reused and no network hit happens.
  • Photoreal content behaves differently. The WD signal assumes Danbooru-style ratings. On photoreal images the CLIP check carries more of the load, so tune by watching the per-image log - the node prints each signal's verdict and the OR result, which makes disagreement cases obvious.
  • Heavy dependencies. It needs onnxruntime, transformers, timm, huggingface_hub, plus a few usual suspects. The Manager install handles these; the manual route does too, as long as you actually run pip install -r requirements.txt.

Install

Via ComfyUI Manager, search ComfyUI-Image-Safety-Gate and hit Install, then restart. Or the manual way:

cd ComfyUI/custom_nodes
git clone https://github.com/monkeykim111/ComfyUI-Image-Safety-Gate
pip install -r ComfyUI-Image-Safety-Gate/requirements.txt

Restart ComfyUI.

If you generate anime in bulk and want a conservative "nope" signal you can trust, this is one node doing what three would. Just remember: it flags, it doesn't fix.

Categoryimage

Inputs (5)

NameTypeDefaultDescription
imagesIMAGE
wd_variantCOMBOeva02-large5 options: vit, convnext, swinv2, vit-large, eva02-large
sensitivityFLOAT0.60–1
nsfw_thresholdFLOAT0.350–1
nsfl_thresholdFLOAT0.500–1

Outputs (2)

NameTypeDescription
IMAGEIMAGE
nsfwBOOLEAN