Nodes/imgutils/Imgutils Deduplicate Tags
ComfyUI Node

Imgutils Deduplicate Tags

Merge Tag Strings and Kill the Duplicates

By xiaden·Created 2 months ago·Updated 2 months ago· 0
Imgutils Deduplicate Tags
    • tags
    • count
    tags

    The moment you run two taggers on one image, you have a duplicate problem. WD14 says "1girl, blue hair"; Camie says "blue hair, 1girl"; and your prompt is about to say both. Imgutils Deduplicate Tags is the merge step: it takes multiple tag strings (yes, multiple wires into the same input - the schema marks it as a list input), combines them, removes duplicates, and hands back one clean comma-separated list plus a count.

    Why you'd reach for it

    Chaining taggers is a real pattern - the KB's captioning material recommends running a describer and a tagger together, and plenty of people run two taggers to catch each other's blind spots. The output needs cleaning before it becomes a prompt or a caption. This node is the cleaner. Feed WD14 into one wire and Camie (or DeepGelbooru, or a hand-typed tag list) into another, and out comes a single deduplicated list in a deterministic order.

    How it works

    Simple string work, no model. Each input string is split on commas and newlines, whitespace is stripped, and tags are deduplicated case-insensitively - "1girl" and "1GIRL" count as the same tag, and the first occurrence wins. The result is joined with ", " and a count (INT) tells you how many unique tags survived.

    The interface

    • tags (STRING) - the input. Wire multiple tag sources into this one socket; they're combined.
    • Outputs: tags (STRING, merged and deduplicated) and count (INT).

    Honest take

    Two details decide whether this node feels great or confusing. Order is stable but first-wins: since the first occurrence of each tag wins, feed your primary, most-trusted tagger first - its ordering becomes the ordering of the output. And dedup is exact-string-after-lowercase, not semantic: "1girl" and "1girl, solo" are different tags and both survive, and near-synonyms ("smile" vs "grinning") won't be merged. That's the correct behavior for a string tool, just don't expect AI-level cleanup.

    The sleeper feature is count. "Fewer than three unique tags from two taggers" almost always means a blank, corrupt, or degenerate frame - count turns tag output into a gating signal for skipping bad frames in a batch. Cheap and genuinely useful.

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/xiaden/comfyui-imgutils.git
    cd comfyui-imgutils
    pip install -r requirements.txt
    

    Or via ComfyUI Manager (search "imgutils"). Needs ComfyUI >= 0.25.0 and Python >= 3.10; dependency is dghs-imgutils[gpu]. No model, no downloads - pure text processing.

    Troubleshooting

    If only one input seems to make it through, check the wiring: this node expects multiple connections on the single tags input, not separate inputs - the list-ness is handled by the engine, so all wires should land on the same socket. And if duplicates still appear in the output, they're different strings that merely look alike ("long hair" vs "long_hair") - the taggers use underscores; hand-typed lists may not, and this node won't normalize the two.

    Categoryimgutils/utility

    Inputs (1)

    NameTypeDefaultDescription
    tagsSTRINGTag strings to merge. Connect multiple inputs — they will be combined and deduplicated.

    Outputs (2)

    NameTypeDescription
    tagsSTRING
    countINT