ComfyUI Node

TK WD14 Tagger

WD14 tags for a whole folder — the booru-tag path for anime datasets

By tackcrypto1031·Created 8 months ago·Updated 6 months ago· 2
TK WD14 Tagger
    • tags
    • filenames
    source_pathC:/input_images
    output_pathC:/output_images
    modelSmilingWolf/wd-v1-4-convnextv2-tagger-v2
    threshold0.35
    character_threshold0.85
    exclude_tags
    filename_prefiximage_

    WD14 is the Danbooru tagger, and it does one thing the fancy VLMs can't: it emits the exact comma-separated booru vocabulary - 1girl, long hair, looking at viewer, solo - that Illustrious, Pony, and NoobAI were trained on. TK WD14 Tagger is the batch wrapper that runs a SmilingWolf WD14 model over a folder, writes a .txt of tags next to each renamed image, and hands you the tag strings. If your dataset is anime and your target model speaks tags, this is the right node in this pack - not the Qwen or JoyCaption ones.

    How it works

    The mechanism is old-school ONNX, not Transformers. Give it a source_path and an output_path:

    1. It downloads the chosen model (a SmilingWolf ONNX model plus its tag CSV) into tk_comfyui_imageVL/models on first use.
    2. Each image is resized to fit a 448×448 canvas, centered on white to handle alpha, converted to BGR, and run through the ONNX session - on CUDAExecutionProvider if you have it, otherwise CPU.
    3. The raw probabilities come back, and the node maps them to tag names from the CSV, skipping the rating category entirely (you don't want rating: explicit polluting your caption).

    The model stays loaded between runs while the node exists, so a second batch is much faster than the first.

    The inputs that matter

    • model - nine SmilingWolf options across the v2 and v3 lines. Default is wd-v1-4-convnextv2-tagger-v2, which is the usual recommendation - a good quality/speed balance.
    • threshold - probability cutoff for general tags, default 0.35. Lower it to catch more tags (and more noise); raise it for cleaner, sparser output.
    • character_threshold - separate, higher cutoff for character tags, default 0.85. Keeps wrong characters out of your captions - a tagger's character guesses are wrong more often than its general guesses, so the higher bar is deliberate.
    • exclude_tags - comma-separated tags to drop (e.g. watermark, signature). Matches case-insensitively with underscores treated as spaces.
    • filename_prefix - rename prefix, same as the batch loader.

    Outputs are tags (LIST of comma-joined tag strings) and filenames (LIST), position-matched. It also writes {prefix}{n}.txt into output_path itself and copies the renamed image over.

    Installation

    cd ComfyUI/custom_nodes
    git clone https://github.com/tackcrypto1031/tk_comfyui_imageVL.git
    cd tk_comfyui_imageVL
    pip install -r requirements.txt
    

    Restart after, or use ComfyUI Manager and search tk_comfyui_imageVL. Note this node specifically needs onnxruntime (the pack's requirements pull it - onnxruntime on Windows/Linux, onnxruntime-silicon on macOS) and pandas, since the tag mapping is done with the CSV.

    Where people get burned

    • CPU is slow. If ONNX Runtime can't find CUDA, everything runs on CPU, and tagging hundreds of images becomes a slog. Check that onnxruntime-gpu is available, or the node logs a CPU fallback.
    • Tags, not descriptions. WD14 never describes a scene - it emits the known vocabulary. That's a feature for booru-based models and a mismatch for natural-language bases. The durable community practice is to run a tagger and a describer (Florence-2, JoyCaption, or a Qwen-VL) and concatenate, so you get both the atomic tags and the scene prose.
    • Threshold tuning is personal. 0.35 is a decent start but there's no universal right answer - test a few images first, then run the whole folder. And the separate character_threshold exists because wrong character tags poison a caption set faster than anything else.

    For anime tagging in bulk, this is the reliable, dependency-light workhorse of the pack. Just don't ask it to write you a sentence.

    CategoryTK/WD14

    Inputs (7)

    NameTypeDefaultDescription
    source_pathSTRINGC:/input_images
    output_pathSTRINGC:/output_images
    modelCOMBOSmilingWolf/wd-v1-4-convnextv2-tagger-v29 options: SmilingWolf/wd-v1-4-moat-tagger-v2, SmilingWolf/wd-v1-4-convnextv2-tagger-v2, SmilingWolf/wd-v1-4-swinv2-tagger-v2, SmilingWolf/wd-v1-4-vit-tagger-v2, SmilingWolf/wd-v1-4-convnext-tagger-v2, SmilingWolf/wd-eva02-large-tagger-v3, +3
    thresholdFLOAT0.350–1
    character_thresholdFLOAT0.850–1
    exclude_tagsSTRING
    filename_prefixSTRINGimage_

    Outputs (2)

    NameTypeDescription
    tagsLIST
    filenamesLIST