Mask Temporal Enhancer (CRT)
Mask Temporal Enhancer (CRT)
- mask
- mask
Mask Temporal Enhancer (CRT) smooths a sequence of masks across time. You feed it the per-frame masks you got from frame-by-frame face or object detection, and it returns masks that no longer blink, pop, or jitter between frames. If you've ever composited a detected subject across a video and watched the mask edge shimmer like a faulty green screen, you already know why this node exists.
Per-frame detection is unstable in a very specific way. Run a segmenter on frame 1, frame 2, frame 3, and the mask for the same subject changes shape slightly every frame - a few pixels of boundary wobble here, a momentary dropout there, a hole that appears and vanishes. Individually each mask is fine; played back, the sequence flickers. The fix is temporal processing: each output mask is influenced by its neighbors in time, so the wobble averages out and a one-frame dropout gets repaired from the frames around it. That's the whole job, and it's a video problem - the KB's inpainting and video work both keep running into it.
The controls map onto that job pretty cleanly. temporal_window (default 5) is how many neighboring frames each mask considers; bigger = smoother but laggier. temporal_strength (default 0.55) is how much of that temporal averaging you actually apply. auto_repair (off/conservative/balanced/aggressive, default balanced) sets how hard it works to fill gaps across frames, with repair_strength and max_repair_gap (default 3) governing the reach - a dropout longer than max_repair_gap frames is left alone rather than guessed. edge_strength and edge_radius control feathering so boundaries stay soft instead of hard-edged, and fill_holes plus hole_threshold mop up interior speckles. cleanup_mode (off/close gaps/open speckles/close then open) adds a classic morphological pass, with cleanup_radius for its size. And processing_device (auto/input/cuda/cpu) lets you force where the math runs - the default auto is right for almost everyone.
The one input that matters is mask (a batch of masks, one per frame - match the ordering to your video frames), and the single output is the enhanced mask batch, ready to feed a compositor, an inpaint, or a per-region detailer. A sensible starting point: defaults, then raise temporal_strength only if the result still flickers, and lower it if you see the mask "lagging" behind fast motion - too much temporal smoothing drags edges, and that's the classic overcorrection.
Install with the pack (ComfyUI Manager → search "CRT-Nodes", or clone https://github.com/plugcrypt/CRT-Nodes.git into custom_nodes and restart). It's numpy/torch processing - no models, no downloads. If your video masks are steady already, you don't need it; if they're not, it's the difference between a composite that looks broken and one that holds still.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| processing_device | COMBO | auto | 4 options: auto, input, cuda, cpu |
| auto_repair | COMBO | balanced | 4 options: off, conservative, balanced, aggressive |
| repair_strength | FLOAT | 1.000–1 | — |
| max_repair_gap | INT | 31–24 | — |
| temporal_window | INT | 51–31 | — |
| temporal_strength | FLOAT | 0.550–1 | — |
| edge_strength | FLOAT | 0.800–1 | — |
| edge_radius | INT | 31–32 | — |
| fill_holes | BOOLEAN | true | — |
| hole_threshold | FLOAT | 0.500–1 | — |
| cleanup_mode | COMBO | close gaps | 4 options: off, close gaps, open speckles, close then open |
| cleanup_radius | INT | 10–16 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |