Raft Optical Flow Node (Buff)
RAFT optical flow between two frames
- image_a
- image_b
- IMAGE
Point this node at two frames - previous and current - and it hands you back an image that visualizes exactly where every pixel moved. That's optical flow, computed by RAFT, one of the best-known models for the job. For anyone working on temporal consistency in video generation, this is a genuinely useful primitive: it turns "how did the scene move" into a color-coded image another model can consume.
The README frames it plainly: it's built for use with TemporalNet2 in video streaming workflows. The pattern is the same one that shows up in the wider temporal-consistency ecosystem (the same idea powering things like TemporalKit's flow-based pipelines): compute the motion between the previous processed frame and the current one, turn that motion into a visual, and feed it to a ControlNet-style model that uses it to keep the next frame consistent. If you're stitching frames together and the result flickers, flow-based conditioning is one of the classic remedies - and this node is how you get the flow.
How it works
Under the hood it's torchvision's raft_large model with the default large weights. The weights download automatically on first use and are cached after that. Input frames are padded to multiples of 8 (RAFT's constraint), run through the model, and the resulting flow field is rendered with torchvision's flow_to_image - the familiar hue-coded map where color direction encodes motion direction. The output is normalized to [0,1] so it behaves like any ordinary ComfyUI image, and padding is cropped back off. Device placement follows your tensors: on GPU, the model moves to GPU.
Inputs and output
image_a- first image (previous frame).image_b- second image (current frame). Must be the same size asimage_a.
Single output: an IMAGE - the color-coded flow visualization. That's the thing you'd feed into a concatenator to build a 6-channel temporal conditioning input, or just preview to sanity-check motion.
Install
From BuffMcBigHuge's pack - ComfyUI Manager (search "ComfyUI-Buff-Nodes") or:
cd ComfyUI/custom_nodes
git clone https://github.com/BuffMcBigHuge/ComfyUI-Buff-Nodes
Restart ComfyUI. The pack itself has no requirements.txt, but this node pulls torchvision's RAFT weights from Hugging Face on first run - so the very first execution needs network and takes a moment. Nothing else to install.
Gotchas
First-run download stalling is the most common stumble; just let it finish once. Mismatched frame sizes raise errors, so keep image_a and image_b the same resolution. The model is Raft_Large_Weights.DEFAULT, which is the big accurate one - on CPU it's slow enough that you'll notice; a GPU makes it trivial. And don't be surprised that the output is a visualization, not raw flow vectors - this node's contract is "give me a flow image," and that's what temporal control models expect. If you need flow for a whole clip at once, the pack's batch version does every consecutive pair in one call; this one is the two-frame building block.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image_a | IMAGE | First image (previous frame). Must be same size as image_b. | |
| image_b | IMAGE | Second image (current frame). Must be same size as image_a. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |