Learnable Cost
- class ezflow.similarity.learnable_cost.Conv2DMatching(config=(64, 96, 128, 64, 32, 1))[source]
Convolutional matching/filtering network for cost volume learning
- Parameters
config (tuple of int or list of int) – Configuration of the convolutional layers in the network
- forward(x)[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.
- class ezflow.similarity.learnable_cost.Custom2DConvMatching(config=(16, 32, 16, 1), kernel_size=3, **kwargs)[source]
Convolutional matching/filtering network for cost volume learning with custom convolutions
- Parameters
config (tuple of int or list of int) – Configuration of the convolutional layers in the network
kernel_size (int) – Kernel size of the convolutional layers
**kwargs – Additional keyword arguments for the convolutional layers
- forward(x)[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.
- class ezflow.similarity.learnable_cost.LearnableMatchingCost(max_u=3, max_v=3, config=(64, 96, 128, 64, 32, 1), remove_warp_hole=True, cuda_cost_compute=False, matching_net=None)[source]
Learnable matching cost network for cost volume learning. Used in DICL (https://arxiv.org/abs/2010.14851)
- Parameters
max_u (int, optional) – Maximum displacement in the horizontal direction
max_v (int, optional) – Maximum displacement in the vertical direction
config (tuple of int or list of int, optional) – Configuration of the convolutional layers (matching net) in the network
remove_warp_hole (bool, optional) – Whether to remove the warp holes in the cost volume
cuda_cost_compute (bool, optional) – Whether to compute the cost volume on the GPU
matching_net (Optional[nn.Module], optional) – Custom matching network, by default None, which uses a Conv2DMatching network
- forward(x, y)[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.
- class ezflow.similarity.learnable_cost.MatryoshkaDilatedCostVolume(num_groups=1, max_displacement=4, stride=1, dilations=[1, 2, 3, 5, 9, 16], use_relu=False)[source]
Cost Volume with concentric offset dilations used in DCVNet: Dilated Cost Volume Networks for Fast Optical Flow
- Parameters
num_groups (int, default 1) – Divides channels into groups of batches for batch processing of similarity computation.
max_displacement (int, default 4) – Determines the cost volume search range/patch size.
stride (int, default 1) – Stride of the spatial sampler
dilations (List[int], default [1, 2, 3, 5, 9, 16]) – List of steps for every shift in patch.
use_relu (bool, default False) – If True, applies ReLU activation to the cost volume output.
- forward(x1, x2)[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.
- class ezflow.similarity.learnable_cost.MatryoshkaDilatedCostVolumeList(num_groups=1, max_displacement=4, encoder_output_strides=[2, 8], dilations=[[1], [1, 2, 3, 5, 9, 16]], normalize_feat_l2=False, use_relu=False)[source]
A List of Cost Volume with concentric offset dilations used in DCVNet: Dilated Cost Volume Networks for Fast Optical Flow
- Parameters
num_groups (int, default 1) – Divides channels into groups of batches for batch processing of similarity computation.
max_displacement (int, default 4) – Determines the cost volume search range/patch size.
encoder_output_strides (List[int], default [2, 8]) – Stride of the feature maps from the encoder output, will modify output height and width.
dilations (List[int], default [1, 2, 3, 5, 9, 16]) – List of steps for every shift in patch.
normalize_feat_l2 (bool, default False) – If True, normalizes input feature maps.
use_relu (bool, default False) – If True, applies ReLU activation to the cost volume output.
- forward(x1, x2)[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.