Nodes/lzits Nodes/Object Selector
ComfyUI Node

Object Selector

Turn 'person' into a bounding box

By lzitser23·Created 9 months ago·Updated 3 months ago· 0
Object Selector
  • detections
  • x1
  • y1
  • x2
  • y2
  • label
  • confidence
labelperson

YOLOGetBoxes finds all the objects in an image, but "all the objects" is a list - and what your workflow wants is one box: the person, the car, the thing you're about to move. Object Selector is the filter: give it the detection list and a label, and it returns the bounding box of the highest-confidence match, plus the label and confidence.

Inputs

  • detections (type YOLO_DETECTIONS) - straight from YOLOGetBoxes.
  • label - the object class you want, default person. Matching is case-insensitive and whitespace-trimmed.

Outputs

Six of them, designed to plug straight into downstream geometry:

  • x1, y1, x2, y2 (INT) - the box corners in pixels, of the best-matching detection.
  • label (STRING) - the matched label.
  • confidence (FLOAT) - that detection's confidence score, so you know how much to trust it.

The pack's Bounding Box Draw node expects the same x1,y1,x2,y2 shape for its source box, and the source code names that connection explicitly ("Wire the four INT outputs into PrepareObjectMove as the source box" if you use that external object-move node). Either way, the four ints are the standard convention.

The one behavior to know

If no detection matches your label, the node raises an error listing the labels that are available - e.g. "No detection found for label 'car'. Available labels: ['person', 'dog', 'truck']". That's deliberate: it fails loudly instead of silently handing you a zeroed box and making you wonder why your workflow is broken. When multiple objects share the label, it picks the highest-confidence one, not the biggest or the leftmost.

If you've never seen the available labels, run YOLOGetBoxes once and look at its preview output - yellow boxes with class + confidence printed right on the image. Then set the label to match exactly.

Installing this node

One of the 16 nodes in the lzits Nodes pack (Lior Zitser, MIT). Install via ComfyUI Manager (search "lzits Nodes") or:

cd ComfyUI/custom_nodes
git clone https://github.com/lzitser23/lzits-nodes.git

Restart ComfyUI. This node itself is pure Python logic over the detections dict, so no extra dependencies - but the YOLOGetBoxes node it pairs with needs ultralytics (the pack's one hard dependency; install it into ComfyUI's Python if the import error shows up).

Categorylzits nodes

Inputs (2)

NameTypeDefaultDescription
detectionsYOLO_DETECTIONS
labelSTRINGperson

Outputs (6)

NameTypeDescription
x1INT
y1INT
x2INT
y2INT
labelSTRING
confidenceFLOAT