RAFT: Recurrent All-Pairs Field Transforms for Optical Flow
Zachary Teed Jia Deng
cs.CV




headings
3526  







RAFT: Recurrent All-Pairs Field Transforms



Z. Teed and J. Deng
Princeton University 
 
{zteed,jiadeng}@cs.princeton.edu


RAFT: Recurrent All-Pairs Field Transforms for Optical Flow
    Zachary Teed Jia Deng
    December 30, 2023
===========================================================




We introduce Recurrent All-Pairs Field Transforms (RAFT), a new deep network architecture for optical flow. RAFT extracts per-pixel features, builds multi-scale 4D correlation volumes for all pairs of pixels, and iteratively updates a flow field through a recurrent unit that performs lookups on the correlation volumes. RAFT achieves state-of-the-art performance. On KITTI, RAFT achieves an F1-all error of 5.10%, a 16% error reduction from the best published result (6.10%). On Sintel (final pass), RAFT obtains an end-point-error of 2.855 pixels, a 30% error reduction from the best published result (4.098 pixels). In addition, RAFT has strong cross-dataset generalization as well as high efficiency in inference time, training speed, and parameter count. Code is available at <https://github.com/princeton-vl/RAFT>.




§ INTRODUCTION

Optical flow is the task of estimating per-pixel motion between video frames. It is a long-standing vision problem that remains unsolved. The best systems are limited by difficulties including fast-moving objects, occlusions, motion blur, and textureless surfaces. 

Optical flow has traditionally been approached as a hand-crafted optimization problem over the space of dense displacement fields between a pair of images <cit.>. Generally, the optimization objective defines a trade-off between a data term which encourages the alignment of visually similar image regions and a regularization term which imposes priors on the plausibility of motion. Such an approach has achieved considerable success, but further progress has appeared challenging, due to the difficulties in hand-designing an optimization objective that is robust to a variety of corner cases. 

Recently, deep learning has been shown as a promising alternative to traditional methods. Deep learning can side-step formulating an optimization problem and train a network to directly predict flow. Current deep learning methods <cit.> have achieved performance comparable to the best traditional methods while being significantly faster at inference time. A key question for further research is designing effective architectures that perform better, train more easily and generalize well to novel scenes. 




We introduce Recurrent All-Pairs Field Transforms (RAFT), a new deep network architecture for optical flow. RAFT enjoys the following strengths: 

    
  * State-of-the-art accuracy: On KITTI <cit.>, RAFT achieves an F1-all error of 5.10%, a 16% error reduction from the best published result (6.10%). On Sintel <cit.> (final pass), RAFT obtains an end-point-error of 2.855 pixels, a 30% error reduction from the best published result (4.098 pixels). 
    
  * Strong generalization: When trained only on synthetic data, RAFT achieves an end-point-error of 5.04 pixels on KITTI <cit.>, a 40% error reduction from the best prior deep network trained on the same data (8.36 pixels). 
    
  * High efficiency: RAFT processes 1088×436 videos at 10 frames per second on a 1080Ti GPU. It trains with 10X fewer iterations than other architectures. A smaller version of RAFT with 1/5 of the parameters runs at 20 frames per second while still outperforming all prior methods on Sintel. 
 

RAFT consists of three main components: (1) a feature encoder that extracts a feature vector for each pixel; (2) a correlation layer that produces a 4D correlation volume for all pairs of pixels, with subsequent pooling to produce lower resolution volumes; (3) a recurrent GRU-based update operator that retrieves values from the correlation volumes and iteratively updates a flow field initialized at zero. Fig. <ref> illustrates the design of RAFT. 

The RAFT architecture is motivated by traditional optimization-based approaches. The feature encoder extracts per-pixel features. The correlation layer computes visual similarity between pixels. The update operator mimics the steps of an iterative optimization algorithm. But unlike traditional approaches, features and motion priors are not handcrafted but learned—learned by the feature encoder and the update operator respectively. 

The design of RAFT draws inspiration from many existing works but is substantially novel. First, RAFT maintains and updates a single fixed flow field at high resolution. This is different from the prevailing coarse-to-fine design in prior work <cit.>, where flow is first estimated at low resolution and upsampled and refined at high resolution. By operating on a single high-resolution flow field, RAFT overcomes several limitations of a coarse-to-fine cascade: the difficulty of recovering from errors at coarse resolutions, the tendency to miss small fast-moving objects, and the many training iterations (often over 1M) typically required for training a multi-stage cascade. 

