Nodes/CS Hybrid 4K Image-to-Video/CS Flow Estimate (RAFT + occlusion)
ComfyUI Node

CS Flow Estimate (RAFT + occlusion)

RAFT flow and occlusion masks for your video, with zero model downloads on you

By lvqunx·Created about a month ago·Updated about a month ago· 0
CS Flow Estimate (RAFT + occlusion)
  • images
  • flow_fwd
  • occlusion
  • flow_bwd
model_size
occ_threshold1.5
batch_size8
unload_models_firsttrue

The trick that makes CS Hybrid 4K work is that it never regenerates your whole video at high resolution. Instead it moves detail around using optical flow - and flow has to come from somewhere. CS Flow Estimate is that somewhere: it computes forward and backward motion between consecutive frames of your video, plus an occlusion mask that tells you which pixels were hidden or revealed and can't be trusted to carry detail. It's the first real step of the pipeline, and everything downstream (detail transfer, the tile schedule) leans on what it produces.

The node comes from CS Hybrid 4K Image-to-Video (lvqunx/comfyui-cs-hybrid), a small new pack built around a very specific workflow: generate video at 480P with any i2v model, then rebuild 4K frames by dragging high-frequency detail out of your source still along the flow. Think of this node as the motion survey before the construction work.

How it works

Under the hood it's RAFT - the optical-flow model that's bundled inside torchvision, no separate model file needed. You get a choice of raft_small or raft_large; the weights auto-download from HuggingFace on first run, then cache locally. It processes your frame batch as pairs (frame 0→1, 1→2, …) in chunks. The chunking isn't cosmetic: the code comments that RAFT's correlation volume is (H/8 * W/8)² per pair - roughly 168MB at 864×480 in fp32 - so a full 120-frame clip in one go would want ~20GB. batch_size (default 8) is what keeps you well under that.

The occlusion mask is the classic forward-backward consistency check: warp the backward flow forward and see whether the two flows cancel out. Where a point was visible in one direction but not the other (an object edge un-covering background, a pan revealing new scenery), they won't, and the pixel gets flagged. occ_threshold (default 1.5) sets how picky that test is - lower it and more pixels count as occluded.

The inputs that matter

  • images - your video frame batch.
  • model_size - raft_small or raft_large. Small is faster and lighter; large is more accurate. For 480P work, small is usually plenty.
  • batch_size - default 8, frames-per-chunk. Drop it if you're tight on VRAM.
  • unload_models_first - default true. The node unloads whatever ComfyUI models you have loaded and empties the cache before loading RAFT, so a big checkpoint sitting in VRAM doesn't OOM the flow pass. Leave it on.

The outputs

Three, all one shorter than your batch (B frames → B−1 flows):

  • flow_fwd - forward motion between consecutive frames (CS_FLOW).
  • occlusion - the occlusion mask (MASK), one per frame pair.
  • flow_bwd - backward motion (CS_FLOW).

CS_FLOW is a pack-internal type: wire it straight into CS Detail Recompose or CS GOP Recompose, and feed the occlusion MASK into CS Tile Scheduler so it schedules full-resolution work on exactly the regions where flow can't be trusted.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/lvqunx/comfyui-cs-hybrid
# restart ComfyUI

Or ComfyUI Manager → search CS Hybrid 4K Image-to-Video. There are no extra pip dependencies - the pack only uses torch and torchvision, which ComfyUI already ships. The only download is the RAFT weights on first run, so make sure you have network the first time you hit this node.

Common issues

First run can feel like a hang while the weights download - it's not stuck, give it a minute. If you OOM on a long clip, lower batch_size or switch to raft_small. And the honest limitation, from the README: flow degrades on stochastic textures - water, smoke, particles - because there's no real correspondence for the model to find. For those shots, raise the scheduler's ratio so more of the frame gets re-synthesized at full res instead of trusting motion transfer.

CategoryCSHybrid

Inputs (5)

NameTypeDefaultDescription
imagesIMAGE
model_sizeCOMBO2 options: raft_small, raft_large
occ_thresholdFLOAT1.50.1–20
batch_sizeINT81–64
unload_models_firstBOOLEANtrue

Outputs (3)

NameTypeDescription
flow_fwdCS_FLOW
occlusionMASK
flow_bwdCS_FLOW