Nodes/ComfyUI_ScarlotSoft/ScarlotSoft YOLO Segmenter
ComfyUI Node

ScarlotSoft YOLO Segmenter

YOLO boxes in, clean masks out — with optional SAM surgery

By scarlotsoft·Created 2 months ago·Updated about a month ago· 0
ScarlotSoft YOLO Segmenter
  • image
  • batch_masks
yolo_model
confidence0.30
iou_threshold0.45
sam_model
detection_hintcenter-1

ScarlotSoft YOLOSegmenter finds objects in an image and hands you back their masks: wire an image in, pick a YOLO model, and out comes a MASK (or a batch of them) that hugs whatever the detector found. Masks are the currency of half of ComfyUI - feed them to inpainting, regional prompting, background removal, mask-conditioned sampling, or a detailing loop (see the KB's masking-detection doc for the whole "detect, crop, refine, paste" pattern). This node is the "detect" half, packaged with an optional SAM refinement stage.

The mechanism is the interesting part. In its default fast mode (sam_model set to None (Fast YOLO Masks)), it runs YOLO and takes YOLO's own segmentation masks, interpolated back to the original image size. No SAM, no extra model - fast and cheap. In SAM mode, it loads a Segment-Anything model from your models/sams folder and uses the YOLO boxes as prompts for SAM's high-precision segmentation. The detection_hint dropdown (a list lifted straight from Impact Pack) controls how SAM is prompted - geometric point patterns (center-1, horizontal-2, vertical-2, rect-4, diamond-4), organic point sampling from the YOLO mask pixels (mask-area, mask-points, mask-point-bbox), or box-only (none). More points = tighter masks, slightly slower.

The inputs, in practice:

  • image - what you're detecting.
  • yolo_model - from your ComfyUI/models/scarlotsoft/yolo/ folder. There is no bundled model; until you drop a .pt in there, the dropdown shows only the placeholder "Put .pt in models/scarlotsoft/yolo".
  • confidence (0.3) and iou_threshold (0.45) - the standard YOLO detection knobs. Lower confidence finds more, finds more false positives.
  • sam_model - None (Fast YOLO Masks) by default; pick a SAM checkpoint from models/sams to enable refinement. The filename determines the variant (vit_h/vit_l/else vit_b).
  • detection_hint - the SAM prompting strategy above. Irrelevant in fast mode.

Output is batch_masks, a MASK tensor - one mask per detected object.

Install and the model hunt

Standard pack install - ComfyUI Manager, search "ScarlotSoft", install, restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/scarlotsoft/ComfyUI_ScarlotSoft

Then the real setup: grab a YOLO weights file and drop it in ComfyUI/models/scarlotsoft/yolo/. The community-standard detectors from the KB - face_yolov8n.pt, hand_yolov8n.pt, person_yolov8n-seg.pt - are what most people reach for. Use the -seg (segmentation) variants if you plan to run fast mode: a plain bbox-only model has no masks output, and the fast path silently returns nothing for it, leaving you with an empty mask and a "no objects detected" console line. The node also auto-installs ultralytics and segment-anything on first import - no requirements.txt here - so the first launch can take a while, and on the Windows portable build the auto-pip may miss ComfyUI's embedded Python (install into python_embeded manually if imports fail).

The honest take

Two caveats, both real. First, Ultralytics is AGPL-3.0, which matters if you ship anything commercial built on it; the KB also records the December 2024 Ultralytics supply-chain compromise (a cryptominer that reached ComfyUI users through a detailing pack) - that was a poisoned release, long since fixed, but it's why people in the know are cautious about auto-installed YOLO deps. Second, for plain face/person masking this is more moving parts than the Impact Pack path many workflows already have - but if you're consolidating onto the ScarlotSoft suite, it's a genuinely clean one-node route from image to mask, and fast mode means you don't need SAM at all.

CategoryScarlotSoft/Detectors

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
yolo_modelCOMBO1 options: Put .pt in models/scarlotsoft/yolo
confidenceFLOAT0.300–1
iou_thresholdFLOAT0.450–1
sam_modelCOMBO1 options: None (Fast YOLO Masks)
detection_hintCOMBOcenter-19 options: center-1, horizontal-2, vertical-2, rect-4, diamond-4, mask-area, +3

Outputs (1)

NameTypeDescription
batch_masksMASK