Second, the update operator of RAFT is recurrent and lightweight. Many recent works <cit.> have included some form of iterative refinement, but do not tie the weights across iterations <cit.> and are therefore limited to a fixed number of iterations. To our knowledge, IRR <cit.> is the only  deep learning approach <cit.> that is recurrent. It uses FlowNetS <cit.> or PWC-Net <cit.> as its recurrent unit. When using FlowNetS, it is limited by the size of the network (38M parameters) and is only applied up to 5 iterations. When using PWC-Net, iterations are limited by the number of pyramid levels. In contrast, our update operator has only 2.7M parameters and can be applied 100+ times during inference without divergence. 

Third, the update operator has a novel design, which consists of a convolutional GRU that performs lookups on 4D multi-scale correlation volumes; in contrast, refinement modules in prior work typically use only plain convolution or correlation layers. 

We conduct experiments on Sintel<cit.> and KITTI<cit.>. Results show that RAFT achieves state-of-the-art performance on both datasets. In addition, we validate various design choices of RAFT through extensive ablation studies. 




§ RELATED WORK



Optical Flow as Energy Minimization
Optical flow has traditionally been treated as an energy minimization problem which imposes a tradeoff between a data term and a regularization term. Horn and Schnuck <cit.> formulated optical flow as a continuous optimization problem using a variational framework, and were able to estimate a dense flow field by performing gradient steps. Black and Anandan<cit.> addressed problems with oversmoothing and noise sensitivity by introducing a robust estimation framework.  TV-L1 <cit.> replaced the quadratic penalties with an L1 data term and total variation regularization, which allowed for motion discontinuities and was better equipped to handle outliers. Improvements have been made by defining better matching costs <cit.> and regularization terms <cit.>.

Such continuous formulations maintain a single estimate of optical flow which is refined at each iteration.  To ensure a smooth objective function, a first order Taylor approximation is used to model the data term. As a result, they only work well for small displacements. To handle large displacements, the coarse-to-fine strategy is used, where an image pyramid is used to estimate large displacements at low resolution, then small displacements refined at high resolution. But this coarse-to-fine strategy may miss small fast-moving objects and have difficulty recovering from early mistakes. Like continuous methods, we maintain a single estimate of optical flow which is refined with each iteration. However, since we build correlation volumes for all pairs at both high resolution and low resolution, each local update uses information about both small and large displacements. In addition, instead of using a subpixel Taylor approximation of the data term, our update operator learns to propose the descent direction. 

More recently, optical flow has also been approached as a discrete optimization problem <cit.> using a global objective. One challenge of this approach is the massive size of the search space, as each pixel can be reasonably paired with thousands of points in the other frame. Menez et al<cit.> pruned the search space using feature descriptors and approximated the global MAP estimate using message passing. Chen et al. <cit.> showed that by using the distance transform, solving the global optimization problem over the full space of flow fields is tractable.  DCFlow <cit.> showed further improvements by using a neural network as a feature descriptor, and constructed a 4D cost volume over all pairs of features. The 4D cost volume was then processed using the Semi-Global Matching (SGM) algorithm <cit.>. Like DCFlow, we also constructed 4D cost volumes over learned features. However, instead of processing the cost volumes using SGM, we use a neural network to estimate flow. Our approach is end-to-end differentiable, meaning the feature encoder can be trained with the rest of the network to directly minimize the error of the final flow estimate. In contrast, DCFlow requires their network to be trained using an embedding loss between pixels; it cannot be trained directly on optical flow because their cost volume processing is not differentiable. 

Direct Flow Prediction Neural networks have been trained to directly predict optical flow between a pair of frames, side-stepping the optimization problem completely. Coarse-to-fine processing has emerged as a popular ingredient in many recent works <cit.>. In contrast, our method maintains and updates a single high-resolution flow field.

