Replace if NSFW
Swap in your own image when the detector says no
- image
- replace_image
- image
- NSFW
- score
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
resizeon, your replacement image is resized to match the original's dimensions exactly. - With
resizeoff 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 elsewhereNSFW(BOOLEAN) - per-frame verdict, so you know what actually got swappedscore(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
resizeon 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.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| replace_image | IMAGE | — | |
| model_name | COMBO | 8 options: compvis, falconsai, adamcodd, umairrkhn, marqo, gantman, +2 | |
| threshold | FLOAT | 0.500–1 | — |
| resize | BOOLEAN | false | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| NSFW | BOOLEAN | — |
| score | FLOAT | — |