Nodes/imgutils/Imgutils Bbox Unpack
ComfyUI Node

Imgutils Bbox Unpack

Turn Detection Output Into Something You Can Actually Loop Over

By xiaden·Created 2 months ago·Updated 2 months ago· 0
Imgutils Bbox Unpack
    • count
    • labels
    • iterable
    bboxes

    The imgutils Detect node hands you a bounding-box result as a plain string - human-readable, not exactly machine-loopy. Imgutils Bbox Unpack is the bridge: it parses that raw string and emits three outputs - a count, a comma-separated label list, and a JSON array you can feed straight into a for-each iterator.

    Why it exists

    The moment you want to do something per-detection - crop each face, re-render each detected hand, upscale each text region - you need structured data plus a way to iterate. This is the utility half of the "detect → crop → re-render → paste" automation loop that the KB's masking-detection doc describes as the highest-value automation pattern in the ecosystem. If you're used to Impact Pack's SEGS container, think of this as the imgutils pack's lighter, plain-JSON equivalent: it hands a for-each framework an iterable list instead of a typed SEGS bundle.

    How it works

    The parser is forgiving by design, because it has to be. It recognizes three input shapes:

    • a JSON array where each entry has a bbox (or box / coords) of [x1, y1, x2, y2], a label, and a score
    • the Detect node's text-tuple format - [x1,y1,x2,y2] label (score)
    • the OCR node's quoted text format

    Each entry is normalized to {x1, y1, x2, y2, label, score, width, height} and serialized back out. Note it parses, it doesn't validate - malformed input just yields zero entries, no crash.

    The outputs

    • count (INT) - how many boxes. Handy as a gate: "if zero faces, skip the detail pass."
    • labels (STRING) - the labels joined with commas. Feed it to Imgutils Label Contains to branch on what was found.
    • iterable (STRING, JSON) - the array, ready for forLoopStart / ForeachListBegin-style iterators that take a JSON list of items.

    Honest take

    It's niche, and it's also quietly the missing glue if you're building the detect-and-process loop by hand. The moment you wire iterable into a for-each and count into a switch, you've turned a detection string into a program. The one surprise to expect: output is a string containing JSON, not a native list socket, so it only helps where the iterator framework accepts JSON text. If your loop framework wants native typed lists, the sibling Bbox Crop and Bbox Mask nodes output IMAGE/MASK lists directly 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"). Needs ComfyUI >= 0.25.0 and Python >= 3.10; dependency is dghs-imgutils[gpu]. No models, no downloads - it's string parsing.

    Troubleshooting

    If count comes back 0 for input you know is valid, the usual culprit is feeding it the wrong socket - the Detect node's detections output (which this parses) versus its json output (which is a differently-structured dict, not the tuple format). Both are strings; only the former is the expected input. And if you paste a bbox string by hand, don't add whitespace inside the coordinate tuples - the regexes are tolerant but not that tolerant.

    Categoryimgutils/utility

    Inputs (1)

    NameTypeDefaultDescription
    bboxesSTRINGRaw bboxes output from imgutils nodes (JSON array or text-tuple format).

    Outputs (3)

    NameTypeDescription
    countINT
    labelsSTRING
    iterableSTRING