Nodes/ComfyUI-UtilsCollection/Face Removal (Preserve Alpha)
ComfyUI Node

Face Removal (Preserve Alpha)

Cut every face out of a group shot as a clean RGBA layer

By silveroxides·Created 3 months ago·Updated 3 days ago· 35
Face Removal (Preserve Alpha)
  • image
  • background_removal_model
  • background_options
  • face_options
  • RGBA Face
  • Face Alpha Mask
background_removal_model_namebirefnet

The name sounds like it deletes faces. It's the opposite: it deletes everything but the faces, and keeps them as individual, background-free RGBA crops with matching alpha masks. Feed it a group photo, a video still with several people, or a batch of portraits, and it hands back one clean face layer per detected face - ready to drop into a composite, an image editor, or anywhere you'd wire a cutout.

It sits in a big utilities pack that's built around a staged compositor family, and this node is basically that compositor's face-cutting primitive exposed on its own. Its sibling UC_BackgroundRemovalPreserveAlpha keeps whole subjects at source resolution; this one zooms in per face, so the two solve different problems. If you want to transplant or rearrange heads, or feed individual faces down a batch pipeline, this is the one.

How it works

There are two detection stages, and they're quietly smart about reuse.

First, the subject cutout. If your input image already has an alpha channel (an RGBA tensor), the node trusts it and skips the removal model entirely - handy for previewing or reusing a mask you made elsewhere. If it's plain RGB, a background-removal model runs. The optional background_removal_model input takes a Core background-removal model object and overrides everything; leave it disconnected and the internal background_removal_model_name selector kicks in - birefnet (the default, and the community's standard cutout model, now shipped inside ComfyUI itself) or lucida.

Second, face detection via the MediaPipe face-landmark model ComfyUI Core bundles (Apache-2.0, so no InsightFace-style non-commercial headache here). Each detected face gets a polygon mask traced from its face-oval landmark ring, then intersected with the subject alpha from stage one - so you only keep pixels that are both face and foreground. By default the crop is expanded 64px around the box so you get context, not a skin-tight cut.

Then the trick that makes the outputs batch-friendly: every crop is centered on transparent padding sized to the largest crop in the batch, so all faces come back at the same canvas dimensions.

Inputs and outputs that matter

  • image - a batched IMAGE. Single images are fine (a Load Image output is already (1, H, W, C)); this node insists on a batch.
  • background_removal_model_name - birefnet or lucida, used only when the model input is disconnected.
  • background_options and face_options - optional config objects from the pack's own UC_StagedLayeredBackgroundCompositeOptions and UC_StagedMediaPipeFaceOptions nodes; disconnect them and defaults apply. The face knobs you'll actually touch live on that options node: detection_threshold, bbox_expansion (how much padding around each face), and face_feather_radius (soften the edge so pasted faces don't look sticker-cut).

Outputs are RGBA Face (an IMAGE batch, straight RGBA - alpha already in the tensor) and Face Alpha Mask (the matching MASK batch). Wire them into the pack's compositor, or ImageFromBatch-style nodes to peel off one face at a time.

Installing

Grab it via ComfyUI Manager (search ComfyUI-UtilsCollection), or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI-UtilsCollection

Then restart ComfyUI. Python dependencies are light (opencv-python, typing-extensions, unifiedefficientloader) - the real requirement is model files. This node wants birefnet.safetensors in ComfyUI/models/background_removal/ and mediapipe_face_fp32.safetensors in ComfyUI/models/detection/. If you've ever run Core's own Remove Background or face-landmark nodes, both are probably already there. If not, the node fails with an error that tells you exactly which URL to download and where to put it - this pack won't silently fetch for you. Note it also needs a recent ComfyUI: it leans on Core's background-removal and MediaPipe internals, so an old install won't have them.

Where people get burned

  • No faces found = hard error. If nothing clears detection_threshold, it raises "No face was detected in the input image batch" rather than returning an empty result. Don't feed it a frame with no human in it.
  • Missing models. First run errors because a .safetensors isn't where Core expects it. The message includes the download link - follow it once and you're done.
  • It needs a 4D batch. A non-batched tensor gets refused. If you're building a workflow by hand, make sure the image socket is actually connected to a proper image source.

Want to iterate fast? Feed it RGBA and it skips model inference entirely - good for checking your detection settings before the expensive pass.

Categoryutils/image

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
background_removal_model_nameCOMBObirefnetInternal model used when background_removal_model_opt is disconnected.
background_removal_modeloptBACKGROUND_REMOVALOptional Core background-removal model. When connected it overrides the internal BiRefNet/Lucida selector.
background_optionsoptUC_STAGED_LAYERED_BACKGROUND_OPTIONS
face_optionsoptUC_STAGED_MEDIAPIPE_FACE_OPTIONS

Outputs (2)

NameTypeDescription
RGBA FaceIMAGE
Face Alpha MaskMASK