ComfyUI Node

RAFT Flow to Image

Turn an optical-flow field into a picture you can see

By jamesWalker55·Created 3 years ago·Updated about a year ago· 215
RAFT Flow to Image
  • raft_flow
  • IMAGE

Optical flow is invisible until you draw it. RAFTFlowToImage is the node that draws it. It takes a RAFT flow field, the per-pixel motion between two frames, and converts it into a normal RGB IMAGE using the standard flow color wheel, so you can actually look at the motion instead of staring at a tensor of numbers. This is a niche, slightly expert corner of ComfyUI, but optical flow itself is very much a live topic in the video-generation crowd (it shows up constantly in threads about motion, warping, and temporal consistency), so if you've wandered into it, here's the map.

It's part of jamesWalker55's "Various ComfyUI Nodes by Type" pack, in the RAFT group, which has exactly three nodes: one to estimate flow, this one to visualize it, and one to load flow from EXR channels.

What optical flow and RAFT are

Optical flow is a field of little arrows: for every pixel, which direction and how far it moved from one frame to the next. RAFT (Recurrent All-Pairs Field Transforms) is the well-regarded model that computes those arrows, and it's shipped inside torchvision, so it's usually already sitting in your environment. In this pack, the RAFTEstimate node is what actually runs RAFT: you give it two images (frame A and frame B) and it produces a RAFT_FLOW, the raw motion field. That RAFT_FLOW is the only thing RAFTFlowToImage takes as input.

The reason you need a separate "to image" step is that a flow field isn't an image. It's two numbers per pixel (horizontal and vertical motion), which no preview node knows how to display. RAFTFlowToImage maps it into color the conventional way researchers do: hue encodes the direction of motion and brightness/saturation encodes the magnitude (how fast). So a region moving right shows up as one color, moving left as its opposite, and a still background stays dark. Once you've seen a few, you can read motion straight off the picture.

What you'd use it for

Two things, mostly. First, plain inspection: you're debugging a video pipeline and want to see where and how much things are moving between frames. Render the flow to an image, preview it, done. Second, and more advanced, using the flow as a signal, feeding a motion visualization somewhere as a control input, or as the visible half of a warp-based temporal-consistency trick where you push pixels from one frame toward the next along the flow. That second use is deep water and you'll know if you're in it.

Input and output

  • raft_flow: a RAFT_FLOW, which in practice means the output of RAFTEstimate. There's no other input; this node's whole job is the conversion.

The output is a single IMAGE (the color-wheel visualization), which wires into a preview, a save, or anything downstream that eats an IMAGE.

Installing it

ComfyUI Manager: search "Various ComfyUI Nodes by Type" or jamesWalker55, install, restart. Or clone:

cd ComfyUI/custom_nodes
git clone https://github.com/jamesWalker55/comfyui-various

then restart ComfyUI. One dependency note straight from the pack's README: the pip install OpenEXR step it mentions is only for the other RAFT node, RAFTLoadFlowFromEXRChannels (the EXR loader). RAFTFlowToImage and RAFTEstimate don't need it; they lean on torchvision, which you almost certainly already have.

Common issues

The type is the trap. RAFT_FLOW is a custom type produced by RAFTEstimate and nothing else, so you can't wire a plain IMAGE or a latent into RAFTFlowToImage. If the node won't connect, that's the reason, put a RAFTEstimate (fed two frames) in front of it. This node is purely the visualizer; it doesn't compute anything, so an empty or wrong-shaped result almost always traces back to the estimate step or the frames you fed it, not to this node.

Second, don't over-read the colors. The flow color wheel is a convention, not calibrated data. It's for seeing relative motion at a glance, not for measuring exact pixel displacement. If you need the actual numbers, you want the raw flow, not its picture.

CategoryjamesWalker55

Inputs (1)

NameTypeDefaultDescription
raft_flowRAFT_FLOW

Outputs (1)

NameTypeDescription
IMAGEIMAGE