comfyui-nsfw-detector
A ComfyUI custom node that detects NSFW content using Freepik/nsfw_image_detector (EVA-based, ~86MB) and saves images with detection results in the filename.
ComfyUI NSFW Detector
A ComfyUI custom node that detects NSFW content using Freepik/nsfw_image_detector (EVA-based, ~86MB) and saves images with detection results in the filename.
Node: NSFW Detector + Save Image
Drop-in replacement for SaveImage with built-in NSFW detection.
Inputs
| Name | Type | Description |
|------|------|-------------|
| images | IMAGE | Input images |
| filename_prefix | STRING | Filename prefix (default: ComfyUI) |
| nsfw_threshold | low / medium / high | Detection threshold (default: medium). See Threshold levels |
| format | png / webp / jpeg | Output image format (default: png) |
| quality | INT | Encode quality 1-100 (default: 90). Only applies to webp / jpeg; ignored for png |
| lossless | BOOLEAN | Lossless WebP (default: False). Only applies to webp; when enabled, quality acts as compression effort |
Outputs
| Name | Type | Description |
|------|------|-------------|
| images | IMAGE | Passthrough (for chaining) |
| nsfw_level | STRING | Detected level: neutral / low / medium / high |
| nsfw_score | FLOAT | Confidence score of the detected level |
Threshold levels
The model classifies images into 4 levels: neutral, low, medium, high. The nsfw_threshold parameter controls the minimum level that triggers a flag — images at or above the threshold are flagged.
| Threshold | Flagged levels | Passed levels | Strictness |
|-----------|---------------|---------------|------------|
| low | low, medium, high | neutral only | Strictest |
| medium | medium, high | neutral, low | Balanced |
| high | high only | neutral, low, medium | Most lenient |
Filename convention
- Normal:
{prefix}_00001_.png - Flagged:
{prefix}_flagged_{level}_00001_.png
The extension follows the format input: .png / .webp / .jpg.
Installation
Clone into ComfyUI's custom_nodes directory:
cd ComfyUI/custom_nodes
git clone https://github.com/newraina/comfyui-nsfw-detector.git
pip install -r comfyui-nsfw-detector/requirements.txt
Pre-download model
The model is downloaded from HuggingFace on first use by default. To pre-download, place model files in ComfyUI/models/nsfw_detector/:
models/nsfw_detector/
config.json
model.safetensors
If you're using comfyui-api, add to manifest.yml:
models:
before_start:
- url: https://huggingface.co/Freepik/nsfw_image_detector/resolve/main/config.json
local_path: models/nsfw_detector/config.json
- url: https://huggingface.co/Freepik/nsfw_image_detector/resolve/main/model.safetensors
local_path: models/nsfw_detector/model.safetensors