Nodes/ComfyUI_LayerStyle_Advance/LayerMask: Ben Ultra(Advance)
ComfyUI Node Runs on cloud

LayerMask: Ben Ultra(Advance)

Background removal with PramaLLC's BEN model, plus optional edge refinement

By chflame163·Created 2 years ago·Updated 4 months ago· 696
LayerMask: Ben Ultra(Advance)
  • ben_model
  • image
  • image
  • mask
detail_method
detail_erode4
detail_dilate2
black_point0.01
white_point0.99
max_megapixels2.0
process_detailfalse

BenUltra cuts the subject out of an image using BEN (Background Erase Network) from PramaLLC - one of the models that launched in early 2025 with vendor benchmarks claiming an edge over RMBG2/BiRefNet on speed. Worth saying plainly: those numbers came from the model's own creators, not an independent test, and BEN never built the kind of ongoing community traction that made BiRefNet the default recommendation for this job. That's not a reason to avoid it - it's a reason to actually compare it against whatever you're currently using on your three hardest images (flyaway hair, semi-transparent fabric, busy backgrounds) rather than assuming it wins because it's newer.

It needs a ben_model fed in from the companion LoadBenModel node - this node does the cutting, LoadBenModel does the loading, same split pattern as the pack's other model-backed Ultra nodes.

The inputs and outputs that matter

  • ben_model / image - required. Model comes from LoadBenModel, where you pick between BEN_Base and BEN2_base (the newer, second-generation weights).
  • detail_method - VITMatte, VITMatte(local), vitmatte-base-composition-1k, PyMatting, or GuidedFilter. This runs on top of BEN's own output to refine the edge further.
  • detail_erode (default 4) / detail_dilate (default 2) - shrink/grow the boundary before the refinement pass runs.
  • black_point (0.01) / white_point (0.99) - edge sampling thresholds for the refinement.
  • max_megapixels (default 2) - resolution cap for the detail pass, mainly relevant if you're running VITMatte.
  • process_detail - defaults to off here, unlike most of the pack's other Ultra nodes. That's a real signal: BEN's raw edges are apparently considered good enough on their own most of the time, so the extra matting pass is opt-in rather than automatic. Turn it on if you're seeing rough hair or fur edges and want the refinement; leave it off for speed on straightforward subjects.

Outputs are image (the cutout) and mask.

Installing it

ComfyUI Manager: search "ComfyUI Layer Style Advance". Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/chflame163/ComfyUI_LayerStyle_Advance.git

Run install_requirements.bat (portable) or install requirements.txt yourself, then restart.

Model download is separate and required. Grab the BEN weights from the author's HuggingFace repo (chflame163/ComfyUI_LayerStyle, ComfyUI/models/BEN) or the BaiduNetdisk mirror, and copy them into ComfyUI/models/BEN. If you plan to use VITMatte as the detail method, that's yet another separate download - hustvl/vitmatte-small-composition-1k into ComfyUI/models/vitmatte.

Common issues

No model in the dropdown. That's LoadBenModel, not BenUltra - nothing's in ComfyUI/models/BEN yet.

Result looks fine in a grey-background preview but falls apart when composited onto something colorful. Classic segmentation-vs-matting symptom: a hard mask can look clean in isolation and still be wrong on genuinely semi-transparent material (veils, smoke, glass). If that's what you're fighting, turn process_detail on and try VITMatte, or accept that BEN - like every segmentation model in this pack - isn't built to represent fractional transparency, only a foreground/background split.

ValueError: Trimap did not contain foreground values. This is a known LayerStyle Advance error when using PyMatting as the detail method and the mask area is too large or too small for it to build a usable trimap. Adjust detail_erode/detail_dilate to change the effective mask area, or switch to a different detail_method.

Cannot import name 'guidedFilter' from 'cv2.ximgproc'. A dependency version mismatch (opencv-contrib-python conflicting with another opencv package). Run repair_dependency.bat in the plugin folder.

Category😺dzNodes/LayerMask

Inputs (9)

NameTypeDefaultDescription
ben_modelBEN_MODEL
imageIMAGE
detail_methodCOMBO5 options: VITMatte, VITMatte(local), vitmatte-base-composition-1k, PyMatting, GuidedFilter
detail_erodeINT41–255
detail_dilateINT21–255
black_pointFLOAT0.010.01–0.98
white_pointFLOAT0.990.02–0.99
max_megapixelsFLOAT2.01–999
process_detailBOOLEANfalse

Outputs (2)

NameTypeDescription
imageIMAGE
maskMASK