LayerMask: Object Detector YOLO8(Advance)
Object Detector YOLO8 — ComfyUI Node Guide
- image
- bboxes
- preview
Not to be confused with YoloV8 Detect elsewhere in this pack, despite the near-identical name - that node outputs masks directly. This one outputs BBOXES, plain bounding-box coordinates, meant to be handed off to another node (SAM2Ultra, DrawBBoxMaskV2, whatever your pipeline needs) rather than turned into a mask on the spot. If your goal is "just give me a mask of the faces in this image," YoloV8 Detect is the more direct path. If you need the box data itself - say, to feed SAM2 for a cleaner segmentation than a raw YOLO mask would give you - this is the one you want.
The mechanism is standard YOLOv8 object detection: run the model, get boxes with confidence scores, sort and filter them per your settings, and hand back the coordinates plus a preview.
Inputs:
image- your source.yolo_model- populated from whatever checkpoints you've placed in the models folder; unlikeYoloV8 Detect, this node doesn't care whether the model has "seg" in the name, since it's only extracting boxes, not tracing outlines.sort_method-left_to_right,top_to_bottom,big_to_small, orconfidence.bbox_select-all,first(highest confidence), orby_index.select_index- used withby_index; defaults to"0,", accepts multiple values separated by pretty much any non-numeric character.
Outputs: bboxes (the BBOXES object this pack's detection pipeline shares across nodes) and preview, a rendering of the detected boxes so you can confirm what got caught before wiring it further downstream.
Installing it: ComfyUI Manager, search "ComfyUI Layer Style Advance," or git clone https://github.com/chflame163/ComfyUI_LayerStyle_Advance into custom_nodes, then install_requirements.bat (or Aki variant) / pip install -r requirements.txt, then repair_dependency.bat, restart. Model files come from GoogleDrive or BaiduNetdisk (linked in the README) into ComfyUI/models/yolo - the same folder and same model files YoloV8 Detect uses, so if you've already set that node up, this one has nothing extra to fetch.
Why you'd chain this into SAM2 instead of just using YOLO's own mask output: YOLO's segmentation masks (even from a seg-suffixed model) are generally rougher around the edges than what a dedicated matting model like SAM2 with VITMatte refinement can produce. The pattern this pack expects - detect with YOLO8, refine with SAM2Ultra - mirrors the same GroundingDINO-plus-SAM pairing that's become standard across the ecosystem for a reason: a fast, class-aware detector finds where, and a segmentation-focused model handles the precise what.
Where people get stuck: picking the wrong node for the job is honestly the most common mix-up here - reaching for this when you actually just wanted a fast mask, which is what YoloV8 Detect gives you directly with less setup. Use this one specifically when you're building a detect-then-refine chain, not as a general-purpose "find stuff" node on its own.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| yolo_model | COMBO | 0 options: | |
| sort_method | COMBO | 4 options: left_to_right, top_to_bottom, big_to_small, confidence | |
| bbox_select | COMBO | 3 options: all, first, by_index | |
| select_index | STRING | 0, | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| bboxes | BBOXES | — |
| preview | IMAGE | — |