Apply Yolov8 Model Seg
Pixel-perfect instance masks from YOLOv8, without touching SAM
- yolov8_model
- image
- IMAGE
- MASK
If you've been getting by with bounding boxes and quietly wishing you had pixel masks instead, this is the node that ends that. Apply Yolov8 Model Seg is the segmentation sibling of the pack's detection node: same idea, but every object it finds comes out as a proper per-pixel mask instead of a rectangle.
The whole "intelligent masking" tier of ComfyUI usually means loading SAM and a GroundingDINO-style proposal model - heavy, slow, and fiddly. YOLOv8's segmentation variant does it in one pass, one model, no prompt engineering. It's not SAM-grade on weird or cluttered scenes, and it only knows the 80 COCO classes, so you can't say "mask the coffee mug" unless a mug is in the list. But for "mask all the people," "mask all the cars," or building a segmentation training set, it's dramatically less machinery for 95% of the job.
How it works
Same plumbing as Apply Yolov8 Model, minus the JSON output. It runs the YOLO model with your confidence threshold, draws the standard annotated image via Ultralytics' plot(), and then - the key difference - reads result.masks.data from each detected instance. Those per-instance masks get summed into a single mask per frame, so one MASK tensor comes out containing every detected object's coverage. Bright where objects are, black elsewhere, ready to wire into anything that takes a mask input.
The crucial prerequisite: you need a -seg checkpoint. Pick yolov8s-seg, yolov8m-seg, etc. on Load Yolov8 Model - the segmentation head only exists in those weights, and feeding this node a plain detection model fails when it goes looking for result.masks. This is the #1 way people hit an error on this node.
Inputs and outputs
Same detection controls as the detect node:
- detect -
all,choose, orinput.choose= single class from the 80-class dropdown;input= comma-separated names in label_name. - label_name - comma list, default
person,cat,dog. Same gotcha as the detect node:allstill funnels through this string, so the default filters to people, cats and dogs - type what you actually want. - threshold - confidence cutoff, default 0.25.
Outputs are just two: IMAGE (annotated) and MASK (the combined instance masks). No JSON here - if you need the Labelme annotations plus segmentation, you pair the seg node with the detection node in parallel, or accept that this pack keeps detection and segmentation slightly separate.
When to reach for it
Honestly, this is the one I'd actually use from the pack for creative work. A classic loop: generate an image, mask all the people with this node, and drive an inpaint or background swap off that mask - no SAM download required. The sample workflow in the repo shows exactly that shape (Apply Seg → MaskToImage → Image Overlay → preview), which is the quickest way to see it working.
Install is the pack install - ComfyUI Manager search Comfyui-Yolov8-JSON, or:
cd ComfyUI/custom_nodes
git clone https://github.com/prodogape/Comfyui-Yolov8-JSON
then pip install -r requirements.txt for ultralytics (plus numpy/torch/PIL) and a restart. If you hit No module named 'ultralytics' on a Windows portable build, install it manually in the embedded Python. And remember the Ultralytics weights are AGPL-reached - fine for personal projects, a licensing conversation before you ship something commercial around them.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| yolov8_model | YOLOV8_MODEL | — | |
| image | IMAGE | — | |
| detect | COMBO | all | 3 options: all, choose, input |
| label_name | STRING | person,cat,dog | — |
| label_list | COMBO | person | 80 options: person, bicycle, car, motorcycle, airplane, bus, +74 |
| threshold | FLOAT | 0.250.01–1 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |