Remove Mouth Background
Clean mouth shapes without building a green screen rig
- images
- images
- masks
If you're doing any non-human lip sync, the awkward part is never the mouth shapes themselves - it's that your A.png through H.png mouth images come with a background baked in. Paste those onto a tracked face and you get a moving rectangle instead of a mouth. Remove Mouth Background exists to kill that problem in one node: feed it your mouth shape images and it returns them with alpha, ready to composite.
It's part of the TrentNodes lip sync family (this pack also gives you Audio To Phonemes, Mouth Shape Compositor, Point Tracker, and friends), but it's deliberately standalone. You can use it to key out any small image set, not just mouth shapes - icons, stickers, sprites, whatever you're about to overlay.
How it works
The method input picks the keying strategy, and it's the one setting that actually matters:
birefnet(default) - runs BiRefNet, the segmentation network that's become the ecosystem's default background remover. It's the good option: BiRefNet's whole claim to fame is surviving hair, fur, and soft edges, which is exactly what a mouth shape made of fuzzy lip edges needs.color_key- a classic chroma-style key against a solid background. Fast, no model, but only worth it if your mouth images are already on a clean white or black background.auto- tries BiRefNet, falls back to color key.
Under BiRefNet you get quality (fast/balanced/quality maps to 512/768/1024 px processing) and model (lite vs standard). Don't sleep on quality - the 512 px fast tier is fine for a 240 px mouth image, and it's meaningfully quicker.
The color key branch has its own knobs: bg_color (white or black), threshold (higher removes more), expand_mask, and feather. A couple of pixels of feather on a cutout is usually the difference between "crisp" and "stuck on" when you composite.
The inputs and outputs you'll actually touch
Required: images - your batch of mouth shape images (the node's tooltip says "batch of 9 or any", so the standard A–H plus X set slots right in).
Outputs are the two you'd guess: images (cutout with alpha) and masks (the clean matte). The output_format enum decides how the alpha is packed - rgba is the safe default; premultiplied can fight your compositor if it isn't premultiplied-aware.
Installing it
This is one of ~69 nodes in the TrentNodes pack, so you install the pack once:
# ComfyUI Manager: search "Trent Nodes", click Install
# or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/TrentHunter82/TrentNodes.git
cd TrentNodes
pip install -r requirements.txt
The one real dependency for this node is transformers (BiRefNet loads through it), and BiRefNet's weights download from Hugging Face on first use. First run takes a minute; after that it's cached. The pack's requirements.txt pulls a fairly long list of things for its other nodes - vosk, psd-tools, fal-client and so on - which is fine, just don't be surprised that installing one node drags in a lot of siblings.
Gotchas
Where people get burned: feeding it a background that isn't actually removable. BiRefNet is a salient object segmenter under the hood - it keys out the most prominent thing in the frame. If your mouth shape has other detail in it (a face, a hand, a watermark), that's what it'll cut, not the mouth. That's a genuine failure mode worth knowing before you blame the node. If your shapes are simple flat drawings, the color_key path against a solid background is often cleaner and faster than a neural model - try auto first, then pick.
The masks output is also worth grabbing and wiring into a preview or mask viewer before you composite, because a bad cutout shows up instantly as a hard rectangle edge once it's moving. Ten seconds of checking beats twenty minutes of wondering why your character's mouth has a visible border.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | Mouth shape images (batch of 9 or any) | |
| methodopt | COMBO | birefnet | Background removal method |
| qualityopt | COMBO | fast | BiRefNet quality: fast (512px), balanced (768px), quality (1024px) |
| modelopt | COMBO | lite | BiRefNet model: lite (faster), standard (better) |
| bg_coloropt | COMBO | white | Background color for color_key method |
| thresholdopt | FLOAT | 0.150.01–1 | Color key threshold (higher = more removed) |
| expand_maskopt | INT | 20–50 | Expand foreground mask by pixels |
| featheropt | INT | 20–50 | Feather mask edges |
| output_formatopt | COMBO | rgba | Output format: rgba (RGB + alpha), transparent (zero BG), premultiplied (RGB * alpha) |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |
| masks | MASK | — |