Nodes/Allor Plugin/ImageSegmentation
ComfyUI Node

ImageSegmentation

Cut out subjects with rembg, right inside ComfyUI

By Nourepide·Created 3 years ago·Updated 2 years ago· 295
ImageSegmentation
  • images
  • IMAGE
model
alpha_matting
alpha_matting_foreground_threshold240
alpha_matting_background_threshold20
alpha_matting_erode_size10
post_process_mask

ImageSegmentation is Allor's wrapper around rembg, the workhorse background-removal library. You feed it images, it runs a segmentation model, and out comes the same images with a transparent background baked into a real alpha channel - ready to composite, export as PNG, or feed into the next node. It's the fastest path from "photo with a background" to "cutout" without leaving the graph.

The pack calls itself image-processing-focused and this is the node that justifies it. The mechanism is rembg under the hood: each image is converted from tensor to PIL, passed through rembg.remove(), and converted back to a tensor, so the output is a proper RGBA IMAGE tensor - not a separate mask. That matters because everything downstream that can consume RGBA (compositing, the Allor alpha nodes, PNG save) just works.

The inputs that matter

There are nine model choices, and this is where beginners get confused, so here's the short version:

  • u2net - general-purpose, the historical default. Good all-round, weak on hair and fine edges.
  • u2net_human_seg - people, reliably.
  • u2net_cloth_seg - garment parsing (upper/lower body), if that's your pipeline.
  • isnet-general-use - better edges than u2net; the one to reach for on tricky silhouettes.
  • isnetis - note this one: the node maps it to the isnet-anime model, so it's the pick for illustrations.
  • silueta - same network as u2net in a 43MB package.
  • modnet-p / modnet-w - photographic and webcam portrait segmentation, fast and focused.

The honest take: this node wraps the u2net-era rembg models, not the current BiRefNet ceiling. If your cutout has flyaway hair or semi-transparent material, BiRefNet (now in ComfyUI core) will beat it. But rembg models are fast, tiny, run on CPU, and are absolutely fine for simple backgrounds - the classic use case where they've been "good enough" since 2020.

The other controls mirror rembg's own knobs. alpha_matting (true/false) toggles the refinement pass - turn it on for hair and it uses the three threshold settings (foreground_threshold default 240, background_threshold default 20, erode_size default 10). post_process_mask runs rembg's mask cleanup. You can ignore most of these at first; flip alpha matting on only when a plain cutout looks ragged.

Output: a single IMAGE (RGBA) tensor, one per input image. Wire it to an ImageComposite or a Save Image that keeps alpha.

Installing it

This is the one node in the pack where the dependencies are real, so pay attention:

cd ComfyUI/custom_nodes
git clone https://github.com/Nourepide/ComfyUI-Allor
cd ComfyUI-Allor
pip install -r requirements.txt

requirements.txt installs rembg and onnx. First run of a model downloads the weights automatically (from rembg's GitHub releases), so give it a minute and don't panic if the first queue takes a while. GPU acceleration is optional: pip install onnxruntime-gpu if you want it, but the CPU path is workable at these model sizes. Restart ComfyUI after install - or just search "Allor" in ComfyUI Manager.

Common issues

  • Model weights download on first use. If the first run errors or hangs, check the network; the downloads are one-time.
  • onnxruntime version conflicts. rembg's ONNX dependency is the usual suspect in dependency hell; if another pack pins a different onnxruntime, you may need to reinstall it after updating Allor.
  • The repo rebase. Allor's git history was rewritten to drop images (a ~344x shrink), which can break auto-updates. The docs at nourepide.github.io/ComfyUI-Allor-Doc have dedicated troubleshooting pages.
  • Transparency "disappearing". If your cutout saves with a black or white background, you're saving to a format or through a node that dropped the alpha - use a PNG save and keep the RGBA tensor intact.

Real talk

For simple backgrounds this is genuinely the easiest cutout node in ComfyUI - pick a model, queue, done. Just know its ceiling: this is 2020-era segmentation quality, and the community's current default for hard edges is BiRefNet, which ComfyUI ships in core. Use ImageSegmentation for the fast and easy stuff, and know when to reach past it.

Categoryimage/segmentation

Inputs (7)

NameTypeDefaultDescription
imagesIMAGE
modelCOMBO9 options: u2net, u2netp, u2net_human_seg, u2net_cloth_seg, silueta, isnet-general-use, +3
alpha_mattingCOMBO2 options: true, false
alpha_matting_foreground_thresholdINT240
alpha_matting_background_thresholdINT20
alpha_matting_erode_sizeINT10
post_process_maskCOMBO2 options: false, true

Outputs (1)

NameTypeDescription
IMAGEIMAGE