Nodes/XB_ToolBox/XB-BOX - ✂️ 人物分割 (DirectML/ROCm)
ComfyUI Node

XB-BOX - ✂️ 人物分割 (DirectML/ROCm)

Cut a person out of any image with a GPU-accelerated mask

By wjluoxiao·Created 5 months ago·Updated 6 days ago· 302
XB-BOX - ✂️ 人物分割 (DirectML/ROCm)
  • seg_model
  • image
  • 人物蒙版
  • 人物抠图

XB_HumanSegmentation is the actual workhorse of the pack's two-node segmentation pair: image in, person mask and person cutout out. It's built for the "get the human out of the background" job - compositing someone into a new scene, prepping a mask for inpainting, isolating a subject for a digital-human pipeline, or just cleaning up a background removal that an API choked on. The (DirectML/ROCm) in its display name is the tell: this is the segmentation node for people who aren't on NVIDIA, and it's genuinely thoughtful about that.

How it works

Give it a seg_model (the session from XB_HumanSegModelLoader) and an image, and it runs a u2net-style human-segmentation ONNX model at a fixed 320×320 internal resolution. The pipeline: resize the image to 320×320, ImageNet-normalize it, push it through the ONNX session, then bilinearly upscale the output mask back to the original resolution on the GPU. Everything past the ONNX call happens in torch with batch-aware ops, so a batch of images goes through in one shot rather than a Python loop.

The model this is tuned for is the u2net_human_seg checkpoint - a human-specific variant of the classic U-2-Net salient-object network. That's worth a reality check: it's the fast, tiny, CPU-friendly corner of the background-removal world, not the state-of-the-art edge. Fine hair and transparent materials (veils, glass) are where u2net-class models visibly struggle - the sharper-edge, hair-friendly options are BiRefNet and InSPyReNet, which now live natively in ComfyUI. If your subject has tricky edges, this node will give you a mask with some halo or hair loss, and the right move is a matting/refinement model after it.

The outputs

Two wires, both labeled in Chinese:

  • 人物蒙版 (MASK) - the person's mask at full resolution, values 0–1. Feed this into inpainting, compositing, or anything that wants a person-shaped region.
  • 人物抠图 (IMAGE) - the cutout: the original image with the background zeroed out, ready to composite or export with an alpha-equivalent.

Install and gotchas

Pack install as usual (Manager → XB_ToolBox, or git clone + restart), plus onnxruntime from requirements.txt. The model must already be in ComfyUI/models/rembg/ - see the ModelLoader article; this node doesn't download it.

Performance note: the fixed 320×320 internal resolution means a 4K image gets downscaled to nothing and upscaled back - you keep the silhouette, but the edge detail you might have had at native resolution is gone. For 4K work, resize your input down before segmentation (you'll lose nothing) or use a higher-res model. And remember the mask is binary-ish, not a true alpha matte: against a white background a grey preview looks clean, but the same cutout against a busy background shows every edge the u2net missed. Test against your actual background before committing to the composite.

CategoryXB_ToolBox/Segment

Inputs (2)

NameTypeDefaultDescription
seg_modelXB_HUMANSEG_MODEL
imageIMAGE

Outputs (2)

NameTypeDescription
人物蒙版MASK
人物抠图IMAGE