Iterative Refinement for Optical Flow
Many recent works have used iterative refinement to improve results on optical flow <cit.> and related tasks <cit.>. Ilg et al. <cit.> applied iterative refinement to optical flow by stacking multiple FlowNetS and FlowNetC modules in series. SpyNet<cit.>, PWC-Net<cit.>, LiteFlowNet<cit.>, and VCN <cit.> apply iterative refinement using coarse-to-fine pyramids. The main difference of these approaches from ours is that they do not share weights between iterations. 

More closely related to our approach is IRR<cit.>, which builds off of the FlownetS and PWC-Net architecture but shares weights between refinement networks.  When using FlowNetS, it is limited by the size of the network (38M parameters) and is only applied up to 5 iterations. When using PWC-Net, iterations are limited by the number of pyramid levels. In contrast, we use a much simpler refinement module (2.7M parameters) which can be applied for 100+ iterations during inference without divergence. Our method also shares similarites with Devon <cit.>, namely the construction of the cost volume without warping and fixed resolution updates. However, Devon does not have any recurrent unit. It also differs from ours regarding large displacements. Devon handles large displacements using a dilated cost volume while our approach pools the correlation volume at multiple resolutions.

Our method also has ties to TrellisNet <cit.> and Deep Equilibrium Models (DEQ) <cit.>. Trellis net uses depth tied weights over a large number of layers, DEQ simulates an infinite number of layers by solving for the fixed point directly. TrellisNet and DEQ were designed for sequence modeling tasks, but we adopt the core idea of using a large number of weight-tied units. Our update operator uses a modified GRU block<cit.>, which is similar to the LSTM block used in TrellisNet. We found that this structure allows our update operator to more easily converge to a fixed flow field.

Learning to Optimize
Many problems in vision can be formulated as an optimization problem. This has motivated several works to embed optimization problems into network architectures <cit.>. These works typically use a network to predict the inputs or parameters of the optimization problem, and then train the network weights by backpropogating the gradient through the solver, either implicitly<cit.> or unrolling each step <cit.>. However, this technique is limited to problems with an objective that can be easily defined.

Another approach is to learn iterative updates directly from data <cit.>. These approaches are motivated by the fact that first order optimizers such as Primal Dual Hybrid Gradient (PDHG)<cit.> can be expressed as a sequence of iterative update steps. Instead of using an optimizer directly, Adler et al. <cit.> proposed building a network which mimics the updates of a first order algorithm. This approach has been applied to inverse problems such as image denoising <cit.>, tomographic reconstruction <cit.>, and novel view synthesis<cit.>. TVNet <cit.> implemented the TV-L1 algorithm as a computation graph, which enabled the training the TV-L1 parameters. However, TVNet operates directly based on intensity gradients instead of learned features, which limits the achievable accuracy on challenging datasets such as Sintel. 

Our approach can be viewed as learning to optimize: our network uses a large number of update blocks to emulate the steps of a first-order optimization algorithm. However, unlike prior work, we never explicitly define a gradient with respect to some optimization objective. Instead, our network retrieves features from correlation volumes to propose the descent direction.



§ APPROACH


Given a pair of consecutive RGB images, I_1, I_2, we estimate a dense displacement field (𝐟^1, 𝐟^2) which maps each pixel (u, v) in I_2 to its corresponding coordinates (u', v') = (u + f^1(u), v + f^2(v)) in I_2. An overview of our approach is given in Figure <ref>. Our method can be distilled down to three stages: (1) feature extraction, (2) computing visual similarity, and (3) iterative updates, where all stages are differentiable and composed into an end-to-end trainable architecture. 



 §.§ Feature Extraction


Features are extracted from the input images using a convolutional network. The feature encoder network is applied to both I_1 and I_2 and maps the input images to dense feature maps at a lower resolution. Our encoder, g_θ outputs features at 1/8 resolution g_θ: ℝ^H × W × 3↦ℝ^H/8 × W/8 × D where we set D=256. The feature encoder consists of 6 residual blocks, 2 at 1/2 resolution, 2 at 1/4 resolution, and 2 at 1/8 resolution (more details in the supplemental material).

We additionally use a context network. The context network extracts features only from the first input image I_1. The architecture of the context network, h_θ is identical to the feature extraction network. Together, the feature network g_θ and the context network h_θ form the first stage of our approach, which only need to be performed once.



 §.§ Computing Visual Similarity



