Nodes/ComfyUI-Impact-BIGdetector-BBOX-SEGS/🎯 Cascade Detector Advanced (Bbox/Segm, Staged)
ComfyUI Node

🎯 Cascade Detector Advanced (Bbox/Segm, Staged)

Three YOLO passes in one node β€” and it stops running face detection on torsos

By Devourer56Β·Created 7 months agoΒ·Updated about a month agoΒ· 1
🎯 Cascade Detector Advanced (Bbox/Segm, Staged)
  • image
  • segs_input
  • stage_1_bbox_detector
  • stage_1_segm_detector
  • stage_2_bbox_detector
  • stage_2_segm_detector
  • stage_3_bbox_detector
  • stage_3_segm_detector
  • segs_output_all_stages (Combined)
  • preview_image (Combined Detections)
  • cropped_fragments_image (All Detections)
  • stage1_segs (Stage 1 Results)
  • stage2_segs (Stage 2 Results)
  • stage3_segs (Stage 3 Results)
  • masked_fragments_image (Masked Fragments)
  • image_bypass (Original if No Detections)
β—„modesequentialβ–Ί
β—„target_size640β–Ί
β—„max_size1024β–Ί
β—„iou_threshold1.00β–Ί
β—„include_masks_in_outputtrueβ–Ί
β—„simplify_maskstrueβ–Ί
β—„simplify_kernel_size5β–Ί
β—„simplify_iterations1β–Ί
β—„stage_1_enabledtrueβ–Ί
β—„stage_1_detector_typebboxβ–Ί
β—„stage_1_confidence0.25β–Ί
β—„stage_1_iou_threshold0.45β–Ί
β—„stage_1_dilation0β–Ί
β—„stage_1_classesβ–Ί
β—„stage_1_crop_factor1.0β–Ί
β—„stage_1_scale_modebboxβ–Ί
β—„stage_1_target_size640β–Ί
β—„stage_1_max_size1024β–Ί
β—„stage_1_process_emptytrueβ–Ί
β—„stage1_input_filter_labelsβ–Ί
β—„min_confidence0.00β–Ί
β—„min_bbox_width1β–Ί
β—„min_bbox_height1β–Ί
β—„stage_2_enabledtrueβ–Ί
β—„stage_2_detector_typebboxβ–Ί
β—„stage_2_confidence0.25β–Ί
β—„stage_2_iou_threshold0.45β–Ί
β—„stage_2_dilation0β–Ί
β—„stage_2_classesβ–Ί
β—„stage_2_crop_factor1.0β–Ί
β—„stage_2_scale_modebboxβ–Ί
β—„stage_2_target_size640β–Ί
β—„stage_2_max_size1024β–Ί
β—„stage_2_process_emptyfalseβ–Ί
β—„stage2_input_filter_labelsβ–Ί
β—„stage_3_enabledtrueβ–Ί
β—„stage_3_detector_typebboxβ–Ί
β—„stage_3_confidence0.25β–Ί
β—„stage_3_iou_threshold0.45β–Ί
β—„stage_3_dilation0β–Ί
β—„stage_3_classesβ–Ί
β—„stage_3_crop_factor1.0β–Ί
β—„stage_3_scale_modebboxβ–Ί
β—„stage_3_target_size640β–Ί
β—„stage_3_max_size1024β–Ί
β—„stage_3_process_emptyfalseβ–Ί
β—„stage3_input_filter_labelsβ–Ί
β—„drop_size1β–Ί

This is a single node that runs up to three detection passes - each with its own bbox or segm YOLO model - and hands you one combined SEGS output. The author describes it as either a "magnifying glass" or a "big detector," and both halves are right. Chained together, each stage re-detects inside what the previous stage found, which is how you reliably find small stuff that a first pass on the full image would miss. Run the stages in parallel and you've got a single node that merges three different detectors' results with NMS, the way you'd otherwise assemble with a pile of SEGSPreview and SEGSConcat nodes.

