Criterion

Sequence Loss

class ezflow.functional.criterion.sequence.SequenceLoss(gamma=0.8, max_flow=400)[source]

Sequence loss for optical flow estimation. Used in RAFT (https://arxiv.org/abs/2003.12039)

Parameters
  • gamma (float) – Weight for the loss

  • max_flow (float) – Maximum flow magnitude

forward(pred, label)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Multi-scale Loss

class ezflow.functional.criterion.multiscale.MultiScaleLoss(norm='l1', weights=(1, 0.5, 0.25), extra_mask=None, use_valid_range=True, valid_range=None)[source]

Multi-scale loss for optical flow estimation. Used in DICL (https://papers.nips.cc/paper/2020/hash/add5aebfcb33a2206b6497d53bc4f309-Abstract.html)

Parameters
  • norm (str) – The norm to use for the loss. Can be either “l2”, “l1” or “robust”

  • weights (list) – The weights to use for each scale

  • extra_mask (torch.Tensor) – A mask to apply to the loss. Useful for removing the loss on the background

  • use_valid_range (bool) – Whether to use the valid range of flow values for the loss

  • valid_range (list) – The valid range of flow values for each scale

forward(pred, label)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.