Nodes/comfyui_cv/CV YOLO Seg Masks
ComfyUI Node

CV YOLO Seg Masks

Builds one binary instance MASK per detection from the 'det_rows' of 'CV YOLO Detect Decode' (whose extra columns carry the mask coefficients) plus the model's (1, C, mh, mw) mask-prototype map. Mirrors ultralytics ops.process_mask: logits = coeffs @ proto, crop to the box in proto space, bilinear-upsample to the letterboxed input, threshold at 0 (sigmoid > 0.5), then un-letterbox back to the original image. Only the NMS-free seg layout carries coefficients - a detection-only model or layout raises a clear wiring error here. Zero detections is a valid result (empty mask batch). DATA only - visualize with 'Overlay Masks'. Processes a single image (the first frame of a batch).

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV YOLO Seg Masks
  • det_rows
  • proto
  • image
  • masks
  • mask_count
ratio1.000
pad_left0
pad_top0
net_size640
Categoryimage/CV/dnn

Inputs (7)

NameTypeDefaultDescription
det_rowsNPARRAYThe (N, 6+C) 'det_rows' from 'CV YOLO Detect Decode' (NMS-free seg layout): [x1, y1, x2, y2, conf, class_id, C mask coefficients] in LETTERBOXED pixels.
protoNPARRAYMask-prototype map, (1, C, mh, mw) or (C, mh, mw). C must equal the number of mask coefficients per det row.
imageNPARRAY,IMAGEThe ORIGINAL image (before letterboxing) - its size is the mask target size. An IMAGE batch uses its first frame. Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size.
ratioFLOAT1.0000.000001–100Letterbox resize ratio from 'CV DNN Letterbox' (1.0 if the image was not letterboxed).
pad_leftINT00–4096Letterbox left padding from 'CV DNN Letterbox'.
pad_topINT00–4096Letterbox top padding from 'CV DNN Letterbox'.
net_sizeINT64032–4096Square letterboxed input size the model ran at (the 'size' used in 'CV DNN Letterbox').

Outputs (2)

NameTypeDescription
masksMASK(N, H, W) binary instance masks at the original image size, aligned row-for-row with the Detect Decode bboxes. Feed 'Overlay Masks' or any mask consumer.
mask_countINTNumber of masks built (= the detection count).