Nodes/Tagger Plus (WD14 / PixAI)/WD14 Tagger Plus ⚡
ComfyUI Node

WD14 Tagger Plus ⚡

Booru tags off any image, without reloading 1.2 GB every picture

By Zove-try·Created 24 days ago·Updated 21 days ago· 17
WD14 Tagger Plus ⚡
  • image
  • tags
  • device
◄model▾►
◄threshold0.35►
◄character_threshold0.85►
◄deviceauto►
◄replace_underscorefalse►
◄escape_parensfalse►
◄sort_by_confidencefalse►
◄trailing_commafalse►
◄exclude_tags►
◄preprocessauto►
◄color_orderauto►
◄unload_after_runfalse►

What it's for

You have an image and you want the prompt. Or you have 80 images and a LoRA to train on an Illustrious/NoobAI/Pony base and you need captions in the booru vocabulary. Either way, WD14 Tagger Plus reads the picture and hands back a comma-separated Danbooru tag string - 1girl, blue_eyes, school_uniform, standing - because that's what those bases were trained on, and prose captions quietly underperform on them.

It's not a captioner. The tag path and the natural-language path (Florence-2, JoyCaption) are worth running side by side: Florence describes a scene in ways WD never will, but it'll never emit the specific known booru tag. Auto-caption a big set with a tagger; audit a small one by hand.

Why this pack exists

WD14 Tagger Plus is a fixed build of WD14Tagger|pysssss, and it targets two things.

Upstream rebuilds its ONNX InferenceSession on every execution, inside tag(). That's a 1.2 GB reload plus graph optimisation, 3–6 seconds, per image, on every machine. This node caches the session and the parsed vocabulary, keyed on (model, provider).

Second: when the CUDA execution provider can't load, ONNX Runtime doesn't fail loudly, it quietly runs on CPU. This node reports the device it actually used as an output, so you find out. On the author's RTX 5060 Ti with a CUDA 13 torch build, upstream measured 16.5 s per image; here it's 0.09–0.2 s on GPU. On a CUDA 12 torch build you were already on the GPU - your win is the session rebuild, which is still most of the pain.

How it runs an image

It reads the input shape off the ONNX session (448×448 for WD v3), Lanczos-scales the long edge, pads to a square with white, flips RGB→BGR, and normalises. NCHW input gets transposed automatically, and an export saved without sigmoid gets one applied.

Those two conventions - BGR and pad-to-square - are what the WD lineage was trained with, and breaking them doesn't error, it lies. Feed RGB and blonde hair comes back blue_hair. Centre-crop instead of pad and you clip heads and feet and get a fabricated head_out_of_frame. Measured agreement with the ONNX path under those mistakes: 43.8% and 50%. Both right: 98.5%. color_order and preprocess are escape hatches for odd models; leave them on auto.

Community models are the other real addition. New taggers usually ship as model.safetensors + config.json with no ONNX, and a DIY export often comes out NCHW and won't run upstream at all. Drop the folder in and this loads it through timm.

The inputs that matter

Required: image; model, a dropdown of bare model names where picking an uninstalled one downloads it on first run; threshold (0.35, the general-tag cutoff); character_threshold (0.85, so you don't get a named girl who isn't there); device (auto/cuda/cpu).

Two optional defaults are deliberate departures from upstream. escape_parens is off - upstream forces it on, converting ( ) into \( \), which breaks any downstream node that looks tags up in a table, since xxx_(series) stops matching. Turn it on only for byte-identical upstream output. sort_by_confidence is off, so you keep vocabulary order like upstream; flip it to read strongest tags first.

Also here: replace_underscore (leave off for booru bases - blue eyes changes how downstream tokenisers split), trailing_comma, exclude_tags (case-insensitive, matches both blue_eyes and blue eyes), color_order, preprocess, unload_after_run.

Two outputs. tags goes to a CLIP Text Encode for img2img seeding, or a Save Text File node for caption files. device goes to a Note once and you stop guessing.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/Zove-try/ComfyUI-TaggerPlus

ComfyUI Manager finds it too - search the pack name - and either way you restart after. Requirements are light: onnxruntime-gpu, safetensors, timm; torch, pillow and numpy come from ComfyUI.

Models live in ComfyUI/models/wd14_tagger/. The dropdown lists known models whether or not you have them; first run fetches into that folder (1.2 GB for wd-eva02-large-tagger-v3, 446 MB swinv2, 361 MB vit). Official HuggingFace first, hf-mirror as fallback, and you can force the mirror:

export TAGGERPLUS_HF_ENDPOINT=https://hf-mirror.com

Where people get burned

device says CPU ⚠ 请求了 GPU 但回退到 CPU. You're missing the CUDA 12 runtime onnxruntime-gpu needs (cublasLt64_12.dll) - common on CUDA 13 torch builds, where the DLL name doesn't match. Run install_cuda12.bat or bash install_cuda12.sh in the pack directory, or unzip the offline cuda12/ package so the path reads ComfyUI-TaggerPlus/cuda12/nvidia/cublas/bin/cublasLt64_12.dll. A nested cuda12/cuda12/ is the classic mistake. And restart the process on port 8188 - closing the tab does nothing.

First run takes 10–50 seconds. That's the CUDA session cold start, once per process. Later images are ~0.1–0.2 s.

timm missing. Only the safetensors community models break; ONNX is unaffected. pip install timm.

VRAM stays occupied. Sessions sit in a module cache, and the pack hooks ComfyUI's free-memory path so they're dropped after about 30 seconds idle. Want it immediate - you're about to load a 12B video model - tick unload_after_run.

CategoryTaggerPlus

Inputs (13)

NameTypeDefaultDescription
imageIMAGE—
modelCOMBO两种格式自动识别、无需转换: • ONNX(.onnx + 词表 csv)—— 自动适配 NHWC / NCHW 布局 • safetensors + timm(<模型名>/model.safetensors + config.json)—— 社区新模型 带 ⬇ 的条目会在首次使用时自动下载(优先官方,失败切国内镜像) 扫描目录: /tmp/ComfyUI/models/wd14_tagger
thresholdFLOAT0.350–1通用标签阈值(原版默认 0.35;部分社区模型建议更高,如 canary 官方建议 0.61)
character_thresholdFLOAT0.850–1角色标签阈值(原版默认 0.85;做对比建议和对方对齐)
deviceCOMBOautoauto = 有 CUDA 就用;加载失败会自动回退并在 device 输出里说明
replace_underscoreoptBOOLEANfalse把 blue_eyes 变成 blue eyes(注意:会让下游分类器按空格切词)
escape_parensoptBOOLEANfalse原版会把 ( ) 转义成 \( \);关掉可让下游查表正常
sort_by_confidenceoptBOOLEANfalseTrue = 按置信度从高到低;False = 词表顺序(与原版一致)
trailing_commaoptBOOLEANfalse—
exclude_tagsoptSTRING要排除的标签,逗号分隔(大小写不敏感)
preprocessoptCOMBOauto社区模型的构图方式。auto/pad = 缩放到长边+补白边(保留整张图,推荐);crop = 短边缩放后中心裁剪(ImageNet 风格,会裁掉头/脚)
color_orderoptCOMBOauto通道顺序。auto = BGR(WD 系列及其微调模型的约定);若某模型输出的颜色类标签明显不对(如把金发认成 blue_hair),可试 rgb
unload_after_runoptBOOLEANfalse—

Outputs (2)

NameTypeDescription
tagsSTRING—
deviceSTRING—