Encoder
Convolution Encoder
- class ezflow.encoder.conv_encoder.BasicConvEncoder(in_channels=3, config=[64, 128, 256, 512], norm=None)[source]
A Basic Convolution Encoder with a fixed size kernel = 3, padding=1 and dilation = 1. Every alternate layer has stride = 1 followed by stride = 2.
- Parameters
in_channels (int) – Number of input channels
config (list of int) – Configuration for the layers in the encoder
norm (str) – Type of normalization to use. Can be None, ‘batch’, ‘group’, ‘instance’
- class ezflow.encoder.conv_encoder.FlowNetConvEncoder(in_channels=3, config=[64, 128, 256, 512], norm=None)[source]
Convolutional encoder based on the FlowNet architecture Used in FlowNet: Learning Optical Flow with Convolutional Networks (https://arxiv.org/abs/1504.06852)
- Parameters
in_channels (int) – Number of input channels
config (list of int) – Configuration for the layers in the encoder
norm (str) – Type of normalization to use. Can be None, ‘batch’, ‘group’, ‘instance’
GANet
- class ezflow.encoder.ganet.GANetBackbone(in_channels=3, out_channels=32)[source]
Feature extractor backbone used in GA-Net: Guided Aggregation Net for End-to-end Stereo Matching (https://arxiv.org/abs/1904.06587)
- Parameters
in_channels (int) – Number of input channels
out_channels (int) – Number of output channels
- 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.
PSPNet
- class ezflow.encoder.pspnet.PSPNetBackbone(is_proj=True, groups=1, in_channels=3, norm=True)[source]
PSPNet feature extractor backbone (https://arxiv.org/abs/1612.01105) Used in Volumetric Correspondence Networks for Optical Flow (https://papers.nips.cc/paper/2019/hash/bbf94b34eb32268ada57a3be5062fe7d-Abstract.html)
- Parameters
is_proj (bool) – Whether to use projection pooling or not
groups (int) – Number of groups in the convolutional
in_channels (int) – Number of input channels
norm (bool) – Whether to use batch normalization
- 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.encoder.pspnet.PyramidPooling(in_channels, levels=4, norm=True)[source]
Pyramid pooling module for the PSPNet feature extractor
- Parameters
in_channels (int) – Number of input channels
levels (int) – Number of levels in the pyramid
norm (bool) – Whether to use batch normalization
- 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.encoder.pspnet.ResidualBlock(in_channels, out_channels, stride=1, downsample=None, dilation=1, norm=True)[source]
- 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.
Pyramid
- class ezflow.encoder.pyramid.PyramidEncoder(in_channels=3, config=[16, 32, 64, 96, 128, 196])[source]
Pyramid encoder which returns a hierarchy of features Used in PWC-Net: CNNs for Optical Flow Using Pyramid, Warping, and Cost Volume (https://arxiv.org/abs/1709.02371)
- Parameters
in_channels (int) – Number of input channels
config (list of int) – Configuration of the pyramid encoder’s layers
Residual
- class ezflow.encoder.residual.BasicEncoder(in_channels=3, out_channels=128, norm='batch', p_dropout=0.0, layer_config=(64, 96, 128), intermediate_features=False)[source]
ResNet-style encoder with basic residual blocks
- Parameters
in_channels (int) – Number of input channels
out_channels (int) – Number of output channels
norm (str) – Normalization layer to use. One of “batch”, “instance”, “group”, or None
p_dropout (float) – Dropout probability
layer_config (list of int or tuple of int) – Configuration of encoder’s layers
intermediate_features (bool) – Whether to return intermediate features to get a feature hierarchy
- 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.encoder.residual.BottleneckEncoder(in_channels=3, out_channels=128, norm='batch', p_dropout=0.0, layer_config=(32, 64, 96), intermediate_features=False)[source]
ResNet-style encoder with bottleneck residual blocks
- Parameters
in_channels (int) – Number of input channels
out_channels (int) – Number of output channels
norm (str) – Normalization layer to use. One of “batch”, “instance”, “group”, or None
p_dropout (float) – Dropout probability
layer_config (list of int or tuple of int) – Configuration of encoder’s layers
intermediate_features (bool) – Whether to return intermediate features to get a feature hierarchy
- 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.
Builder
- ezflow.encoder.build.build_encoder(cfg_grp=None, name=None, instantiate=True, **kwargs)[source]
Build an encoder from a registered encoder name
- Parameters
cfg (
CfgNode
) – Config to pass to the encodername (str) – Name of the registered encoder
instantiate (bool) – Whether to instantiate the encoder
kwargs (dict) – Additional keyword arguments to pass to the encoder
- Returns
The encoder object
- Return type
torch.nn.Module