YOLO Detection & Selection
Find the Biggest, Most Confident, or Center-most Thing in Your Image
- image
- image
- preview_with_boxes
- mask
- x
- y
- width
- height
- x2
- y2
YOLO Detection & Selection (class YOLODetectionNode) is the static half of the ComfyUI-YoloTrack pack - the one you reach for when the tracking node's video machinery is overkill. It runs YOLOv8 on a batch of images, sorts every detection by whatever you care about, and hands back the pick plus a mask and the box coordinates. The key word is Selection: raw YOLO gives you a pile of boxes, but you usually want exactly one, and this node bakes that decision into a dropdown.
That's the pattern: detect an object, feed its mask or region into an inpaint, a crop-and-upscale chain, or a masked refinement pass. It's the same detect-crop-refine idea Impact Pack made famous, minus the video smoothing - right tool when you're processing stills or a few keyframes, not whole sequences.
How it works
The mechanism is refreshingly honest: per image, YOLO inference runs with confidence_threshold and nms_threshold passed straight through, detections get filtered by class_ids, then sorted by select_criteria. The top select_count are kept. The select_criteria menu is where the real power is:
- Area Max / Area Min - biggest or smallest object
- Confidence Max / Min - the most sure (or least sure) detection
- Center Top / Bottom / Left / Right and Center Nearest - positional picks
- Nearest to History / Farthest from History - on a batch of frames, these keep choosing the object closest to (or furthest from) where previous picks were. It's a poor-man's tracker: no smoothing, but it does make the node stick to one subject across a video batch.
output_mode changes the output semantics. Merged Mask fills all selected boxes into one mask and reports the union bounding box in the coordinate outputs. Individual Objects emits per-selection outputs, so with select_count of 3 you get a batch of three masks and per-object coordinates. Note that if nothing is detected, the node returns zeros and 0,0,0,0 coords instead of crashing - which means downstream nodes won't explode, but you should still check width before trusting the crop.
Outputs: image, preview_with_boxes (green boxes + labels on the original), mask, and x, y, width, height, x2, y2.
The inputs that matter
select_criteria- the whole point of the node; Center Nearest is the classic "give me the thing in the middle" pick.output_mode- Merged Mask for one mask to feed an inpaint; Individual Objects for per-target work.confidence_threshold- default 0.5 is fine; raise to 0.7 to kill false positives, drop to 0.3 when detections are being missed.class_ids(optional) - comma-separated COCO ids,0= person,2= car, blank = all 80 classes.
Installing it
Same pack, same steps as the tracking node. ComfyUI Manager: search YoloTrack. Or manually:
cd ComfyUI/custom_nodes/
git clone https://github.com/tppp2806/ComfyUI-YoloTrack
cd ComfyUI-YoloTrack
pip install -r requirements.txt
Then restart ComfyUI. Put .pt files in ComfyUI/models/yolo/; if the folder's empty, the dropdown shows the stock five (yolov8n–yolov8x) and Ultralytics auto-downloads whichever you pick on first run. n/s for speed, l/x for accuracy.
Gotchas
- The README's clone command has a placeholder
your-usernamein it - use the URL above. - Coordinates are in the pixel space of whatever you fed in. If you resized images upstream, those coords are in resized space, not original.
- Nothing detected? Lower the confidence threshold, double-check
class_idsformatting (0,2, no spaces needed), and confirm the model actually downloaded. - This node pulls Ultralytics - AGPL-licensed, and the same dependency that carried a cryptominer supply-chain incident in December 2024. Fine for personal use, worth noting before you ship a workflow that depends on it.
If you want the same selection logic but with stabilization, a crop ratio, and preview marks, that's the tracking node in this pack. This one is the simpler, more predictable sibling.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| model_name | COMBO | 5 options: yolov8n.pt, yolov8s.pt, yolov8m.pt, yolov8l.pt, yolov8x.pt | |
| select_criteria | COMBO | 11 options: Area Max, Area Min, Confidence Max, Confidence Min, Center Top, Center Bottom, +5 | |
| select_count | INT | 11–100 | — |
| confidence_threshold | FLOAT | 0.500–1 | — |
| nms_threshold | FLOAT | 0.400–1 | — |
| output_mode | COMBO | 2 options: Merged Mask, Individual Objects | |
| class_idsopt | STRING | — |
Outputs (9)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| preview_with_boxes | IMAGE | — |
| mask | MASK | — |
| x | INT | — |
| y | INT | — |
| width | INT | — |
| height | INT | — |
| x2 | INT | — |
| y2 | INT | — |