SEGS Classify
Filter detected regions by a classifier score
- classifier
- segs
- ref_image_opt
- filtered_SEGS
- remained_SEGS
- detected_labels
Once you've detected a bunch of regions, sometimes you want to treat them differently based on what they are. SEGS Classify runs a HuggingFace classifier over each detected region and splits your SEGS into two piles based on a rule you write: the ones that match go out one output, the ones that don't go out the other. Detect all the faces, then separate the ones classified as female from the ones classified as male, and prompt each pile differently. That's the kind of thing this enables.
It's a niche node - you only need it when a workflow has to branch on an attribute of a detection - but when you need it, nothing else in the pack does the job. It's the filter half of Impact Pack's little classification subsystem; the loader half is the HF Transformers Classifier Provider.
How it works
You feed it a classifier (from the provider node) and your segs. For each region, it crops the area, runs the classifier, gets label scores, and evaluates your expression against them. Regions where the expression is true go to filtered_SEGS; the rest go to remained_SEGS. The expression is a simple comparison like male > 0.5 or female <= 0.4 - label name, operator, threshold.
The inputs and outputs that matter
classifier- theTRANSFORMERS_CLASSIFIERfrom an HF Transformers Classifier Provider. Required.segs- the detected regions to sort.preset_expr- a dropdown of ready-made expressions (#Female > #Male,female > 0.5,Age16to25 > 0.1, etc.), ending inManual expr. The#Female/#Maleforms are convenience symbols that group several related labels (woman, women, female…) rather than a single label.manual_expr- when the preset isManual expr, write your own rule here, e.g.male <= 0.4. The label name must match what the classifier actually outputs.ref_image_opt(optional) - an alternate image to classify against.
Outputs: filtered_SEGS (regions matching the expression), remained_SEGS (the rest), and detected_labels (a string list of what was found) - great for debugging when a filter isn't behaving.
How to install it
Ships with the Impact Pack. ComfyUI Manager: search ComfyUI Impact Pack, Install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack comfyui-impact-pack
cd comfyui-impact-pack
pip install -r requirements.txt
then restart. You also need the HF Transformers Classifier Provider (same pack) to supply the classifier, and its model downloads from HuggingFace on first use.
Common issues & troubleshooting
Everything ends up in one pile. Your expression's label name probably doesn't match the classifier's actual labels, so the comparison never evaluates the way you think. Wire the detected_labels output to a preview and look at what the model is really outputting - then write the expression against those exact names. The README points you at the target repo's config.json for the supported labels.
The #Female / #Male shorthand behaves oddly. Those aren't single labels - they're groups that stand in for a bundle of related labels for convenience. If you need a precise single-label threshold, use the raw label name in manual_expr instead of the # symbol.
Filtered and remained look swapped. Remember the rule is match → filtered_SEGS, non-match → remained_SEGS. If you wanted the opposite set, either invert the comparison operator or just swap which output you use downstream.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| classifier | TRANSFORMERS_CLASSIFIER | — | |
| segs | SEGS | — | |
| preset_expr | COMBO | 7 options: #Female > #Male, #Female < #Male, female > 0.5, male > 0.5, Age16to25 > 0.1, Age50to69 > 0.1, +1 | |
| manual_expr | STRING | — | |
| ref_image_optopt | IMAGE | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| filtered_SEGS | SEGS | — |
| remained_SEGS | SEGS | — |
| detected_labels | STRING | — |