Nodes/ComfyUI-DragNUWA/Load MotionBrush From Optical Flow Directory
ComfyUI Node

Load MotionBrush From Optical Flow Directory

Loading .flo Files

By chaojie·Created 3 years ago·Updated 2 years ago· 411
Load MotionBrush From Optical Flow Directory
  • model
  • MotionBrush
optical_flow_directoryX://path/to/optical_flow

Load MotionBrush From Optical Flow Directory is the pre-computed cousin of the optical-flow loader. Where the other one takes a live OPTICAL_FLOW tensor from a preprocessor, this one reads ready-made flow files off disk - specifically Middlebury .flo files, the classic binary format for storing dense optical flow - and converts them into a MotionBrush. It exists because a whole ecosystem of tools (flow estimators, video-processing scripts, even some of the README's credit goes to toyxyz's directory-based loaders) can dump flow to .flo, and not everyone wants to run a flow preprocessor live inside ComfyUI.

Mechanically it's straightforward: the node scans the directory for *.flo files, reads each one (the Middlebury header + raw w × h × 2 float data), and stacks them frame by frame into the (frames, height, width, 2) brush tensor, resizing each to the model's resolution along the way. The model's model_length dictates how many flow files it consumes from the start of the list - so your folder should have at least model_length - 1 .flo files, in the order you want them used.

Inputs

  • model - the DragNUWA object, providing target resolution and model_length.
  • optical_flow_directory - a path string to the folder of .flo files. The default (X://path/to/optical_flow) is a placeholder; replace it with your real path. Note this is a plain filesystem path, not a ComfyUI-managed input - the files are whatever you've generated elsewhere.

Output

A MotionBrush built from the flow files, feeding the usual chain into DragNUWA Run MotionBrush or a composite.

When this is the right tool

If you already have flow files - from a script, from another tool, or from a directory of flows you saved for reuse - this is the direct route with no extra nodes and no live preprocessing in the graph. The README explicitly credits community tools for loading optical flow from a directory, and this node is the pack's native answer to that same pattern. It's also handy when the flow estimation is too slow or too finicky to run inside ComfyUI: compute once, save .flo, reuse.

Gotchas

The frame count is a silent assumption. There's no error if your folder has fewer .flo files than model_length - 1 - you just get a shorter brush, and the run node fills the gap with zeros, which reads as "motion dies out partway through." Make sure the folder has enough flow files to cover the clip.

Format and order. It's Middlebury .flo or nothing - wrong magic number and the file is skipped. And "order" is filesystem order; with natsort in the requirements you'd hope for natural sorting, but don't bet a workflow on it. Name your files with zero-padded numbers (flow_001.flo, flow_002.flo) and check the output.

The usual pack reality. Flow files computed against a source video won't match your target image's content - you're re-applying motion, not objects. Expect the SVD-era softness and warping on anything ambitious, remember the hardcoded cuda:0 model load, and keep model_length consistent across the graph. For "I have flow files, apply this motion," this is the node - just count your files first.

CategoryDragNUWA

Inputs (2)

NameTypeDefaultDescription
modelDragNUWA
optical_flow_directorySTRINGX://path/to/optical_flow

Outputs (1)

NameTypeDescription
MotionBrushMotionBrush