SegformerNodeMergeSegments
Blur, dilate, feather — the segmentation node with actual dials
- image
- IMAGE
- MASK
- STRING
SegformerNodeMergeSegments is the segmentation node for people who found SegformerNodeMasks too raw. It takes the SegFormer masks, merges the segments you choose, and then lets you clean the result up - blur the edges, dilate the mask, adjust intensity, cap the ceiling - before you ever touch an inpainting node. It's the difference between handing a sampler a hard-edged mask that leaks at the seams and handing it one that's already been feathered for the job.
Think of it as the finishing step. Raw segmentation masks have hard, jagged boundaries that don't match where a diffusion model's denoise actually needs to happen. A few pixels of blur or dilation can be the difference between a clean garment swap and a visible seam. If you've ever stared at an inpainted edge that looks "cut out", this node is the upstream fix you were missing.
How it works
Same SegFormer engine as the rest of the pack, with a post-processing stage bolted on. The image is classified pixel-by-pixel, the segment indices in segments_to_merge_str are combined into one mask, and then the mask gets processed before it's returned.
The inputs that matter:
- image - the image to segment.
- segments_to_merge_str - which segment indices to merge, as a string (e.g.
"0,1"). Runtime-discoverable via the STRING output, same as SegformerNodeMasks. - model_name - the checkpoint dropdown, default
enes361/segformer_b2_clothes. - blur_radius - Gaussian blur applied to the mask edge. Zero leaves it hard; a few pixels softens the boundary so inpainted content blends into the surrounding pixels instead of visibly stopping.
- dilation_radius - grows the mask outward by N pixels. Use this when the mask hugs the subject too tightly and you want to cover the halo of edge pixels the sampler will otherwise leave behind.
- intensity and ceiling - floats that scale and cap the mask values.
intensityof 1.0 leaves values untouched; lower it to make the mask "softer" overall.ceilingcaps the maximum mask value, which is a way to force a partially transparent mask instead of a hard 1.0.
Outputs are the usual trio: IMAGE preview, MASK ready to wire into SetLatentNoiseMask or an inpainting model, and STRING reporting the segments found.
The workflow it enables
The classic chain: generate → SegformerNodeMergeSegments (dilate 2–4px, blur 2–3px) → mask into an inpainting sampler with a "change the outfit" prompt. The mask is doing the real work - SegFormer finds the garment, and the dilation/blur make sure the regeneration actually covers it without a visible boundary. Community outfit-change workflows lean on exactly this pattern with the same segformer_b2_clothes weights.
Install and gotchas
Install once for the whole pack: ComfyUI Manager → search "ComfyUI-LexTools", or clone https://github.com/SOELexicon/ComfyUI-LexTools into custom_nodes and restart. Needs transformers (plus torch/PIL/numpy/scipy, which ComfyUI already has); the model downloads from HuggingFace on first use.
The dials are the trap, honestly. Blur and dilation both look like "make it bigger" but they aren't the same thing - dilation expands the covered region, blur softens the value gradient. Go straight to dilation-8 thinking you're fixing a seam and you'll just inpaint a bigger blob. Start at 2–4 on each and check the preview. And set segments_to_merge_str from the STRING output, not from memory - the indices change between checkpoints.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| segments_to_merge_str | STRING | — | |
| model_name | COMBO | enes361/segformer_b2_clothes | 10 options: enes361/segformer_b2_clothes, mattmdjaga/segformer_b0_clothes, mattmdjaga/segformer_b2_clothes, DiTo97/binarization-segformer-b3, s3nh/SegFormer-b0-person-segmentation, venture361/clothes_segmentation, +4 |
| blur_radius | INT | 0 | — |
| dilation_radius | INT | 0 | — |
| intensity | FLOAT | 1.00 | — |
| ceiling | FLOAT | 1.00 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |
| STRING | STRING | — |