BD Human Parser Mask Clean
De-speckle your human parse maps in one pass
- parse_map
- parse_map
Human parsers are powerful and noisy. The 18-class maps they produce are usually right in the broad strokes - hair is hair, jacket is jacket - but the pixel-level output is speckled: stray "bag" pixels inside the jacket, a few hair-colored flecks on the forehead, tiny disconnected blobs everywhere. BD_HumanParserMaskClean is the small cleanup node that scrubs that noise, per class, before you split the map into masks you actually want to use.
It's the middle step in the pack's human-parser trio. The flow you'll usually run: BD Fashn Human Parser (or ATR) → this node → BD Human Parser Mask Split (or Named Mask / Preview). If your downstream masks look like confetti, this is the node that fixes it.
How it works
Three knobs, all optional:
- morph_op -
open(remove specks; erode then dilate),close(fill small holes; dilate then erode), oropen_then_close(both). Defaultopen, which is the speckle-killer. - kernel_size (default 3, odd numbers work best) - the size of the morphological kernel. Larger kernels scrub harder but also eat thin structures like glasses arms and hair wisps.
- min_area (default 64) - drop any connected component smaller than N pixels, per class. This is the "kill the stray blobs" control; 0 turns it off.
The operation runs per class on the class map, so the opening of one region doesn't eat into a neighbor. Pixels stripped from their class fall back to background - which is the right call for most pipelines, since a leftover speck of "bag" floating on "top" is worse than a clean background.
Input is parse_map (HUMAN_PARSE_MAP), output is the cleaned parse_map of the same type. It's in-place, so you can chain it or not - it just hands the map on.
Install
Part of the BrainDead pack:
cd ComfyUI/custom_nodes
git clone https://github.com/BizaNator/ComfyUI-BrainDead
cd ComfyUI-BrainDead
pip install -r requirements.txt
Or search "BrainDead" in ComfyUI Manager and restart. Requires scipy and opencv at runtime - both typical in a ComfyUI environment; pip install scipy opencv-python-headless if you hit an import error.
Troubleshooting
- Still speckly - bump
min_area(128–256) and switchmorph_optoopen_then_close. - Thin details vanished (glasses, hair strands) - your
kernel_sizeis too big. Drop it back toward 1–3. - Masks look fine but boundaries shifted - morphology always eats a pixel or two off edges. That's inherent; account for it by not over-cleaning.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| parse_map | HUMAN_PARSE_MAP | — | |
| morph_opopt | COMBO | open | open=remove specks, close=fill small holes, open_then_close=both. |
| kernel_sizeopt | INT | 31–15 | Morphology kernel side (odd numbers work best). |
| min_areaopt | INT | 640–100000 | Drop connected components smaller than N pixels per class. 0 = off. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| parse_map | HUMAN_PARSE_MAP | — |