Nodes/ComfyUI YetAnotherSafetyChecker/Intercept NSFW Outputs
ComfyUI Node

Intercept NSFW Outputs

A Content Filter That Lives in Your Graph, Not in the Cloud

By BetaDoggo·Created 2 years ago·Updated 2 years ago· 6
Intercept NSFW Outputs
  • image
  • IMAGE
  • STRING
threshold0.80
cudafalse

ComfyUI has no content policy. It will happily render whatever the loaded model wants to render, and save it to your output folder - no filters, no questions. That's usually a feature. But if you're running a shared instance, generating at work, or batch-rendering hundreds of images you don't want to eyeball one by one, "whatever the model wants" stops being charming. This node is a filter you drop into the graph: wire it between VAE Decode and Save Image, and anything it flags as NSFW comes out as a solid black frame instead.

The "Yet Another" in the name is doing honest work - there are a dozen of these nodes, and this one isn't trying to be more than a 30-line gate. Which is exactly its appeal. No API, no key, no cloud call. It downloads one small open model from HuggingFace and runs it entirely on your machine.

How it works

Under the hood it loads AdamCodd/vit-base-nsfw-detector, a Vision Transformer image classifier fine-tuned for exactly this job, through HuggingFace's transformers pipeline. Feed it an image and it returns a score from 0 to 1. If the score lands above your threshold, the node swaps the image for a black tensor; otherwise the original passes straight through untouched. You also get the score back as text so you can see exactly how confident the model was.

This is the same family of detector the ReActor face-swap node and other "solid black output" filters use, so it's not some random model - vit-base-nsfw-detector has steady real-world usage. The author picked it because it's small, fast, and reliably scores nudity at 0.95+. The 0.8 default is a deliberately safe baseline: it blocks anything remotely spicy while rarely touching legitimate content. Don't expect a perfect censor, though. It's a decent classifier, not a human reviewer.

The inputs and outputs that matter

  • image (IMAGE) - wire your VAE Decode output here. It should sit right before the Save Image node.
  • threshold (FLOAT, default 0.8, range 0–1) - the block line. Score above this and the image goes black. This is the one you'll actually fiddle with.
  • cuda (BOOLEAN, default off) - load the model on your GPU instead of CPU. Flipping it on makes scoring noticeably snappier; leave it off if your VRAM is already cramped.

Outputs are IMAGE (the primary one - original or black) and STRING (the raw score). The intended tuning loop is to run the score string into a Show Text node, generate a few test images, and adjust threshold until your boundary feels right.

Installing it

ComfyUI Manager, search "ComfyUI YetAnotherSafetyChecker". Or the manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/BetaDoggo/ComfyUI-YetAnotherSafetyChecker

Restart ComfyUI. Now the catch, and it's a real one: this pack declares no Python dependencies at all. No requirements.txt, and pyproject.toml lists none. The code needs transformers, which base ComfyUI does not ship. If you don't already have it (another node usually pulls it in), you'll hit ModuleNotFoundError: No module named 'transformers'. Install it yourself:

pip install transformers

On the Windows portable build, use python_embeded\python.exe -m pip install transformers. First run then downloads the model - a few hundred megabytes from HuggingFace - so it looks frozen the first time. It's not; it's downloading. Cached after that, and you'll need internet at least once.

Where people get burned

  • It only scores the first image of a batch. The code checks image[0] and passes the whole batch through if that one is clean. Feed it a batch of four and you're screening one image, not four. Route single images through it.
  • The black placeholder is hard-coded at 512×512. It won't match your input resolution, so don't pipe the blocked output into an upscaler or anything shape-sensitive - send it to a Save Image / Preview and stop there.
  • The model reloads on every queue run. It re-initializes the pipeline each execution, which is why CPU scoring feels slower than it should. Use the cuda toggle if this annoys you.
  • It's a gate on one wire, not a global policy. It only catches what passes through it. Put it on the right path, and remember nothing stops you (or anyone with API access) from bypassing the graph - this is a convenience filter, not a security measure.

It's a small node with a small audience, but it does one thing cleanly. If you need a "look, there's a filter" answer on a shared setup, this is a solid, dependency-light way to give it.

Categoryimage/processing

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
thresholdFLOAT0.800–1
cudaBOOLEANfalse

Outputs (2)

NameTypeDescription
IMAGEIMAGE
STRINGSTRING