Ino NSFW Detect
Blur it, flag it, or route it
- image
- image
- is_nsfw
- nsfw_score
- sfw_score
- message
Most "NSFW detection" in ComfyUI is a hand-wavy prompt filter that misses half the time. This node is not that. It runs a real image-classification model - Marqo/nsfw-image-detection-384 from HuggingFace, a vision transformer fine-tuned for exactly this job - and gives you a score, a verdict, and optionally a blurred copy. If you're building a shared machine, an automated pipeline, or just want a guard between your sampler and your output folder, this is the practical option.
The name undersells the useful part: it's both a filter and a router. The is_nsfw boolean output can drive a switch node, so flagged images take one path (blur, discard, send elsewhere) and clean images take another - all inside the graph.
How it works
On first use it downloads the classifier weights through the standard HuggingFace cache (~/.cache/huggingface/hub), then loads it with transformers. One detail in the source is worth calling out because it explains why this node exists instead of a five-line pipeline script: the author deliberately bypasses transformers.pipeline(), because on certain transformers + accelerate version combos that path loads the model as meta tensors and then crashes on .to(device). They load it directly with low_cpu_mem_usage=False instead. That's the kind of bug-hunting that only happens after the naive version fails on someone's machine.
For each image it runs the classifier, takes a softmax over the logits, and flags NSFW when nsfw_score >= threshold. If flagged and blur_radius > 0, it applies a PIL Gaussian blur and returns that copy; otherwise the original image passes through untouched. Classification runs in a background thread, so a big batch doesn't freeze the UI.
Inputs and outputs that matter
- threshold - score above which an image is flagged. Default 0.5; the author's own tooltip spells it out: "NSFW score above which the image is flagged." Lower it if the default lets borderline content through.
- blur_radius - Gaussian blur radius applied to flagged images, default 30. Set to 0 for detect-only mode: image comes back unchanged, but
is_nsfwstill tells the truth. That's the mode you want when you're routing, not censoring. - model_id - swap in any HuggingFace image-classification model with NSFW/SFW labels if you want a different classifier.
- use_gpu - defaults to CPU, and the tooltip makes the case: running on CPU avoids evicting your diffusion weights from VRAM. Unless you're classifying huge batches, leave it off.
Outputs: image (original or blurred), is_nsfw (boolean), nsfw_score, sfw_score, and a message string.
Installing it
ComfyUI Manager → search "ComfyUI Ino Nodes" → install → restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/nobandegani/comfyui_ino_nodes
cd comfyui_ino_nodes
pip install -r requirements.txt
Restart after. Now the important caveat: transformers is not in the pack's requirements.txt - the node imports it lazily on first use. If your ComfyUI environment doesn't already have it (many don't; it's a heavy dependency that ComfyUI core doesn't ship), the first run fails with "Failed to load classifier". Fix it with pip install transformers. The classifier model itself then downloads once and caches.
Common issues
- Missing transformers - see above; the most common first-run failure.
- First run is slow - the model download is a few hundred MB, then a one-time load. Subsequent runs hit the cache.
- Blur is a privacy knob, not a guarantee - a Gaussian blur hides content at a glance but isn't irreversible; if your use case is "never keep the image," route
is_nsfwto a discard path rather than relying on blur. - Threshold tuning - the Marqo model is decent but not psychic. Test against your actual output style; if you're doing heavy stylization, borderline content will sit right at 0.5 and you'll want to pick a side.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| threshold | FLOAT | 0.500–1 | NSFW score above which the image is flagged. |
| blur_radiusopt | INT | 300–200 | Gaussian blur radius applied to flagged images. Set to 0 to skip blurring even when the image is flagged (detect-only mode). |
| model_idopt | STRING | Marqo/nsfw-image-detection-384 | HuggingFace model id. Must be an image-classification model with NSFW/SFW labels. |
| use_gpuopt | BOOLEAN | false | Run the classifier on CUDA when available. CPU is recommended to avoid evicting diffusion weights from VRAM. |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| is_nsfw | BOOLEAN | — |
| nsfw_score | FLOAT | — |
| sfw_score | FLOAT | — |
| message | STRING | — |