Nodes/ComfyUI CV/CV Load Labels
ComfyUI Node

CV Load Labels

So your detections say 'dog' instead of '16'

By bmad4ever·Created 3 months ago·Updated 14 days ago· 1
CV Load Labels
    • labels
    • labels_array
    • count
    ◄file▾►

    Every object detector in this pack ultimately emits class ids, because that's what a neural network produces: a row of scores, and the index of the winner. 16 is not a useful answer to "what's in this picture." CV Load Labels reads a plain text file - one class name per line - and hands it to the decoder so your detections come out named. It's a one-line-per-class convention; the file is the mapping.

    What it does

    file is a dropdown listing the .txt files in ComfyUI/models/labels. Line N (0-based) is the name of class id N. Nothing clever, and that's the point - the same COCO label list works for any COCO-trained model no matter which ONNX file you're running, and you can hand-write a three-line file for a three-class custom model.

    Three outputs: labels as a newline-joined STRING, labels_array as a (C,) string array with one row per class id, and count. Which you use depends on the consumer. The pack's decoders (think CV YOLO Detect Decode) take a labels input that is also a multiline text widget - so you can either wire this node in or paste the list straight into the widget. Wiring wins when you keep switching label sets, because the dropdown is checkable and the pasted text is not. labels_array is there for anything that wants indexed access rather than a blob of text.

    Also worth noticing: the pack registers models/labels as a folder path at import, which is why the combo can list the folder at all. Files added while ComfyUI is running won't appear until the node definitions are refetched - reload the page.

    The thing people miss

    The pack doesn't ship the label file. Its README is explicit that models aren't bundled, and the label lists live in the same "you download these yourself" category - model_sources.txt at the repo root records where to get the models and the accompanying label files (the COCO coco-labels-2014_2017.txt style lists are the usual ones). So the sequence is: make ComfyUI/models/labels, drop the .txt in, reload, then pick it.

    And the classic silent failure: if the file's line order doesn't match the model's class ordering, nothing errors - your detections just come out confidently labelled with the wrong names. If you see plausible-but-nonsense labels ("toaster" on a photo of a dog), suspect the file, not the model. There's no checksum or sanity check here; the node trusts you completely.

    Install

    ComfyUI Manager, search comfyui_cv (repo bmad4ever/comfyui_cv). Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/bmad4ever/comfyui_cv
    

    Restart ComfyUI. Requires Python ≥ 3.12 and a recent ComfyUI on the V3 node API - the pack declares nodes with io.ComfyNode/io.Schema and has no NODE_CLASS_MAPPINGS, so older builds don't load it. The one Python dependency:

    pip install "opencv-contrib-python-headless~=5.0.0.93"
    

    Keep it contrib: all four OpenCV wheels share a single site-packages/cv2, and a non-contrib install over a contrib one silently strips the contrib submodules, which makes contrib nodes disappear from the menu with no error in the log at all. The pack ships tools/repair_opencv_contrib.py - --check then --apply.

    Small print

    If you're doing detection work, note that the models this feeds (ONNX detector exports) live outside the pack and a few carry strict licences - yolo26n-seg.onnx is AGPL-3.0 with a network clause, per the pack's own provenance file. Read model_sources.txt before you redistribute anything that runs through this pipeline.

    And the standard caveat from the README: heavy LLM involvement in the codebase, sample-tuned example workflows, updates not planned, and a recommendation not to ship to production without your own review. For a node that reads a text file, that's a five-minute check - but the credit line matters when the label list is what's standing between you and a confidently mislabelled detection.

    Categoryimage/CV/dnn

    Inputs (1)

    NameTypeDefaultDescription
    fileCOMBOLabel .txt file from ComfyUI/models/labels. Line N (0-based) is the name of class id N.

    Outputs (3)

    NameTypeDescription
    labelsSTRINGThe labels, newline-joined. Feed a decoder's 'labels' input (also a multiline widget you can paste into directly).
    labels_arrayNPARRAYThe labels as a (C,) string array, one row per class id.
    countINTNumber of labels read.