Comfy Pro Alpha Generator
Inside the Comfy Pro Alpha Generator Node
- images
- alpha
- comp
Every matte tool in ComfyUI makes you pick a side. A segmentation model - SAM 3, BiRefNet, whatever's winning this month - finds exactly the person you clicked and then hands you a soft outline that eats the hair. A generative matte draws hair down to the individual strand and then refuses to tell you which of the three kids in the frame it matted. Comfy Pro Alpha Generator is a pack by Rikin Patel (Comfy Compositing, and yes, he's a Nuke compositor) built to stop choosing: SAM 3 decides who, LTX-2.5's alpha-gen IC-LoRA decides what the edge looks like.
The gap it's aiming at is real. Vibe-masking got commoditised years ago; the frontier moved from "can it find the subject" to "can it survive hair, fur and semi-transparency", and nobody won that. This node's pitch is that hair is a rendering problem, not a segmentation problem.
The node's own headline numbers, measured on a 247-frame plate where only the middle kid should be matted: 88.7% edge-detail match against pure LTX alpha-gen (the reference for hair), versus 45% for the SAM 3 + ViTMatte route and 29% for a raw SAM 3 mask. Flicker lands at 1.2x LTX alone. Salt, as usual: it's the author's own harness and it favours LTX-shaped edges. The visual difference between strands and halo isn't subtle either way.
How it actually gets there
On Queue, the node expands into a full graph of SAM 3, ViTMatte and LTX stages. You never wire that by hand - you get one node with a picker and a render button.
The core trick is that LTX can't be told which subject to matte, so the node changes what LTX sees. SAM 3 tracks every other subject in the plate, and those get painted out of a copy with an inpainted background - a flat colour fill doesn't work, LTX reads it as a half-transparent object. LTX then mattes your subject alone and draws all its edges, including the parts SAM 3 missed. Where the subject overlaps another person, LTX outputs 1.0 on both sides so there's no edge to take, and within about 15 px of other people the node falls back to a stabilised ViTMatte edge. A coarse coverage map catches the parts LTX left empty entirely - a parked car, a table - and fills only those.
LTX renders 49 frames in one go, so its edges hold still; SAM 3 and ViTMatte decide per frame, so their output is smoothed with optical-flow-warped neighbours before the blend. Long shots render in overlapping chunks that get cross-faded. Every stage is cached, which is why switching Fast/Best or running the full shot after a preview doesn't redo finished work.
The inputs you actually touch
images is the plate - Load Video → Get Video Components, or Load Plate Sequence, or any crop/resize chain. fps and first_frame come along with it; first_frame is the one that makes VFX numbering work (1001 gives you alpha_01001).
quality picks 2 LTX passes (Best) or 1 (Fast, roughly half the time, weaker edges against other people). render chooses a 49-frame preview from the pick frame or the full shot. picks is the JSON the picker writes when you click - don't hand-edit it. filename_prefix puts each shot in its own output folder, and format is png16 or exr.
Then a row of model selectors whose only real job is telling you a file is missing: ltx_model, alpha_lora, video_vae (must be the conv VAE), audio_vae, vitmatte, and text_encoder, which you leave on built-in empty prompt forever because alpha-gen runs with an empty prompt and the pack ships that conditioning. Under the Advanced fold: chunk, overlap, seed, erode/dilate, near_px, stabilize_radius, sam3_threshold, fast_attention. Optional switches handle the specialist cases - overlap_mode for crossing people, native_edges for plates over 1080p, edge_colour for the soft-edge halos.
Outputs
alpha is the 16-bit MASK. comp is the subject composited over grey - and it's only computed if something is wired to it, because a full 1080p shot of frames is several gigabytes. Leave it disconnected unless you're previewing.
Install
Manager → Install via Git URL → https://github.com/rik-python/ComfyUI-Comfy-Pro-Alpha-Generator.git, then install ComfyUI-SAM3 and ComfyUI-LTXVideo the same way. By hand:
cd ComfyUI/custom_nodes
git clone https://github.com/rik-python/ComfyUI-Comfy-Pro-Alpha-Generator.git
pip install -r ComfyUI-Comfy-Pro-Alpha-Generator/requirements.txt
Then the models, about 28 GB: the LTX-2.5 int8 transformer into diffusion_models/, the alpha-gen IC-LoRA into loras/, the conv video VAE and audio VAE into vae/. SAM 3, ViTMatte and Depth Anything V2 Small download themselves on first run. Both Lightricks repos are gated - you need a free Hugging Face account, the terms accepted on each page, and hf auth login if you're pulling from the CLI.
Where people get burned
MISSING: <file> in a model selector stops the run with the download link instead of failing halfway, so read it rather than guessing. Frames before the frame you picked come out empty - tracking only runs forward. A shot needs more than 24 chunks (roughly 960 frames at defaults) and it hard-errors; split it. 4K with native edges holds every frame in RAM, 97 GB at 242 frames, so split long 4K shots into ~100-frame runs.
And the licence catches people off guard: the pack is PolyForm Noncommercial - paid client work needs a commercial licence from the author - and LTX-2.x adds its own terms on top, including a paid tier above $10M annual revenue. Check both before you ship.
Inputs (38)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | The plate. Connect Load Video -> Get Video Components, Load Plate Sequence, or any crop/resize chain. Then click 'Load plate' in the node. Best quality at 1920x1088 (a 1920x1080 plate is padded to 1088 automatically): LTX alpha-gen is tuned for that size. Bigger plates (4K, DCI, 2K) are matted on a 1080p proxy, with the edges rendered again at native resolution (native-resolution edges). Smaller plates work, but edges can come out softer. | |
| fps | FLOAT | 24.0001–240 | Plate frame rate (connect Get Video Components / Load Plate Sequence fps) |
| first_frame | INT | 10–10000000 | Frame number of the first image (1001 for VFX plates): output files use it |
| quality | COMBO | Best (v12, 2 LTX passes) | 2 options: Best (v12, 2 LTX passes), Fast (v7, 1 LTX pass) |
| render | COMBO | full shot | preview chunk = first 49 frames from the pick frame |
| picks | STRING | {} | Set by the picker; JSON. |
| filename_prefix | STRING | comfy_pro_alpha/shot | — |
| format | COMBO | png16 | 2 options: png16, exr |
| ltx_model | COMBO | Recommended: ltx-2.5-22b-distilled-transformer-comfy-int8-convrot.safetensors | folder: ComfyUI/models/diffusion_models/ (press R after adding files) | Low RAM/VRAM: LTX-2.5-Distilled-Q4_K_M.gguf (needs the ComfyUI-GGUF node pack); keep models on an NVMe SSD so ComfyUI streams them from disk | |
| alpha_lora | COMBO | Recommended: ltx-2.5-22b-ic-lora-alpha-gen-0.9.safetensors | folder: ComfyUI/models/loras/ (press R after adding files) | |
| text_encoder | COMBO | built-in empty prompt (no text encoder needed) | built-in empty prompt (no text encoder needed): same result, skips loading the 13 GB encoder. Or pick gemma4-12b-with-proj-ltx-2.5-comfy-int8-convrot.safetensors from ComfyUI/models/text_encoders/ |
| video_vae | COMBO | Recommended: ltx-2.5-video-vae-conv-bf16.safetensors | folder: ComfyUI/models/vae/ (press R after adding files) | |
| audio_vae | COMBO | Recommended: ltx-2.5-audio-vae-bf16.safetensors | folder: ComfyUI/models/vae/ (press R after adding files) | |
| vitmatte | COMBO | Folder in ComfyUI/models/vitmatte/, or auto-download on first run | |
| chunk | INT | 499–145 | LTX renders the shot in chunks of this many frames (8n+1). 49 fits 1920x1088 on 32 GB. |
| overlap | INT | 90–72 | Frames shared by neighbouring chunks and cross-faded so the joins don't show. More = smoother joins but more chunks (slower). 9 = a new chunk every 40 frames. |
| seed | INT | 420–2147483647 | — |
| erode | INT | 100–64 | — |
| dilate | INT | 151–64 | — |
| near_px | INT | 151–64 | v7 zone around other excluded subjects (Best) |
| stabilize_radius | INT | 20–6 | Removes frame-to-frame chatter in the SAM3/ViTMatte edges: each frame is averaged with this many frames before and after, warped by optical flow (occlusions are ignored). 0 = off, 2 = default (5-frame window). Higher is smoother but fast motion can lag or ghost, and it is slower. LTX edges are already stable. |
| sam3_threshold | FLOAT | 0.300–1 | — |
| fast_attention | BOOLEAN | true | Comfy Kitchen int8 attention for LTX: about 36% faster sampling, matte difference ~0.004 (7x smaller than changing the seed). Turn off to use standard PyTorch attention. |
| clean_plate_loraopt | COMBO | Recommended: ltx-2.5-22b-ic-lora-clean-plate-1.0.safetensors | folder: ComfyUI/models/loras/ (press R after adding files) | Only for edge colour = perfect; without it perfect runs as quick | |
| overlap_modeopt | BOOLEAN | false | For people crossing the subject (hands, arms, hair). LTX mattes the subject and everyone else on the real plate (3 LTX passes instead of 2, plus a depth pass) and subtracts the others where SAM3 and depth say they are in front: their fingers and curls come out crisp instead of soft. Replaces the quality setting. If a limb of the subject that rests on someone goes missing, add a click on it. Needs other subjects picked; without them it runs Best (v12). |
| v13_depthopt | BOOLEAN | true | Depth Anything V2 Small decides who is in front where SAM3 gives a pixel to both people or neither (fingers over a chest). Off = SAM3 alone (a local vote): faster, but fast thin fingers in front of the subject can ghost. |
| hair_guideopt | BOOLEAN | false | Overlap (v13) only. Where someone's hair crosses the subject, re-fit their hair matte to the plate's own edges (guided filter): more single strands, cleaner gaps between curls. Can read dark stripes or patterns on the subject's clothes as hair, so check the comp. Off by default. |
| hair_radiusopt | INT | 41–16 | How far the hair sharpening looks for plate edges. Smaller = finer strands but noisier; larger = smoother but picks up more clothing pattern. |
| attn_growopt | INT | 200–80 | How far each SAM3 mask is grown before it steers LTX's attention, so hair outside the SAM outline is still matted. Tested best: 20. |
| attn_bluropt | FLOAT | 10.00–40 | Feather of that attention mask. 0 = hard edge (cuts hair, ~1.5x error). Tested best: 10. |
| attn_strengthopt | FLOAT | 1.000–1 | How strongly LTX follows the attention mask. Lower lets it drift to other people. Tested best: 1.0. |
| occluder_reachopt | INT | 200–60 | How far past an in-front person's overlap the subtraction reaches, to catch their soft edge (strands, fast fingertips). Larger can bite the subject's own thin parts. Tested best: 20. |
| limb_capopt | INT | 9020–400 | LTX also draws parts of the subject it cannot see (amodal). Anything further than this from the SAM3 selection is removed (fades over the last 40 px). Raise it if real edges far from the selection get cut. Tested best: 90. |
| front_smoothingopt | INT | 31–9 | Frames averaged so the in-front / behind decision never pops. 1 = off. Tested best: 3. |
| native_edgesopt | BOOLEAN | true | Plates bigger than 1920x1088: LTX also renders the subject's edges on native-resolution 1920x1088 tiles, for strand-level detail at the plate's own size. Roughly 2-3x the render time on a 4K plate. Off: matte at 1080p and scale the alpha up (fast). Plates at 1080p or smaller are not affected. Plates only a little bigger than 1080p (up to about 2300 px wide, e.g. 2K) gain little detail for the full tile cost: switch it off there to save time. |
| edge_colouropt | COMBO | quick | quick: rebuilds the colour of the soft edges from the subject itself, so sky or grass behind hair does not stay in the strands (CPU, no extra VRAM: about 2 s a frame at 1080p, 4 s a frame at 4K). perfect: LTX Clean Plate rebuilds the background, which is then subtracted from the edges (one extra LTX pass per chunk on the 1080p proxy, plus about 2 s a frame at 4K; needs the Clean Plate IC-LoRA). off: the raw plate in the edges, as v0.4.1. The alpha is the same in every mode. Saves rgba_ files next to the alpha. |
| track_backwardopt | BOOLEAN | true | Full shot: matte the whole plate. Every pick is tracked backward to the first frame as well as forward, so you can pick the subject on any frame where it is clear. Frames before the subject enters get an empty alpha. Off: the shot starts at the pick frame (as before v0.6). The preview always starts at the pick frame. |
| skip_sam3opt | BOOLEAN | false | Plain LTX alpha-gen: no picks, no SAM3. LTX mattes every main subject in the plate, and you still get the chunked full shot, native 4K edges, edge colour and EXR with plate frame numbers. The preview starts at the scrubber frame. Quality and overlap mode do not apply. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| alpha | MASK | — |
| comp | IMAGE | — |