The genuinely useful trick is input label filtering. Each stage takes a comma-separated list of labels and only processes segments with those labels from the previous stage - so stage 2 can run eye detection exclusively on the face segments stage 1 produced, instead of pointlessly scanning arms and torsos for eyes. stage2_input_filter_labels = "face" is the whole workflow, right there.

How it works

Each stage has its own detector (bbox or segm), confidence, IoU threshold, dilation, class filter, crop factor, scale mode, and target/max size. In sequential mode, stage 2 detects inside the crops of stage 1; in parallel mode every enabled stage runs independently on the full image and the results are merged with NMS against the top-level iou_threshold; parallel_per_segment runs each detector independently on each segment.

The part worth knowing about is masks. When a downstream stage detects on an upscaled crop ("enlarged fragments"), the node recalculates each mask back into the original image's coordinate space as a numpy array - the author's flagship fix, and the thing that makes it work with non-square images like 1152Γ—1280 and with Impact Pack's SEG objects, which historically hate mismatched mask shapes. There's also simplify_masks (morphological closing with an elliptical kernel) to smooth those recalculated masks out.

The inputs that matter

  • mode - sequential vs parallel. Start here; it changes what the stage settings mean.
  • stage_N_detector_type plus the matching stage_N_bbox_detector / stage_N_segm_detector - you wire Impact Pack's UltralyticsDetectorProvider into these. That's where the actual YOLO models (like face_yolov8m.pt) come from and download on first use.
  • stageX_input_filter_labels - the headline feature. Comma-separated labels; empty means process everything.
  • include_masks_in_output - keep this true. The README is blunt: most nodes that consume SEGS error out or misbehave without masks attached.

After the cascade, min_confidence, min_bbox_width, and min_bbox_height prune weak or tiny detections, and drop_size feeds the detectors' own filtering.

Outputs

segs_output_all_stages is the main one - wire it into SEGSPaste or SEGSDetailer from Impact Pack. preview_image draws the boxes (color-coded per stage), cropped_fragments_image is a contact sheet of every crop, masked_fragments_image shows just the masked interiors, and stage1/2/3_segs give you each stage's results separately. image_bypass is a nice fallback: it returns the original image when nothing was found and a black frame otherwise, so a downstream branch can skip gracefully when detection comes up empty.

Installing it

ComfyUI Manager - search "ComfyUI-Impact-BIGdetector-BBOX-SEGS" - or:

cd ComfyUI/custom_nodes
git clone https://github.com/Devourer56/ComfyUI-Impact-BIGdetector-BBOX-SEGS

then restart ComfyUI. The pack ships no requirements.txt: it uses numpy, cv2, torch, and PIL, all already in ComfyUI. What you actually need is Impact Pack installed separately, plus its YOLO models.

Honest caveats

Set expectations before you build a masterpiece on this. The README's foreword admits the node was generated with AI in half a day "for my own needs," the previews are self-described as "so-so" (use Impact Pack's SEGSPreview), and the author's announcement post landed with zero engagement - this is a personal utility that happens to be public, not a maintained ecosystem staple. The stages are hardcoded to three, so don't expect a 5-stage pipeline without editing source. And since it leans on Impact Pack's Ultralytics stack, keep both updated - that dependency chain is exactly how the December 2024 compromised-Ultralytics cryptominer reached ComfyUI installs. All that said, if you've ever stacked three FaceDetailer-style passes manually, this node collapses the whole cascade into one block with per-stage settings you can actually read.

CategoryDetection/Cascade

Inputs (56)