We compute visual similarity by constructing a full correlation volume between all pairs. Given image features g_θ(I_1) ∈ℝ^H × W × D and g_θ(I_2) ∈ℝ^H × W × D, the correlation volume is formed by taking the dot product between all pairs of feature vectors. The correlation volume, 𝐂, can be efficiently computed as a single matrix multiplication.

    𝐂(g_θ(I_1), g_θ(I_2)) ∈ℝ^H × W × H × W,     
        C_ijkl = ∑_h g_θ(I_1)_ijh· g_θ(I_2)_klh



Correlation Pyramid: We construct a 4-layer pyramid {𝐂^1, 𝐂^2, 𝐂^3, 𝐂^4 } by pooling the last two dimensions of the correlation volume with kernel sizes 1, 2, 4, and 8 and equivalent stride (Figure <ref>). Thus, volume 𝐂^k has dimensions H × W × H/2^k × W/2^k. The set of volumes gives information about both large and small displacements;  however, by maintaining the first 2 dimensions (the I_1 dimensions) we maintain high resolution information, allowing our method to recover the motions of small fast-moving objects.

Correlation Lookup:  We define a lookup operator L_𝐂 which generates a feature map by indexing from the correlation pyramid. Given a current estimate of optical flow (𝐟^1, 𝐟^2), we map each pixel 𝐱=(u, v) in I_1 to its estimated correspondence in I_2: 𝐱' = (u + f^1(u), v + f^2(v)). We then define a local grid around 𝐱'

    𝒩(𝐱')_r = {𝐱' + 𝐝𝐱 | 𝐝𝐱∈ℤ^2, ||𝐝𝐱||_1 ≤ r }

