Skip to content

Video understanding, tracking, generation, and world models · Motion and tracking · VID031 · Architecture

RAFT

Computes all-pairs feature correlations and repeatedly updates a dense flow field using a recurrent refinement operator.

Needs a data type CodeSplash doesn't load yet Component demo, not a trained model CodeSplash's run and the reference's record

In CodeSplash

Running this needs images, audio, video, graphs or another data type CodeSplash doesn't load yet.

Availability
Needs a data type CodeSplash doesn't load yet
Code example
Component demo, not a trained model
Who ran it
CodeSplash's run and the reference's record
CodeSplash's run
The reference's example ran in Python and R here, and they agree.
The reference's record
Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.

Purpose

Computes all-pairs feature correlations and repeatedly updates a dense flow field using a recurrent refinement operator. Unlike coarse-to-fine flow prediction, it maintains a single high-resolution flow estimate while consulting a multiscale correlation representation.

Question / objective

Estimate image displacement or maintain the location and identity of objects/points over time. This is a learning or inference objective, not a test of a statistical null hypothesis.

Method type and supervision

architecture · Motion and tracking. Mixed: supervised neural perception or non-neural inference over detections; see the individual assumptions.

Architecture / computational structure

Image/context encoders, all-pairs correlation pyramid and recurrent flow update operator.

Assumptions

Inputs must satisfy the temporal, modality and annotation protocol described below. All-pairs correlation can be memory intensive. Textureless areas and occlusions remain ambiguous; additional iterations are not a guarantee of physical correctness.

Formula / computational definition

C(p,q)=f1(p)⊤f2(q)C(p,q)=f_1(p)^\top f_2(q) and uk+1=uk+Δθ(uk,C,hk)u^{k+1}=u^k+\Delta_\theta(u^k,C,h^k) summarize correlation construction and iterative refinement; hkh^k is recurrent state. Training supervises a sequence of predictions.

Parameters and notation

Learned/estimated quantities: Neural feature/refinement weights are learned when the method contains a network; coordinates, flow fields and track states are inferred outputs, not fixed network parameters. Symbols specific to the objective are defined with the equation. Hyperparameters and design choices: Iteration count, correlation pyramid, feature resolution, image padding, training data and update-network capacity matter.

Fitting, fine-tuning, and adaptation

Adapt the update block and encoders using sequence flow supervision. More refinement iterations changes inference cost; it is not parameter fine-tuning and must be evaluated separately. Use a separate adaptation validation split, monitor the target metric and retention of previously useful behavior, and save the exact preprocessing and training configuration.

How to use and calibrate

Fix the input protocol and target before fitting; choose design settings on held-out source videos, then freeze the evaluation procedure. Report endpoint error, outlier rates, inference iterations and memory; separate image-pair accuracy from downstream tracking consistency.

Example application

Recover dense motion for image warping or video analysis.

Interpretation / pitfalls

Watch out

An optimized training objective or a favorable example does not establish generalization. Report endpoint error, outlier rates, inference iterations and memory; separate image-pair accuracy from downstream tracking consistency. The example below isolates one mechanism and cannot substantiate a full-model benchmark claim.

Python and R code examples

Component: Construct all-pairs correlation and a toy iterative flow refinement. Dependencies: NumPy in Python; base R in R; run the shared setup above. Python component: executed successfully. R component: unexecuted. No complete model training or pretrained inference was executed.

Full implementation route — Python: Use a verified RAFT implementation with correct image scaling and padding, or study its correlation/update components separately. R: Compute endpoint error and small correlation matrices in R; bridge GPU inference through reticulate.

Python and R

The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.

Python

Component demo, not a trained model — Construct all-pairs correlation and a toy iterative flow refinement.

Shared setup for this chapter
import numpy as np

def softmax(x):
    z = np.asarray(x, dtype=float)
    e = np.exp(z - z.max())
    return e / e.sum()
first = np.eye(3); second = np.roll(first,1,axis=0)
correlation = first@second.T
matches = correlation.argmax(axis=1)
target_flow = matches-np.arange(3); flow = np.zeros(3)
for _ in range(3): flow += .5*(target_flow-flow)
print(correlation, "toy refined flow",flow)
# Fixed relaxation illustrates iteration; it is not RAFT's learned GRU.
R

Component demo, not a trained model — Construct all-pairs correlation and a toy iterative flow refinement.

Shared setup for this chapter
softmax <- function(x) {
  e <- exp(x - max(x))
  e / sum(e)
}
first <- diag(3); second <- first[c(3,1,2),]
correlation <- first%*%t(second)
matches <- max.col(correlation,ties.method="first")
target_flow <- matches-1:3; flow <- numeric(3)
for(k in 1:3) flow <- flow+.5*(target_flow-flow)
print(correlation); print(flow) # relaxation, not the learned RAFT update

Sources

From the CodeSplash reference, entry VID031.