NameTypeDefaultDescription
imageIMAGEβ€”
modeCOMBOsequential3 options: sequential, parallel, parallel_per_segment
target_sizeINT64064–16384β€”
max_sizeINT102464–16384β€”
iou_thresholdFLOAT1.000–1β€”
include_masks_in_outputBOOLEANtrueβ€”
simplify_masksBOOLEANtrueβ€”
simplify_kernel_sizeINT51–21β€”
simplify_iterationsINT11–10β€”
segs_inputoptSEGSβ€”
stage_1_enabledoptBOOLEANtrueβ€”
stage_1_detector_typeoptCOMBObbox2 options: bbox, segm
stage_1_bbox_detectoroptBBOX_DETECTORβ€”
stage_1_segm_detectoroptSEGM_DETECTORβ€”
stage_1_confidenceoptFLOAT0.250–1β€”
stage_1_iou_thresholdoptFLOAT0.450–1β€”
stage_1_dilationoptINT0-512–512β€”
stage_1_classesoptSTRINGβ€”
stage_1_crop_factoroptFLOAT1.01–10β€”
stage_1_scale_modeoptCOMBObbox3 options: bbox, crop_region, fixed
stage_1_target_sizeoptINT64064–16384β€”
stage_1_max_sizeoptINT102464–16384β€”
stage_1_process_emptyoptBOOLEANtrueβ€”
stage1_input_filter_labelsoptSTRINGComma-separated labels to PROCESS on Stage 1 (e.g., 'person,car'). Empty = process all input segments.
min_confidenceoptFLOAT0.000–1β€”
min_bbox_widthoptINT11–16384β€”
min_bbox_heightoptINT11–16384β€”
stage_2_enabledoptBOOLEANtrueβ€”
stage_2_detector_typeoptCOMBObbox2 options: bbox, segm
stage_2_bbox_detectoroptBBOX_DETECTORβ€”
stage_2_segm_detectoroptSEGM_DETECTORβ€”
stage_2_confidenceoptFLOAT0.250–1β€”
stage_2_iou_thresholdoptFLOAT0.450–1β€”
stage_2_dilationoptINT0-512–512β€”
stage_2_classesoptSTRINGβ€”
stage_2_crop_factoroptFLOAT1.01–10β€”
stage_2_scale_modeoptCOMBObbox3 options: bbox, crop_region, fixed
stage_2_target_sizeoptINT64064–16384β€”
stage_2_max_sizeoptINT102464–16384β€”
stage_2_process_emptyoptBOOLEANfalseβ€”
stage2_input_filter_labelsoptSTRINGComma-separated labels to PROCESS on Stage 2 (e.g., 'face'). Empty = process all Stage 1 results.
stage_3_enabledoptBOOLEANtrueβ€”
stage_3_detector_typeoptCOMBObbox2 options: bbox, segm
stage_3_bbox_detectoroptBBOX_DETECTORβ€”
stage_3_segm_detectoroptSEGM_DETECTORβ€”
stage_3_confidenceoptFLOAT0.250–1β€”
stage_3_iou_thresholdoptFLOAT0.450–1β€”
stage_3_dilationoptINT0-512–512β€”
stage_3_classesoptSTRINGβ€”
stage_3_crop_factoroptFLOAT1.01–10β€”
stage_3_scale_modeoptCOMBObbox3 options: bbox, crop_region, fixed
stage_3_target_sizeoptINT64064–16384β€”
stage_3_max_sizeoptINT102464–16384β€”
stage_3_process_emptyoptBOOLEANfalseβ€”
stage3_input_filter_labelsoptSTRINGComma-separated labels to PROCESS on Stage 3 (e.g., 'eyes,nose'). Empty = process all Stage 2 results.
drop_sizeoptINT11–100β€”

Outputs (8)

NameTypeDescription
segs_output_all_stages (Combined)SEGSβ€”
preview_image (Combined Detections)IMAGEβ€”
cropped_fragments_image (All Detections)IMAGEβ€”
stage1_segs (Stage 1 Results)SEGSβ€”
stage2_segs (Stage 2 Results)SEGSβ€”
stage3_segs (Stage 3 Results)SEGSβ€”
masked_fragments_image (Masked Fragments)IMAGEβ€”
image_bypass (Original if No Detections)IMAGEβ€”