Nodes/imgutils/Imgutils Label Contains
ComfyUI Node

Imgutils Label Contains

Ask a Label String 'Does It Mention X?' and Get a Boolean Out

By xiaden·Created 2 months ago·Updated 2 months ago· 0
Imgutils Label Contains
    • boolean
    labels
    search

    Detection and tagging output arrives as text; branching on it requires a boolean. Imgutils Label Contains is the one-line translator between those worlds: give it a comma-separated label string and a search term, and it tells you - as a real BOOLEAN output - whether the term is there. Case-insensitive, no model, instant.

    Why it's useful

    Once you're running Imgutils Detect, Check, or any of the taggers, the natural next move is routing: "if a face was detected, run the detail pass"; "if the labels include '1girl', use this prompt"; "if this image is tagged 'monochrome', skip it." That's a conditional, and conditionals need booleans. This node is the adapter that turns a detection or tag string into a gate you can feed into a switch, an if-node, or Imgutils Boolean Logic for compound conditions. It lives in the same plumbing layer the KB's node-plumbing doc describes as ComfyUI's "graph as a small program."

    How it works

    It's a plain substring check - search.lower() in labels.lower(). No tokenization, no fuzzy matching, no AI. That's a feature for speed and predictability, and a caveat for exactness, which we'll get to.

    The interface

    • labels (STRING) - the comma-separated label/tag string, e.g. from Detect's detections, a tagger's tags, or Bbox Unpack's labels output.
    • search (STRING) - the term you're looking for.
    • Output: boolean (BOOLEAN) - true if the term appears anywhere in the labels.

    Honest take

    The substring semantics are both the point and the trap. "face" matches "facemask", "1girl" matches "1girls", "book" matches "bookshelf". Usually that's fine - you're checking for a concept, not a token boundary - but if you need an exact tag match, this node will over-match and you'll wonder why your branch fires when it shouldn't. The fix is to search for a term that won't be a substring of anything else (a full danbooru tag with underscores, say) or add a trailing comma context to your search. And the output is a bare boolean with no label/scores - if you want the score and a boolean, use Check or Score Threshold instead.

    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"). Requires ComfyUI >= 0.25.0 and Python >= 3.10; pack dependency is dghs-imgutils[gpu]. No model, no download - pure string comparison.

    Troubleshooting

    The failure modes are all about inputs, not the node: feeding it a single tag when you meant the whole list (it searches the entire string, so that works anyway), or typing a search term with different case (handled - it's case-insensitive). The real one to watch is empty labels: an empty string contains nothing, so you get false, which is usually the desired behavior but worth knowing when your graph "randomly" skips a branch on a blank result.

    Categoryimgutils/utility

    Inputs (2)

    NameTypeDefaultDescription
    labelsSTRINGComma-separated label string (e.g. from Detect or Tagging output).
    searchSTRINGTerm to search for in the labels. Case-insensitive.

    Outputs (1)

    NameTypeDescription
    booleanBOOLEAN