as the set of integer offsets which are within a radius of r units of 𝐱' using the L1 distance. We use the local neighborhood 𝒩(𝐱')_r to index from the correlation volume. Since 𝒩(𝐱')_r is a grid of real numbers, we use bilinear sampling. 

We perform lookups on all levels of the pyramid, such that the correlation volume at level k, 𝐂^k, is indexed using the grid 𝒩(𝐱' / 2^k)_r. A constant radius across levels means larger context at lower levels: for the lowest level, k=4 using a radius of 4 corresponds to a range of 256 pixels at the original resolution. The values from each level are then concatenated into a single feature map.



Efficient Computation for High Resolution Images:  The all pairs correlation scales O(N^2) where N is the number of pixels, but only needs to be computed once and is constant in the number of iterations M. However, there exists an equivalent implementation of our approach which scales O(NM) exploiting the linearity of the inner product and  average pooling. Consider the cost volume at level m, 𝐂^m_ijkl, and feature maps g^(1) = g_θ(I_1), g^(2) = g_θ(I_2):

    𝐂^m_ijkl = 1/2^2m∑_p^2^m∑_q^2^m⟨ g^(1)_i,j, g^(2)_2^mk+p,2^ml+q⟩ 
            = ⟨ g^(1)_i,j, 1/2^2m (∑_p^2^m∑_q^2^m g^(2)_2^mk+p,2^ml+q) ⟩

which is the average over the correlation response in the 2^m × 2^m grid. This means that the value at 𝐂^m_ijkl can be computed as the inner product between the feature vector g_θ(I_1)_ij and g_θ(I_2) pooled with kernel size 2^m × 2^m.

In this alternative implementation, we do not precompute the correlations, but instead precompute the pooled image feature maps. In each iteration, we compute each correlation value on demand—only when it is looked up. This gives a complexity of O(NM). 

We found empirically that precomputing all pairs is easy to implement and not a bottleneck, due to highly optimized matrix routines on GPUs—even for 1088x1920 videos it takes only 17% of total inference time. Note that we can always switch to the alternative implementation should it become a bottleneck. 




 §.§ Iterative Updates



Our update operator estimates a sequence of flow estimates {𝐟_1, ..., 𝐟_N } from an initial starting point 𝐟_0 = 0. With each iteration, it produces an update direction Δ𝐟 which is applied to the current estimate: 𝐟_k+1 = Δ𝐟 + 𝐟_k+1.

The update operator takes flow, correlation, and a latent hidden state as input, and outputs the update Δ𝐟 and an updated hidden state. The architecture of our update operator is designed to mimic the steps of an optimization algorithm. As such, we used tied weights across depth and use bounded activations to encourage convergence to a fixed point. The update operator is trained to perform updates such that the sequence converges to a fixed point 𝐟_k →𝐟^*.

Initialization:  By default, we initialize the flow field to 0 everywhere, but our iterative approach gives us the flexibility to experiment with alternatives. When applied to video, we test warm-start initialization, where optical flow from the previous pair of frames is forward projected to the next pair of frames with occlusion gaps filled in using nearest neighbor interpolation.

Inputs:  Given the current flow estimate 𝐟^k, we use it to retrieve correlation features from the correlation pyramid as described in Sec. <ref>. The correlation features are then processed by 2 convolutional layers. Additionally, we apply 2 convolutional layers to the flow estimate itself to generate flow features. Finally, we directly inject the input from the context network. The input feature map is then taken as the concatenation of the correlation, flow, and context features. 

Update:  A core component of the update operator is a gated activation unit based on the GRU cell, with fully connected layers replaced with convolutions:

    z_t = σ(Conv_3x3([h_t-1, x_t], W_z)) 
       r_t = σ(Conv_3x3([h_t-1, x_t], W_r)) 
       h̃_̃t̃ = tanh(Conv_3x3([r_t ⊙ h_t-1, x_t], W_h)) 
        h_t = (1 - z_t) ⊙ h_t-1 + z_t ⊙h̃_̃t̃

where x_t is the concatenation of flow, correlation, and context features previously defined. We also experiment with a separable ConvGRU unit, where we replace the 3 × 3 convolution with two GRUs: one with a 1×5 convolution and one with a 5×1 convolution to increase the receptive field without significantly increasing the size of the model.

Flow Prediction:  The hidden state outputted by the GRU is passed through two convolutional layers to predict the flow update Δ𝐟. The output flow is at 1/8 resolution of the input image. During training and evaluation, we upsample the predicted flow fields to match the resolution of the ground truth.

Upsampling:  The network outputs optical flow at 1/8 resolution. We upsample the optical flow to full resolution by taking the full resolution flow at each pixel to be the convex combination of a 3x3 grid of its coarse resolution neighbors. We use two convolutional layers to predict a H/8× W/8×(8×8×9) mask and perform softmax over the weights of the 9 neighbors. The final high resolution flow field is found by using the mask to take a weighted combination over the neighborhood, then permuting and reshaping to a H × W × 2 dimensional flow field. This layer can be directly implemented in PyTorch using the  function.



 §.§ Supervision

We supervised our network on the l_1 distance between the predicted and ground truth flow over the full sequence of predictions, {𝐟_1, ..., 𝐟_N }, with exponentially increasing weights. Given ground truth flow 𝐟_gt, the loss is defined as

    ℒ = ∑_i=1^Nγ^N-i ||𝐟_gt - 𝐟_i||_1

where we set γ=0.8 in our experiments.



§ EXPERIMENTS

We evaluate RAFT on Sintel<cit.> and KITTI<cit.>. Following previous works, we pretrain our network on FlyingChairs<cit.> and FlyingThings<cit.>, followed by dataset specific finetuning. Our method achieves state-of-the-art performance on both Sintel (both clean and final passes) and KITTI. Additionally, we test our method on 1080p video from the DAVIS dataset<cit.> to demonstrate that our method scales to  videos of very high resolutions. 

Implementation Details: 
RAFT is implemented in PyTorch<cit.>. All modules are initialized from scratch with random weights. During training, we use the AdamW<cit.> optimizer and clip gradients to the range [-1, 1]. Unless otherwise noted, we evaluate after 32 flow updates on Sintel and 24 on KITTI. For every update, Δ𝐟 + 𝐟_k, we only backpropgate the gradient through the Δ𝐟 branch, and zero the gradient through the 𝐟_k branch as suggested by <cit.>.

Training Schedule: 
We train RAFT using two 2080Ti GPUs. We pretrain on FlyingThings for 100k iterations with a batch size of 12, then train for 100k iterations on FlyingThings3D with a batch size of 6. We finetune on Sintel for another 100k by combining data from Sintel<cit.>, KITTI-2015 <cit.>, and HD1K<cit.> similar to MaskFlowNet <cit.> and PWC-Net+ <cit.>. Finally, we finetune on KITTI-2015 for an additionally 50k iterations using the weights from the model finetuned on Sintel. Details on training and data augmentation are provided in the supplemental material. For comparison with prior work, we also include results from our model when finetuning only on Sintel and only on KITTI.








 §.§ Sintel

We train our model using the FlyingChairs→FlyingThings schedule and then evaluate on the Sintel dataset using the train split for validation. Results are shown in Table <ref> and Figure <ref>, and we split results based on the data used for training. C + T means that the models are trained on FlyingChairs(C) and FlyingThings(T), while +ft indicates the model is finetuned on Sintel data. Like PWC-Net+<cit.> and MaskFlowNet <cit.> we include data from KITTI and HD1K when finetuning. We train 3 times with different seeds, and report results using the model with the median accuracy on the clean pass of Sintel (train).








When using C+T for training, our method outperforms all existing approaches, despite using a significantly shorter training schedule. Our method achieves an average EPE (end-point-error) of 1.43 on the Sintel(train) clean pass, which is a 29% lower error than FlowNet2. These results demonstrates good cross dataset generalization. One of the reasons for better generalization is the structure of our network. By constraining optical flow to be the product of a series of identical update steps, we force the network to learn an update operator which mimics the updates of a first-order descent algorithm. This constrains the search space, reduces the risk of over-fitting, and leads to faster training and better generalization.

When evaluating on the Sintel(test) set, we finetune on the combined clean and final passes of the training set along with KITTI and HD1K data. Our method ranks 1st on both the Sintel clean and final passes, and outperforms all prior work by 0.9 pixels (36%) on the clean pass and 1.2 pixels (30%) on the final pass. We evaluate two versions of our model, Ours (two-frame) uses zero initialization, while Ours (warp-start) initializes flow by forward projecting the flow estimate from the previous frame. Since our method operates at a single resolution, we can initialize the flow estimate to utilize motion smoothness from past frames, which cannot be easily done using the coarse-to-fine model.




 §.§ KITTI

We also evaluate RAFT on KITTI and provide results in Table <ref> and Figure <ref>. We first evaluate cross-dataset generalization by evaluating on the KITTI-15 (train) split after training on Chairs(C) and FlyingThings(T). Our method outperforms prior works by a large margin, improving EPE (end-point-error) from 8.36 to 5.04, which shows that the underlying structure of our network facilitates generalization. Our method ranks 1st on the KITTI leaderboard among all optical flow methods.





 §.§ Ablations


We perform a set of ablation experiments to show the relative importance of each component. All ablated versions are trained on FlyingChairs(C) + FlyingThings(T). Results of the ablations are shown in Table <ref>. In each section of the table, we test a specific component of our approach in isolation, the settings which are used in our final model is underlined. Below we describe each of the experiments in more detail.




Architecture of Update Operator:  We use a gated activation unit based on the GRU cell. We experiment with replacing the convolutional GRU with a set of 3 convolutional layers with ReLU activation. We achieve better performance by using the GRU block, likely because the gated activation makes it easier for the sequence of flow estimates to converge.

Weight Tying:  By default, we tied the weights across all instances of the update operator. Here, we test a version of our approach where each update operator learns a separate set of weights. Accuracy is better when weights are tied and the parameter count is significantly lower.

Context:  We test the importance of context by training a model with the context network removed. Without context, we still achieve good results, outperforming all existing works on both Sintel and KITTI. But context is helpful. Directly injecting image features into the update operator likely allows spatial information to be better aggregated within motion boundaries.

Feature Scale:  By default, we extract features at a single resolution. We also try extracting features at multiple resolutions by building a correlation volume at each scale separately. Single resolution features simplifies the network architecture and allows fine-grained matching even at large displacements. 

Lookup Radius:  The lookup radius specifies the dimensions of the grid used in the lookup operation. When a radius of 0 is used, the correlation volume is retrieved at a single point. Surprisingly, we can still get a rough estimate of flow when the radius is 0, which means the network is learning to use 0'th order information. However, we see better results as the radius is increased.

Correlation Pooling:  We output features at a single resolution and then perform pooling to generate multiscale volumes. Here we test the impact when this pooling is removed. Results are better with pooling, because large and small displacements are both captured.

Correlation Range:  Instead of all-pairs correlation, we also try constructing the correlation volume only for a local neighborhood around each pixel. We try a range of 32 pixels, 64 pixels, and 128 pixels. Overall we get the best results when the all-pairs are used, although a 128px range is sufficient to perform well on Sintel because most displacements fall within this range. That said, all-pairs is still preferable because it eliminates the need to specify a range. It is also more convenient to implement: it can be computed using matrix multiplication allowing our approach to be implemented entirely in PyTorch.  

Features for Refinement:  We compute visual similarity by building a correlation volume between all pairs of pixels. In this experiment, we try replacing the correlation volume with a warping layer, which uses the current estimate of optical flow to warp features from I_2 onto I_1 and then estimates the residual displacement. While warping is still competitive with prior work on Sintel, correlation performs significantly better, especially on KITTI.

Upsampling:  RAFT outputs flow fields at 1/8 resolution. We compare bilinear upsampling to our learned upsampling module. The upsampling module produces better results, particularly near motion boundaries.

Inference Updates:  Although we unroll 12 updates during training, we can apply an arbitrary number of updates during inference. In Table <ref> we provide numerical results for selected number of updates, and test an extreme case of 200 to show that our method doesn't diverge. Our method quickly converges, surpassing PWC-Net after 3 updates and FlowNet2 after 6 updates, but continues to improve with more updates. 




 §.§ Timing and Parameter Counts

Inference time and parameter counts are shown in Figure <ref>. Accuracy is determined by performance on the Sintel(train) final pass after training on FlyingChairs and FlyingThings (C+T). In these plots, we report accuracy and timing after 10 iterations, and we time our method using a GTX 1080Ti GPU. Parameters counts for other methods are taken as reported in their papers, and we report times when run on our hardware. RAFT is more efficient in terms of parameter count, inference time, and training iterations. Ours-S uses only 1M parameters, but outperforms PWC-Net and VCN which are more than 6x larger. We provide an additional table with numerical values for parameters, timing, and training iterations in the supplemental material. 









 §.§ Video of Very High Resolution

To demonstrate that our method scales well to videos of very high resolution we apply our network to HD video from the DAVIS<cit.> dataset. We use 1080p (1088x1920) resolution video and apply 12 iterations of our approach. Inference takes 550ms for 12 iterations on 1080p video, with all-pairs correlation taking 95ms. Fig. <ref> visualizes example results on DAVIS. 



§ CONCLUSIONS

We have proposed RAFT—Recurrent All-Pairs Field Transforms—a new end-to-end trainable model for optical flow.  RAFT is unique in that it operates at a single resolution using a large number of lightweight, recurrent update operators. Our method achieves state-of-the-art accuracy across a diverse range of datasets, strong cross dataset generalization, and is efficient in terms of inference time, parameter count, and training iterations.

Acknowledgments:   This  work was partially funded by the National Science Foundation under Grant No. 1617767.


splncs04









§ NETWORK ARCHITECTURE










§ UPSAMPLING MODULE













§ TRAINING DETAILS





Photometric Augmentation:  We perform photometric augmentation by randomly perturbing brightness, contrast, saturation, and hue. We use the Torchvision  with brightness 0.4, contrast 0.4, saturation 0.4, and hue 0.5/π. On KITTI, we reduce the degree of augmentation to brightness 0.3, contrast 0.3, saturation 0.3, and hue 0.3/π. With probablity 0.2, color augmentation is performed to each of the images independently. 



Spatial Augmentation:  We perform spatial augmentation by randomly rescaling and stretching the images. The degree of random scaling depends on the dataset. For FlyingChairs, we perform spatial augmentation in the range 2^[-0.2, 1.0], FlyingThings 2^[-0.4, 0.8], Sintel 2^[-0.2, 0.6], and KITTI 2^[-0.2, 0.4]. Spatial augmentation is performed with probability 0.8. 



Occlusion Augmentation:  Following HSM-Net <cit.>, we also randomly erase rectangular regions in I_2 with probability 0.5 to simulate occlusions.



§ TIMING, PARAMETERS, AND TRAINING ITERATIONS











