Nodes/ComfyDL/VOC Classes
ComfyUI Node

VOC Classes

The 21 names behind every PASCAL VOC segmentation label

By Cynthia-lxx·Created 2 months ago·Updated 3 days ago· 6
VOC Classes
    • class_names
    index-1

    Every time a segmentation model outputs class index 3, something has to tell you that 3 means "bird." CdlVocClasses is that something. It holds the PASCAL VOC 21-class list - background, aeroplane, bicycle, bird, boat, bottle, bus, car, cat, chair, cow, diningtable, dog, horse, motorbike, person, potted plant, sheep, sofa, train, tv/monitor - and hands you either the whole list or a single class by index.

    It's a constant, basically - the VOC_CLASSES table from the d2l segmentation chapter, exposed as a node. The design is simple: one index widget, and you get either one class name or all of them. Set index to -1 (the default) and it returns all 21 as a comma-separated string. Set it to, say, 15 and it returns just person. That's the entire node. It's the reference card you keep on the canvas so you never have to remember which index is sheep and which is potted plant - because there are several entries in that list you'll absolutely mix up.

    Inputs

    • index - an INT, default -1 (all classes), range −1 to 20. Any value 0–20 returns that single class name; -1 returns the full list.

    Output

    One output: class_names, a STRING. Either one class name or the full comma-separated list. Handy to wire into a display node as a legend next to a segmentation visualization - it's the human-readable key for whatever label tensor you're looking at.

    Installing it

    Part of ComfyDL. ComfyUI Manager, search "ComfyDL". Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Cynthia-lxx/ComfyDL
    pip install -r ./ComfyDL/requirements.txt
    

    Restart ComfyUI. Only matplotlib for the pack; no downloads.

    Gotchas

    There's almost nothing to break here, which makes the honest advice short: use it as your legend. When you're reading a VOC Label Indices output - a [H, W] mask where pixel value 15 is person - this node is how you decode that number without counting on your fingers. One thing worth knowing: the class order is the standard VOC order, background first, so index 0 is never a real object. That ordering is the one detail you must not re-sort; if you ever remap these indices for a custom dataset, keep the table straight or your labels will be silently wrong. Niche pack, zero community signal, but a constant table can't really fail - the risk is you misremembering index 7 vs index 8, which is exactly what the node exists to prevent.

    Categoryd2l/Segmentation

    Inputs (1)

    NameTypeDefaultDescription
    indexINT-1-1–20

    Outputs (1)

    NameTypeDescription
    class_namesSTRING