Layers and other models#

Layers#

class kornia.feature.FilterResponseNorm2d(num_features, eps=1e-6, is_bias=True, is_scale=True, is_eps_leanable=False)[source]#

Feature Response Normalization layer from ‘Filter Response Normalization Layer: Eliminating Batch Dependence in the Training of Deep Neural Networks’, see [SK20] for more details.

\[y = \gamma \times \frac{x}{\sqrt{\mathrm{E}[x^2]} + |\epsilon|} + \beta\]
Parameters:
  • num_features (int) – number of channels

  • eps (float, optional) – normalization constant Default: 1e-6

  • is_bias (bool, optional) – use bias Default: True

  • is_scale (bool, optional) – use scale Default: True

  • drop_rate – dropout rate,

  • is_eps_leanable (bool, optional) – if eps is learnable Default: False

Returns:

Normalized features

Return type:

torch.Tensor

Shape:
  • Input: \((B, \text{num_features}, H, W)\)

  • Output: \((B, \text{num_features}, H, W)\)

class kornia.feature.TLU(num_features)[source]#

TLU layer from ‘Filter Response Normalization Layer: Eliminating Batch Dependence in the Training of Deep Neural Networks, see [SK20] for more details. \({\tau}\) is learnable per channel.

\[y = \max(x, {\tau})\]
Parameters:

num_features (int) – number of channels

Returns:

torch.Tensor

Shape:
  • Input: \((B, \text{num_features}, H, W)\)

  • Output: \((B, \text{num_features}, H, W)\)

Fast moving objects#

class kornia.feature.DeFMO(pretrained=False)[source]#

nn.Module that disentangle a fast-moving object from the background and performs deblurring.

This is based on the original code from paper “DeFMO: Deblurring and Shape Recovery

of Fast Moving Objects”. See [ROF+21] for more details.

Parameters:

pretrained (bool, optional) – Download and set pretrained weights to the model. Default: false.

Returns:

Temporal super-resolution without background.

Shape:
  • Input: (B, 6, H, W)

  • Output: (B, S, 4, H, W)

Examples

>>> import kornia
>>> input = torch.rand(2, 6, 240, 320)
>>> defmo = kornia.feature.DeFMO()
>>> tsr_nobgr = defmo(input) # 2x24x4x240x320
forward(input_data)[source]#

Deblur a fast-moving object into a sequence of RGBA sub-frames.

Parameters:

input_data (Tensor) – Tensor with shape \((B, 6, H, W)\) containing the blurred RGB image concatenated with an RGB background estimate.

Return type:

Tensor

Returns:

Tensor with shape \((B, T, 4, H, W)\), where T is the number of temporal sub-frames and 4 stores red, green, blue, and alpha channels.