Shortcuts

raft_small

torchvision.models.optical_flow.raft_small(*, weights: Optional[Raft_Small_Weights] = None, progress=True, **kwargs) RAFT[source]

RAFT “small” model from RAFT: Recurrent All Pairs Field Transforms for Optical Flow.

Please see the example below for a tutorial on how to use this model.

Parameters:
  • weights (Raft_Small_Weights, optional) – The pretrained weights to use. See Raft_Small_Weights below for more details, and possible values. By default, no pre-trained weights are used.

  • progress (bool) – If True, displays a progress bar of the download to stderr. Default is True.

  • **kwargs – parameters passed to the torchvision.models.optical_flow.RAFT base class. Please refer to the source code for more details about this class.

class torchvision.models.optical_flow.Raft_Small_Weights(value)[source]

The model builder above accepts the following values as the weights parameter. Raft_Small_Weights.DEFAULT is equivalent to Raft_Small_Weights.C_T_V2. You can also use strings, e.g. weights='DEFAULT' or weights='C_T_V1'.

The metrics reported here are as follows. epe is the “end-point-error” and indicates how far (in pixels) the predicted flow is from its true value. This is averaged over all pixels of all images. per_image_epe is similar, but the average is different: the epe is first computed on each image independently, and then averaged over all images. This corresponds to “Fl-epe” (sometimes written “F1-epe”) in the original paper, and it’s only used on Kitti. fl-all is also a Kitti-specific metric, defined by the author of the dataset and used for the Kitti leaderboard. It corresponds to the average of pixels whose epe is either <3px, or <5% of flow’s 2-norm.

Raft_Small_Weights.C_T_V1:

These weights were ported from the original paper. They are trained on FlyingChairs + FlyingThings3D.

epe (on Sintel-Train-Cleanpass)

2.1231

epe (on Sintel-Train-Finalpass)

3.279

per_image_epe (on Kitti-Train)

7.6557

fl_all (on Kitti-Train)

25.2801

min_size

height=128, width=128

num_params

990162

recipe

link

GFLOPS

47.66

File size

3.8 MB

The inference transforms are available at Raft_Small_Weights.C_T_V1.transforms and perform the following preprocessing operations: Accepts PIL.Image, batched (B, C, H, W) and single (C, H, W) image torch.Tensor objects. The images are rescaled to [-1.0, 1.0].

Raft_Small_Weights.C_T_V2:

These weights were trained from scratch on FlyingChairs + FlyingThings3D. Also available as Raft_Small_Weights.DEFAULT.

epe (on Sintel-Train-Cleanpass)

1.9901

epe (on Sintel-Train-Finalpass)

3.2831

per_image_epe (on Kitti-Train)

7.5978

fl_all (on Kitti-Train)

25.2369

min_size

height=128, width=128

num_params

990162

recipe

link

GFLOPS

47.66

File size

3.8 MB

The inference transforms are available at Raft_Small_Weights.C_T_V2.transforms and perform the following preprocessing operations: Accepts PIL.Image, batched (B, C, H, W) and single (C, H, W) image torch.Tensor objects. The images are rescaled to [-1.0, 1.0].

Examples using raft_small:

Optical Flow: Predicting movement with the RAFT model

Optical Flow: Predicting movement with the RAFT model

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources