Nodes/nsfw-shorier_comfyui/Replace if NSFW
ComfyUI Node

Replace if NSFW

Swap in your own image when the detector says no

By phyblas·Created 12 months ago·Updated 4 months ago· 17
Replace if NSFW
  • image
  • replace_image
  • image
  • NSFW
  • score
model_name
threshold0.50
resizefalse

Sometimes a blur isn't the statement you want to make. ReplaceIfNsfw swaps the whole flagged image for one you provide - your own placeholder, a "blocked" card, a blank frame, whatever you've got on hand. The detector runs, and every NSFW frame in the batch gets replaced with replace_image while clean frames pass through untouched. It's the closest thing in this pack to a content gate that still outputs a real image downstream.

How it works

The detection side is standard for the pack: model_name (default compvis) and threshold (default 0.5, lower = stricter). The interesting input is resize (boolean, default off). Two behaviors worth knowing:

  • With resize on, your replacement image is resized to match the original's dimensions exactly.
  • With resize off and a mixed batch (some frames NSFW, some not), the node pads the replacement to the right aspect ratio instead of distorting it - a nice touch that keeps a batch of different-sized frames consistent.

If the whole batch is clean, the node short-circuits and returns the original images untouched, no processing wasted.

Outputs

  • image (IMAGE) - your replacements where needed, originals elsewhere
  • NSFW (BOOLEAN) - per-frame verdict, so you know what actually got swapped
  • score (FLOAT) - the raw detector score behind it

That pass-through verdict is the quietly useful part: you can count replacements, log them, or gate further processing on whether anything got caught.

Install

Same pack, same drill - ComfyUI Manager (search "nsfw-shorier") or:

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

Restart, and the first run downloads the detector you pick. Keep in mind the replacement image lives in your workflow or is loaded by another node - it's a normal IMAGE input, not a file path.

Gotchas

  • If your replacement and original have very different aspect ratios, leave resize on for a full-bleed fill, or off for a letterboxed look in mixed batches.
  • Threshold tuning is the usual dance - too low and you replace clean art, too high and flagged content sails through.
  • Photo-trained detectors (including the default compvis) are noticeably weaker on anime, so budget for false calls if that's your content.
CategoryNSFW

Inputs (5)

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

Outputs (3)

NameTypeDescription
imageIMAGE
NSFWBOOLEAN
scoreFLOAT