Nodes/Mickmumpitz-Nodes/SEGS Filter by Relative Area
ComfyUI Node

SEGS Filter by Relative Area

Filter Impact's SEGS by how much of the frame they fill

By mickmumpitz·Created 8 months ago·Updated 9 days ago· 47
SEGS Filter by Relative Area
  • segs
  • filtered_SEGS
  • removed_SEGS
area_threshold0.50
keepsmaller_than_threshold

Impact Pack's SEGS Filter (range) only knows absolute pixel areas. That sounds fine until you realize a "small" face on a 1024 image and a "small" face on a 512 image are completely different pixel counts - and if the max value stays at its huge default, nearly frame-filling faces slip straight through. CCC_SEGSRelativeAreaFilter is the fix: it filters SEGS by area as a fraction of the image, so "keep only faces smaller than half the frame" is a threshold you can actually set, in a unit that means something.

It's one of the nodes that assumes you're already running ComfyUI Impact Pack - it takes SEGS in and gives SEGS out, and the README is explicit that it consumes Impact's format. This is the SEGS-detection path to the same goal the face-area nodes serve: detail the small stuff, leave the big stuff alone.

How it works

The inputs are minimal:

  • segs - the SEGS output from an Impact BBOX Detector (SEGS) or similar.
  • area_threshold - a fraction of the image area, 0.5 = 50%. This is the "relative" part that Impact's filter lacks.
  • keep - smaller_than_threshold or larger_than_threshold.

The math is trivial: it computes H × W for the image, divides each SEG's area by that, and routes each detection to one of the two outputs. filtered_SEGS gets the keepers, removed_SEGS gets the rejects - so you never lose data, you just split it. That two-output split is genuinely useful: filter what you detail, but keep the other set if you want to run them through a different (cheaper) path.

The canonical setup, straight from the source: place it between BBOX Detector (SEGS) and DetailerForEach, set keep = smaller_than_threshold with area_threshold = 0.5, and it replaces the old Impact range-filter-plus-math-nodes dance entirely. The faces that fill less than half the frame are exactly the ones worth upscaling and detailing; the frame-filling ones are already as good as the model will get them.

Where it fits

In the Consistent Character Creator face pipeline it sits beside the Face Area nodes, but it's really a general Impact Pack helper - useful in any workflow where you detail small detections and want to skip big ones. Same idea as the FaceDetailer heuristic "crop and resample small faces," expressed as an explicit filter.

Installing it

Ships in Mickmumpitz-Nodes:

cd ComfyUI/custom_nodes
git clone https://github.com/mickmumpitz/ComfyUI-Mickmumpitz-Nodes.git

or Manager → search "Mickmumpitz". You'll also need ComfyUI Impact Pack (and its Subpack if you want the Ultralytics detector provider) for the SEGS in the first place. No extra downloads from this pack - the optional ultralytics dependency only matters for the splitter node that loads its own YOLO, which you don't need if you feed SEGS in from Impact.

Troubleshooting

  • Nothing filtered - check area_threshold in the context of your image size. A 100×100 face is 1% of a 1024 frame but ~9% of a 320×320 frame; the same threshold behaves differently at different resolutions.
  • "Larger" and "smaller" feel flipped - keep selects which output bucket is filtered_SEGS. The threshold itself is direction-agnostic; only the bucket label changes.
  • SEGS format errors - the node expects genuine Impact SEGS. If you wired something SEGS-shaped but not actual SEGS (a mask, a tensor), it'll fail on the shape tuple. Connect a real detector first.
CategoryMickmumpitz/ConsistentCharacterCreator

Inputs (3)

NameTypeDefaultDescription
segsSEGS
area_thresholdFLOAT0.500–1Threshold as a fraction of the image area (0.5 = 50%).
keepCOMBOsmaller_than_threshold2 options: smaller_than_threshold, larger_than_threshold

Outputs (2)

NameTypeDescription
filtered_SEGSSEGS
removed_SEGSSEGS