In this release we have focus in bringing more classic Computer Vision functionalities to the PyTorch ecosystem, like morphological operators and more diversity with Deep Local Descriptors, color conversions and drawing functions. In addition, we have worked towards improving the integration with TPU and better support with Torchscript.

Morphological Operators

As a highlight we include a kornia.morphology that implements several functionalities to work with morphological operators on high-dimensional tensors and differentiability. Contributed by @Juclique

Morphology implements the following methods: dilation, erosion, open, close, close, gradient, top_hat and black_hat.

from kornia import morphology as morph

dilated_image = morph.dilation(tensor, kernel) # Dilation
plot_morph_image(dilated_image) # Plot

See a full tutorial here:

Deep Descriptors

We have added a set of local feature-related models: MKDDescriptor #841 by implemented and ported to kornia by @manyids2; also we ported TFeat, AffNet, OriNet from authors repos #846.

Here is notebook, showing the usage and benefits of new features. We also show how to seamlessly integrate kornia and opencv code via new conversion library kornia_moons.

Also: exposed set_laf_orientation function #869

Video Augmentations

We include a new operator to perform augmentations with videos VideoSequential. The module is based in nn.Sequential and has the ability to concatenate our existing kornia.augmentations for multi-dimensional video tensors. Contributed by @shijianjian

import kornia
import torchvision

clip, _, _ ="drop.avi")
clip = clip.permute(3, 0, 1, 2)[None] / 255.  # To BCTHW
input = torch.randn(2, 3, 1, 5, 6).repeat(1, 1, 4, 1, 1)

aug_list = VideoSequential(
    kornia.augmentation.ColorJitter(0.1, 0.1, 0.1, 0.1, p=1.0),
    kornia.augmentation.RandomAffine(360, p=1.0),

out = aug(input)

See a full example in the following Colab:

Draw functions

We include an experimental functionality draw_rectangle implemented in pure torch.tensor. Contributed by @mmathew23

rects = torch.tensor([[[110., 50., 310., 275.], [325., 100., 435., 275.]]])
color = torch.tensor([255., 0., 0.])

x_out = K.utils.draw_rectangle(x_rgb, rects, color)

See full example here:

More user contrib



  • Deprecated kornia.geometry.warp module.
    • DepthWarper is now in kornia.geometry.depth
    • HomographyWarper and related functions are now inside kornia.geometry.transform.
  • Deprecated kornia.contrib module.
    • max_pool_blurd2d is now in kornia.filters
  • Dropped support of Pytorch 1.5.1 #854

Warp and Crop

We refactored the interface of the functions warp_perspective, warp_affine, center_crop, crop_and_resize and crop_by_boxes in order to expose to the user the needed parameters by grid_sample [mode, padding_mode, align_corners]. #896

The param align_corners has been set by default to None that maps to True in case the user does not specify. This comes from the motivation to match the behavior of the warping functions with OpenCV.

Example of warp_perspective:

def warp_perspective(src: torch.Tensor, M: torch.Tensor, dsize: Tuple[int, int],
                     mode: str = 'bilinear', padding_mode: str = 'zeros',
                     align_corners: Optional[bool] = None) -> torch.Tensor:

Please review the full release notes here:

Thanks to all our contributors !!! :sunglasses: