LayerMask: RmBgUltra V2
RmBgUltra V2 — background removal with matting-grade edge cleanup
- image
- image
- mask
Background removal is a commodity - half a dozen models do it for free and most are good enough for a product shot on a clean background. Where they all fall apart is the same place: hair, fur, fabric mesh, anything with a soft or semi-transparent edge. RmBgUltra V2 is the Layer Style pack's answer, and the "Ultra" is the whole point - it runs a segmentation model to find the subject, then refines the boundary with a matting pass so the edges survive instead of coming out crunchy.
How it works
There are two stages here, and understanding the split is what lets you get good cutouts. First, a background-removal model produces a rough mask of the subject. That's the easy part; every tool does it. The problem, as the knowledge base puts it, is that a segmentation model labels each pixel foreground or background - a hard binary - which is structurally wrong for a strand of hair that's genuinely half-transparent. A cutout that looks clean against a gray preview falls apart when you drop it on a colored background.
The Ultra refinement fixes exactly that. It takes the mask's edge and runs it through a matting algorithm that recovers fractional alpha - partial transparency - along the boundary. That's the difference between a paper-doll cutout and one where the flyaway hair actually blends.
The inputs that matter
image(IMAGE) - the picture to cut out.detail_method- the edge refiner.VITMatteis the quality option (it pulls a matting model on first use);PyMattingandGuidedFilterare lighter and need no download. Start with VITMatte for anything with hair; drop to GuidedFilter if you're tight on VRAM.detail_erode/detail_dilate(both default 6) - how far the refinement reaches inside/outside the mask edge. Widen these if the boundary is being cut too tight or leaving a halo.black_point/white_point- mask contrast. Tighten if the mask leaks gray where it should be solid.max_megapixels(default 2) - caps the resolution the refinement runs at, to keep memory in check on big images.
Outputs are image (the subject with the background removed) and mask - feed the mask into a composite, or into ImageBlendAdvance to drop the subject onto a new scene.
How to install it
ComfyUI Manager: search ComfyUI Layer Style, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/chflame163/ComfyUI_LayerStyle
install requirements.txt, restart. It's under 😺dzNodes → LayerMask. Note this node downloads a background-removal model plus, if you use it, the VITMatte matting weights.
Common issues and troubleshooting
The usual failure is a missing model - the node errors on first run because the segmentation or VITMatte weights didn't download (a flaky HuggingFace connection or a proxy is the usual culprit). The reliable fix is to fetch the model into the pack's model folder by hand and restart; the Segformer nodes in this same pack fail the identical way and the manual clone solves both.
The bigger-picture note: as of 2026, ComfyUI ships BiRefNet natively as its background-removal model, and BiRefNet is the community's default recommendation for exactly the hair-and-fur cases this node targets. So RmBgUltra V2 is a solid, self-contained option, but it's no longer the only game - if your edges aren't clean enough, it's worth testing native BiRefNet (or InSPyReNet, which still wins some head-to-heads) on your three hardest images before committing. And a matting reminder from the knowledge base: for genuinely semi-transparent material - veils, glass, smoke - no segmentation-plus-refinement will match a true matting model. Pick the tool by which failure you can tolerate.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| detail_method | COMBO | 5 options: VITMatte, VITMatte(local), vitmatte-base-composition-1k, PyMatting, GuidedFilter | |
| detail_erode | INT | 61–255 | — |
| detail_dilate | INT | 61–255 | — |
| black_point | FLOAT | 0.010.01–0.98 | — |
| white_point | FLOAT | 0.990.02–0.99 | — |
| process_detail | BOOLEAN | true | — |
| device | COMBO | 2 options: cuda, cpu | |
| max_megapixels | FLOAT | 2.01–999 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |