Nodes/ComfyUI-YoloNSFW/YOLO NSFW Detector
ComfyUI Node

YOLO NSFW Detector

Blur the NSFW parts without an API key — this YOLO node does it locally

By er1cw00·Created 5 months ago·Updated 5 months ago· 1
YOLO NSFW Detector
  • images
  • image
  • has_nsfw
model_nameerax_nsfw_yolo11n
devicecpu
conf0.25
iou0.30
blurfull
blur_radius35
auto_releasefalse

The YOLO NSFW Detector (YoloNSFWNode) is a small node that looks at your images, decides whether anything NSFW is in the frame, and optionally blurs it before the image leaves your graph. No cloud API, no moderation key, nothing leaves your machine. It's the one-node answer to a problem people usually solve with three: find the dirty bits, mask them, then blur or pixelate inside the mask.

Why would you reach for this? Think of the workflows where the output is not for you. You're batch-generating a set for a client or a public gallery and you want a safety net that flags anything spicy and blurs it so it never shows up in the final folder. Or you're building a "queue through a filter" pipeline where every generation has to pass a content check before it gets saved or posted. That's the honest use case: automatic censorship of your own output, locally.

The name is a slight lie in the best way - it doesn't call any API and needs no key. Under the hood it's a plain YOLO11 detector from the erax-ai/EraX-NSFW-V1.0 model family, the same detector lineage people were already wiring into Impact Pack's BboxDetector + CropAndStitch to do manual censor pipelines. This node just bundles detection, blurring, and the result flag into one box.

How it works

On first run the node downloads the .pt weights straight from Hugging Face into ComfyUI/models/nsfw/ (the README's nested folder tree is a little confusing; the code writes to models/nsfw/ directly). Then it's a stock ultralytics predict call, followed by a PIL GaussianBlur on either the whole frame or just the detected boxes. One genuinely nice touch: a fix commit made sure it only blurs when something is actually detected - clean images come through untouched, which is the whole point.

The inputs that matter

You don't need to touch most of these on day one, but the three that actually change results:

  • model_name - erax_nsfw_yolo11n (fastest/lightweight) vs erax_nsfw_yolo11s (balanced) vs erax_nsfw_yolo11m (most accurate, slowest). The n model is fine for casual filtering; reach for m when false negatives actually cost you.
  • conf (default 0.25) - the detection confidence threshold. Crank it toward 0.5 if it's over-flagging clean images.
  • blur - none, full, or partial. partial blurs only the detected regions and is what you want for keeping the image legible. The optional blur_radius (1–100, default 35) controls how strong that Gaussian is.

Also worth knowing: device defaults to cpu - set it to cuda (or mps on Apple Silicon) or you're leaving speed on the table, though it falls back gracefully if the backend isn't available. auto_release unloads the model and runs gc.collect() after each run; useful if this node sits in the same workflow as a big diffusion model and VRAM is tight, at the cost of reloading on every pass.

The outputs

  • image - the processed tensor (blurred if flagged, original otherwise). Wire this to a Save Image / Preview.
  • has_nsfw - a BOOLEAN that's True if anything was detected. Feed it into a switch node to reroute the pipeline, or just read it as your content check.

One honest gotcha from reading the source: has_nsfw is per-batch, not per-image. If you feed a batch and any single frame trips the detector, every clean frame after it in that batch also gets blurred. Feed images one at a time if that distinction matters to you.

Installing it

ComfyUI Manager: search "ComfyUI-YoloNSFW" and install. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/er1cw00/ComfyUI-YoloNSFW.git
cd ComfyUI-YoloNSFW
pip install -r requirements.txt

Then restart ComfyUI. The only genuinely new dependencies are ultralytics and opencv-python - torch, numpy, and Pillow are already in any working ComfyUI environment, though ultralytics itself is a chunky install. First inference will pause while the model downloads, so don't panic if it looks frozen; it's pulling a few tens of MB from Hugging Face.

It's a niche utility from a small pack - nobody's writing thinkpieces about it - but for "automatically keep the spicy output out of the final folder," it does exactly one job and does it locally.

Categoryimage/nsfw

Inputs (8)

NameTypeDefaultDescription
imagesIMAGE
model_nameCOMBOerax_nsfw_yolo11n3 options: erax_nsfw_yolo11m, erax_nsfw_yolo11n, erax_nsfw_yolo11s
deviceCOMBOcpu3 options: cpu, cuda, mps
confFLOAT0.250–1
iouFLOAT0.300–1
blurCOMBOfull3 options: none, full, partial
blur_radiusoptINT351–100
auto_releaseoptBOOLEANfalse

Outputs (2)

NameTypeDescription
imageIMAGE
has_nsfwBOOLEAN