NSFW Load Model + Filter Policy (HF)
Load the classifier once, check as many times as you want
- nsfw_model
- block_policy
NSFW Guard is a small pack with one job: catch explicit output before it leaves your pipeline. NSFW Load Model + Filter Policy (HF) - the class is called NSFWLoadModel, but don't let the name undersell it - is where you start. It does two things in one node: pulls one of the pack's two Viddexa classifier models into memory, and bakes in the blocking policy (which content classes count as "reject this"). Everything downstream just points at what this node produces.
Why bother with a separate loader instead of the pack's single all-in-one node? Because that one (NSFWCheck) is fine for a single checkpoint but wasteful the moment you want to screen an image more than once in the same run. Most real setups do want more than once - check what came in before you touch it, then check what you're about to hand back. Load once, check twice, pay the model-load cost exactly once.
How it works
Point model_repo at one of Viddexa's two Hugging Face classifiers - nano (the default) or mini - and the node loads it via the pack's preferred moderators backend, falling back to transformers if that's not available. Nothing gets classified here; this node's whole job is producing a loaded model object and a policy object for the check nodes to consume. The five boolean flags (porn, hentai, sexy, drawing, normal) set which of the classifier's five output buckets should trip a block - that five-way split (explicit photo content, explicit drawn content, suggestive-but-not-explicit, drawings generally, and safe/neutral) is the same shape most open-source NSFW image classifiers have used for years. By default porn, hentai, and sexy are checked and drawing/normal aren't, which matches the pack's documented default policy.
The inputs and outputs that matter
model_repo-viddexa/nsfw-detection-2-nanoorviddexa/nsfw-detection-2-mini. The README doesn't publish a speed/accuracy comparison between the two, so treat "nano" as the safe default and only reach for "mini" if you have a specific reason to try it.porn/hentai/sexy/drawing/normal- five checkboxes, one per class the classifier can predict. Leave the defaults (porn/hentai/sexy on) unless you specifically want to also catch anime-style explicit art (flipdrawingon) or - almost never a good idea - flag safe images too (flipnormalon, which blocks everything).
Two outputs: nsfw_model (NSFW_GUARD_MODEL) goes into every NSFW Check (HF, Shared Model) node you want to reuse it in, and block_policy (NSFW_BLOCK_POLICY) goes into their optional block_policy input. You don't strictly have to wire the policy output anywhere - the check nodes fall back to the pack's default policy if you leave it disconnected - but wiring it is how you actually choose what "NSFW" means for your pipeline instead of accepting the default.
How to install it
Easiest path is ComfyUI Manager: search "NSFW Guard", install, restart. Manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/vuhung3990/comfyui-nsfw-guard
pip install -r comfyui-nsfw-guard/requirements.txt
then restart ComfyUI. The dependency footprint is small - the pack prefers the moderators PyPI package and falls back to transformers, both of which you likely have half-installed already if you've touched any other Hugging Face classifier node.
Common issues & troubleshooting
First run is slow, then it's fine. This is an "(HF)" node - it's pulling classifier weights from Hugging Face the first time you execute it. Give it a minute on a cold environment; after that it's cached and loads fast.
You wired nsfw_model into a check node and nothing visibly happens on a block. That's correct, just not obvious: this pack doesn't quietly blur or swap the flagged image. Per the README, a blocked image interrupts the whole run and raises an error typed nsfw_content_detected. If you're driving this over an API, that's the signal to catch server-side, not something to branch on inside the graph.
Requirements install fails on moderators. It's a smaller, less common PyPI package than transformers. If it won't resolve in your environment, the pack is built to fall back to transformers - make sure that's actually installed rather than fighting the preferred backend.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| model_repo | COMBO | viddexa/nsfw-detection-2-nano | 2 options: viddexa/nsfw-detection-2-nano, viddexa/nsfw-detection-2-mini |
| porn | BOOLEAN | true | — |
| hentai | BOOLEAN | true | — |
| sexy | BOOLEAN | true | — |
| drawing | BOOLEAN | false | — |
| normal | BOOLEAN | false | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| nsfw_model | NSFW_GUARD_MODEL | — |
| block_policy | NSFW_BLOCK_POLICY | — |