π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
Upgrade to modern Python syntax (#1213)
Christian Clauss09e8ee775684
diff --git a/docs/generate_example_images.py b/docs/generate_example_images.pyindex 2af139846..f63158608 100644--- a/docs/generate_example_images.py+++ b/docs/generate_example_images.py@@ -97,7 +97,7 @@ def main():h_dif, w_dif = int(h - h_new), int(w - w_new)out = torch.nn.functional.pad(out, (w_dif // 2, w_dif // 2, 0, h_dif))- out = torch.cat([img_in[0], *[out[i] for i in range(out.size(0))]], dim=-1)+ out = torch.cat([img_in[0], *(out[i] for i in range(out.size(0)))], dim=-1)# save the output imageout_np = K.utils.tensor_to_image((out * 255.0).byte())cv2.imwrite(str(OUTPUT_PATH / f"{aug_name}.png"), out_np)@@ -119,7 +119,7 @@ def main():torch.manual_seed(seed)# apply the augmentaiton to the image and concatout, _ = aug(img_in, torch.tensor([0, 1]))- out = torch.cat([img_in[0], img_in[1], *[out[i] for i in range(out.size(0))]], dim=-1)+ out = torch.cat([img_in[0], img_in[1], *(out[i] for i in range(out.size(0)))], dim=-1)# save the output imageout_np = K.utils.tensor_to_image((out * 255.0).byte())cv2.imwrite(str(OUTPUT_PATH / f"{aug_name}.png"), out_np)@@ -162,10 +162,10 @@ def main():# save the output imageif fn_name == "grayscale_to_rgb":out = torch.cat(- [K.rgb_to_grayscale(img2[0]).repeat(3, 1, 1), *[out[i] for i in range(out.size(0))]], dim=-1+ [K.rgb_to_grayscale(img2[0]).repeat(3, 1, 1), *(out[i] for i in range(out.size(0)))], dim=-1)else:- out = torch.cat([img2[0], *[out[i] for i in range(out.size(0))]], dim=-1)+ out = torch.cat([img2[0], *(out[i] for i in range(out.size(0)))], dim=-1)out_np = K.utils.tensor_to_image((out * 255.0).byte())cv2.imwrite(str(OUTPUT_PATH / f"{fn_name}.png"), out_np)sig = f"{fn_name}({', '.join([str(a) for a in args])})"@@ -198,7 +198,7 @@ def main():fn = getattr(mod, fn_name)out = fn(*args_in)# save the output image- out = torch.cat([img_in[0], *[out[i] for i in range(out.size(0))]], dim=-1)+ out = torch.cat([img_in[0], *(out[i] for i in range(out.size(0)))], dim=-1)out_np = K.utils.tensor_to_image((out * 255.0).byte())cv2.imwrite(str(OUTPUT_PATH / f"{fn_name}.png"), out_np)sig = f"{fn_name}({', '.join([str(a) for a in args])})"@@ -225,7 +225,7 @@ def main():fn = getattr(mod, fn_name)out = fn(*args_in)# save the output image- out = torch.cat([img_in[0], *[out[i] for i in range(out.size(0))]], dim=-1)+ out = torch.cat([img_in[0], *(out[i] for i in range(out.size(0)))], dim=-1)out_np = K.utils.tensor_to_image((out * 255.0).byte())cv2.imwrite(str(OUTPUT_PATH / f"{fn_name}.png"), out_np)sig = f"{fn_name}({', '.join([str(a) for a in args])})"@@ -265,7 +265,7 @@ def main():if fn_name == "spatial_gradient":out = out.permute(2, 1, 0, 3, 4).squeeze()# save the output image- out = torch.cat([img_in[0], *[out[i] for i in range(out.size(0))]], dim=-1)+ out = torch.cat([img_in[0], *(out[i] for i in range(out.size(0)))], dim=-1)out_np = K.utils.tensor_to_image((out * 255.0).byte())cv2.imwrite(str(OUTPUT_PATH / f"{fn_name}.png"), out_np)sig = f"{fn_name}({', '.join([str(a) for a in args])})"@@ -337,7 +337,7 @@ def main():_out.append(out_tmp)out = torch.cat(_out)# save the output image- out = torch.cat([img_in[0], *[out[i] for i in range(out.size(0))]], dim=-1)+ out = torch.cat([img_in[0], *(out[i] for i in range(out.size(0)))], dim=-1)out_np = K.utils.tensor_to_image((out * 255.0).byte())cv2.imwrite(str(OUTPUT_PATH / f"{fn_name}.png"), out_np)sig = f"{fn_name}({', '.join([str(a) for a in args])})"diff --git a/docs/source/conf.py b/docs/source/conf.pyindex b6d6cc084..3c087e602 100644--- a/docs/source/conf.py+++ b/docs/source/conf.py@@ -67,9 +67,9 @@ source_suffix = ['.rst', '.ipynb']master_doc = 'index'# General information about the project.-project = u'Kornia'-author = u'%s developers' % project-copyright = u'2019, %s' % author+project = 'Kornia'+author = f'{project} developers'+copyright = f'2019, {author}'# The version info for the project you're documenting, acts as replacement for# |version| and |release|, also used in various other places throughout the@@ -165,14 +165,14 @@ latex_elements = {# Grouping the document tree into LaTeX files. List of tuples# (source start file, target name, title,# author, documentclass [howto, manual, or own class]).-latex_documents = [(master_doc, 'kornia.tex', u'Kornia', 'manual')]+latex_documents = [(master_doc, 'kornia.tex', 'Kornia', 'manual')]# -- Options for manual page output ---------------------------------------# One entry per manual page. List of tuples# (source start file, name, description, authors, manual section).-man_pages = [(master_doc, 'Kornia', u'Kornia Documentation', [author], 1)]+man_pages = [(master_doc, 'Kornia', 'Kornia Documentation', [author], 1)]# -- Options for Texinfo output -------------------------------------------diff --git a/kornia/augmentation/augmentation.py b/kornia/augmentation/augmentation.pyindex 2377d38ac..1ddcdd591 100644--- a/kornia/augmentation/augmentation.py+++ b/kornia/augmentation/augmentation.py@@ -218,9 +218,7 @@ class ColorJitter(IntensityAugmentationBase2D):p: float = 1.0,keepdim: bool = False,) -> None:- super(ColorJitter, self).__init__(- p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim- )+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim)self._device, self._dtype = _extract_device_dtype([brightness, contrast, hue, saturation])self.brightness = brightnessself.contrast = contrast@@ -306,9 +304,7 @@ class RandomGrayscale(IntensityAugmentationBase2D):def __init__(self, return_transform: bool = False, same_on_batch: bool = False, p: float = 0.1, keepdim: bool = False) -> None:- super(RandomGrayscale, self).__init__(- p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim- )+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim)def __repr__(self) -> str:return self.__class__.__name__ + f"({super().__repr__()})"@@ -372,9 +368,7 @@ class RandomErasing(IntensityAugmentationBase2D):p: float = 0.5,keepdim: bool = False,) -> None:- super(RandomErasing, self).__init__(- p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim- )+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim)self._device, self._dtype = _extract_device_dtype([scale, ratio])self.scale = scaleself.ratio = ratio@@ -462,9 +456,7 @@ class RandomPerspective(GeometricAugmentationBase2D):p: float = 0.5,keepdim: bool = False,) -> None:- super(RandomPerspective, self).__init__(- p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim- )+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim)self._device, self._dtype = _extract_device_dtype([distortion_scale])self.distortion_scale = distortion_scaleself.resample: Resample = Resample.get(resample)@@ -579,9 +571,7 @@ class RandomAffine(GeometricAugmentationBase2D):p: float = 0.5,keepdim: bool = False,) -> None:- super(RandomAffine, self).__init__(- p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim- )+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim)self._device, self._dtype = _extract_device_dtype([degrees, translate, scale, shear])self.degrees = degreesself.translate = translate@@ -757,9 +747,7 @@ class CenterCrop(GeometricAugmentationBase2D):) -> None:# same_on_batch is always True for CenterCrop# Since PyTorch does not support ragged tensor. So cropping function happens batch-wisely.- super(CenterCrop, self).__init__(- p=1.0, return_transform=return_transform, same_on_batch=True, p_batch=p, keepdim=keepdim- )+ super().__init__(p=1.0, return_transform=return_transform, same_on_batch=True, p_batch=p, keepdim=keepdim)if isinstance(size, tuple):self.size = (size[0], size[1])elif isinstance(size, int):@@ -886,9 +874,7 @@ class RandomRotation(GeometricAugmentationBase2D):p: float = 0.5,keepdim: bool = False,) -> None:- super(RandomRotation, self).__init__(- p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim- )+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim)self._device, self._dtype = _extract_device_dtype([degrees])self.degrees = degreesself.resample: Resample = Resample.get(resample)@@ -999,7 +985,7 @@ class RandomCrop(GeometricAugmentationBase2D):cropping_mode: str = 'slice',) -> None:# Since PyTorch does not support ragged tensor. So cropping function happens batch-wisely.- super(RandomCrop, self).__init__(+ super().__init__(p=1.0, return_transform=return_transform, same_on_batch=same_on_batch, p_batch=p, keepdim=keepdim)self.size = size@@ -1222,7 +1208,7 @@ class RandomResizedCrop(GeometricAugmentationBase2D):cropping_mode: str = 'slice',) -> None:# Since PyTorch does not support ragged tensor. So cropping function happens all the time.- super(RandomResizedCrop, self).__init__(+ super().__init__(p=1.0, return_transform=return_transform, same_on_batch=same_on_batch, p_batch=p, keepdim=keepdim)self._device, self._dtype = _extract_device_dtype([scale, ratio])@@ -1351,7 +1337,7 @@ class Normalize(IntensityAugmentationBase2D):p: float = 1.0,keepdim: bool = False,) -> None:- super(Normalize, self).__init__(p=p, return_transform=return_transform, same_on_batch=True, keepdim=keepdim)+ super().__init__(p=p, return_transform=return_transform, same_on_batch=True, keepdim=keepdim)if isinstance(mean, float):mean = torch.tensor([mean])@@ -1412,7 +1398,7 @@ class Denormalize(IntensityAugmentationBase2D):p: float = 1.0,keepdim: bool = False,) -> None:- super(Denormalize, self).__init__(p=p, return_transform=return_transform, same_on_batch=True, keepdim=keepdim)+ super().__init__(p=p, return_transform=return_transform, same_on_batch=True, keepdim=keepdim)self.mean = meanself.std = std@@ -1488,9 +1474,7 @@ class RandomMotionBlur(IntensityAugmentationBase2D):p: float = 0.5,keepdim: bool = False,) -> None:- super(RandomMotionBlur, self).__init__(- p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim- )+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim)self.kernel_size: Union[int, Tuple[int, int]] = kernel_sizeself._device, self._dtype = _extract_device_dtype([angle, direction])@@ -1584,7 +1568,7 @@ class RandomSolarize(IntensityAugmentationBase2D):p: float = 0.5,keepdim: bool = False,) -> None:- super(RandomSolarize, self).__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch)+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch)self._device, self._dtype = _extract_device_dtype([thresholds, additions])self.thresholds = thresholdsself.additions = additions@@ -1659,9 +1643,7 @@ class RandomPosterize(IntensityAugmentationBase2D):p: float = 0.5,keepdim: bool = False,) -> None:- super(RandomPosterize, self).__init__(- p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim- )+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim)self._device, self._dtype = _extract_device_dtype([bits])self.bits = bits@@ -1725,9 +1707,7 @@ class RandomSharpness(IntensityAugmentationBase2D):p: float = 0.5,keepdim: bool = False,) -> None:- super(RandomSharpness, self).__init__(- p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim- )+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim)self._device, self._dtype = _extract_device_dtype([sharpness])self.sharpness = sharpness@@ -1787,9 +1767,7 @@ class RandomEqualize(IntensityAugmentationBase2D):def __init__(self, same_on_batch: bool = False, return_transform: bool = False, p: float = 0.5, keepdim: bool = False) -> None:- super(RandomEqualize, self).__init__(- p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim- )+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim)def __repr__(self) -> str:return self.__class__.__name__ + f"({super().__repr__()})"@@ -1843,9 +1821,7 @@ class RandomGaussianBlur(IntensityAugmentationBase2D):same_on_batch: bool = False,p: float = 0.5,) -> None:- super(RandomGaussianBlur, self).__init__(- p=p, return_transform=return_transform, same_on_batch=same_on_batch, p_batch=1.0- )+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, p_batch=1.0)self.kernel_size = kernel_sizeself.sigma = sigmaself.border_type: BorderType = BorderType.get(border_type)@@ -1869,7 +1845,7 @@ class GaussianBlur(RandomGaussianBlur):same_on_batch: bool = False,p: float = 0.5,) -> None:- super(GaussianBlur, self).__init__(+ super().__init__(kernel_size=kernel_size,sigma=sigma,border_type=border_type,@@ -1919,9 +1895,7 @@ class RandomInvert(IntensityAugmentationBase2D):same_on_batch: bool = False,p: float = 0.5,) -> None:- super(RandomInvert, self).__init__(- p=p, return_transform=return_transform, same_on_batch=same_on_batch, p_batch=1.0- )+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, p_batch=1.0)self.max_val = max_valdef __repr__(self) -> str:@@ -1956,9 +1930,7 @@ class RandomChannelShuffle(IntensityAugmentationBase2D):"""def __init__(self, return_transform: bool = False, same_on_batch: bool = False, p: float = 0.5) -> None:- super(RandomChannelShuffle, self).__init__(- p=p, return_transform=return_transform, same_on_batch=same_on_batch, p_batch=1.0- )+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, p_batch=1.0)def __repr__(self) -> str:return self.__class__.__name__ + f"({super().__repr__()})"@@ -2006,9 +1978,7 @@ class RandomGaussianNoise(IntensityAugmentationBase2D):same_on_batch: bool = False,p: float = 0.5,) -> None:- super(RandomGaussianNoise, self).__init__(- p=p, return_transform=return_transform, same_on_batch=same_on_batch, p_batch=1.0- )+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, p_batch=1.0)self.mean = meanself.std = std@@ -2058,9 +2028,7 @@ class RandomFisheye(GeometricAugmentationBase2D):same_on_batch: bool = False,p: float = 0.5,) -> None:- super(RandomFisheye, self).__init__(- p=p, return_transform=return_transform, same_on_batch=same_on_batch, p_batch=1.0- )+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, p_batch=1.0)self.center_x = self._check_tensor(center_x)self.center_y = self._check_tensor(center_y)self.gamma = self._check_tensor(gamma)@@ -2146,9 +2114,7 @@ class RandomElasticTransform(GeometricAugmentationBase2D):same_on_batch: bool = False,p: float = 0.5,) -> None:- super(RandomElasticTransform, self).__init__(- p=p, return_transform=return_transform, same_on_batch=same_on_batch, p_batch=1.0- )+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, p_batch=1.0)self.kernel_size = kernel_sizeself.sigma = sigmaself.alpha = alpha@@ -2209,9 +2175,7 @@ class RandomThinPlateSpline(GeometricAugmentationBase2D):same_on_batch: bool = False,p: float = 0.5,) -> None:- super(RandomThinPlateSpline, self).__init__(- p=p, return_transform=return_transform, same_on_batch=same_on_batch, p_batch=1.0- )+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, p_batch=1.0)self.align_corners = align_cornersself.dist = torch.distributions.Uniform(-scale, scale)@@ -2268,9 +2232,7 @@ class RandomBoxBlur(GeometricAugmentationBase2D):same_on_batch: bool = False,p: float = 0.5,) -> None:- super(RandomBoxBlur, self).__init__(- p=p, return_transform=return_transform, same_on_batch=same_on_batch, p_batch=1.0- )+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, p_batch=1.0)self.kernel_size = kernel_sizeself.border_type = border_typeself.normalized = normalizeddiff --git a/kornia/augmentation/augmentation3d.py b/kornia/augmentation/augmentation3d.pyindex 20c6c0b25..a6117c9a4 100644--- a/kornia/augmentation/augmentation3d.py+++ b/kornia/augmentation/augmentation3d.py@@ -67,9 +67,7 @@ class RandomHorizontalFlip3D(AugmentationBase3D):def __init__(self, return_transform: bool = False, same_on_batch: bool = False, p: float = 0.5, keepdim: bool = False) -> None:- super(RandomHorizontalFlip3D, self).__init__(- p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim- )+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim)def __repr__(self) -> str:return self.__class__.__name__ + f"({super().__repr__()})"@@ -140,9 +138,7 @@ class RandomVerticalFlip3D(AugmentationBase3D):def __init__(self, return_transform: bool = False, same_on_batch: bool = False, p: float = 0.5, keepdim: bool = False) -> None:- super(RandomVerticalFlip3D, self).__init__(- p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim- )+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim)def __repr__(self) -> str:return self.__class__.__name__ + f"({super().__repr__()})"@@ -214,9 +210,7 @@ class RandomDepthicalFlip3D(AugmentationBase3D):def __init__(self, return_transform: bool = False, same_on_batch: bool = False, p: float = 0.5, keepdim: bool = False) -> None:- super(RandomDepthicalFlip3D, self).__init__(- p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim- )+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim)def __repr__(self) -> str:return self.__class__.__name__ + f"({super().__repr__()})"@@ -339,9 +333,7 @@ class RandomAffine3D(AugmentationBase3D):p: float = 0.5,keepdim: bool = False,) -> None:- super(RandomAffine3D, self).__init__(- p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim- )+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim)self._device, self._dtype = _extract_device_dtype([degrees, shears, translate, scale])self.degrees = degreesself.shears = shears@@ -497,9 +489,7 @@ class RandomRotation3D(AugmentationBase3D):p: float = 0.5,keepdim: bool = False,) -> None:- super(RandomRotation3D, self).__init__(- p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim- )+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim)self._device, self._dtype = _extract_device_dtype([degrees])self.degrees = degreesself.resample = Resample.get(resample)@@ -616,7 +606,7 @@ class RandomMotionBlur3D(AugmentationBase3D):p: float = 0.5,keepdim: bool = False,) -> None:- super(RandomMotionBlur3D, self).__init__(+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, p_batch=1.0, keepdim=keepdim)self._device, self._dtype = _extract_device_dtype([angle, direction])@@ -717,9 +707,7 @@ class CenterCrop3D(AugmentationBase3D):) -> None:# same_on_batch is always True for CenterCrop# Since PyTorch does not support ragged tensor. So cropping function happens batch-wisely.- super(CenterCrop3D, self).__init__(- p=1.0, return_transform=return_transform, same_on_batch=True, p_batch=p, keepdim=keepdim- )+ super().__init__(p=1.0, return_transform=return_transform, same_on_batch=True, p_batch=p, keepdim=keepdim)if isinstance(size, tuple):self.size = (size[0], size[1], size[2])elif isinstance(size, int):@@ -820,7 +808,7 @@ class RandomCrop3D(AugmentationBase3D):keepdim: bool = False,) -> None:# Since PyTorch does not support ragged tensor. So cropping function happens batch-wisely.- super(RandomCrop3D, self).__init__(+ super().__init__(p=1.0, return_transform=return_transform, same_on_batch=same_on_batch, p_batch=p, keepdim=keepdim)self.size = size@@ -977,9 +965,7 @@ class RandomPerspective3D(AugmentationBase3D):p: float = 0.5,keepdim: bool = False,) -> None:- super(RandomPerspective3D, self).__init__(- p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim- )+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim)self._device, self._dtype = _extract_device_dtype([distortion_scale])self.distortion_scale = distortion_scaleself.resample = Resample.get(resample)@@ -1065,9 +1051,7 @@ class RandomEqualize3D(AugmentationBase3D):def __init__(self, p: float = 0.5, return_transform: bool = False, same_on_batch: bool = False, keepdim: bool = False) -> None:- super(RandomEqualize3D, self).__init__(- p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim- )+ super().__init__(p=p, return_transform=return_transform, same_on_batch=same_on_batch, keepdim=keepdim)def __repr__(self) -> str:return self.__class__.__name__ + f"({super().__repr__()})"diff --git a/kornia/augmentation/base.py b/kornia/augmentation/base.pyindex ff43cf6af..76d04d0e7 100644--- a/kornia/augmentation/base.py+++ b/kornia/augmentation/base.py@@ -38,7 +38,7 @@ class _BasicAugmentationBase(nn.Module):def __init__(self, p: float = 0.5, p_batch: float = 1.0, same_on_batch: bool = False, keepdim: bool = False) -> None:- super(_BasicAugmentationBase, self).__init__()+ super().__init__()self.p = pself.p_batch = p_batchself.same_on_batch = same_on_batch@@ -157,7 +157,7 @@ class _AugmentationBase(_BasicAugmentationBase):p_batch: float = 1.0,keepdim: bool = False,) -> None:- super(_AugmentationBase, self).__init__(p, p_batch=p_batch, same_on_batch=same_on_batch, keepdim=keepdim)+ super().__init__(p, p_batch=p_batch, same_on_batch=same_on_batch, keepdim=keepdim)self.p = pself.p_batch = p_batchself.return_transform = return_transform@@ -459,7 +459,7 @@ class MixAugmentationBase(_BasicAugmentationBase):"""def __init__(self, p: float, p_batch: float, same_on_batch: bool = False, keepdim: bool = False) -> None:- super(MixAugmentationBase, self).__init__(p, p_batch=p_batch, same_on_batch=same_on_batch, keepdim=keepdim)+ super().__init__(p, p_batch=p_batch, same_on_batch=same_on_batch, keepdim=keepdim)def __check_batching__(self, input: TensorWithTransformMat):if isinstance(input, tuple):diff --git a/kornia/augmentation/container/augment.py b/kornia/augmentation/container/augment.pyindex 925d2e79f..e4c638ccf 100644--- a/kornia/augmentation/container/augment.py+++ b/kornia/augmentation/container/augment.py@@ -91,7 +91,7 @@ class AugmentationSequential(ImageSequential):keepdim: Optional[bool] = None,random_apply: Union[int, bool, Tuple[int, int]] = False,) -> None:- super(AugmentationSequential, self).__init__(+ super().__init__(*args,same_on_batch=same_on_batch,return_transform=return_transform,diff --git a/kornia/augmentation/container/image.py b/kornia/augmentation/container/image.pyindex 1e1958f05..99841d800 100644--- a/kornia/augmentation/container/image.py+++ b/kornia/augmentation/container/image.py@@ -70,9 +70,7 @@ class ImageSequential(SequentialBase):keepdim: Optional[bool] = None,random_apply: Union[int, bool, Tuple[int, int]] = False,) -> None:- super(ImageSequential, self).__init__(- *args, same_on_batch=same_on_batch, return_transform=return_transform, keepdim=keepdim- )+ super().__init__(*args, same_on_batch=same_on_batch, return_transform=return_transform, keepdim=keepdim)self.random_apply: Union[Tuple[int, int], bool] = self._read_random_apply(random_apply, len(args))self.return_label: Optional[bool] = Nonediff --git a/kornia/augmentation/container/patch.py b/kornia/augmentation/container/patch.pyindex 473e0bdf4..9b57f1084 100644--- a/kornia/augmentation/container/patch.py+++ b/kornia/augmentation/container/patch.py@@ -119,7 +119,7 @@ class PatchSequential(ImageSequential):raise ValueError(f"Only boolean value allowed when `patchwise_apply` is set to True. Got {random_apply}.")else:_random_apply = random_apply- super(PatchSequential, self).__init__(+ super().__init__(*args, same_on_batch=same_on_batch, return_transform=False, keepdim=keepdim, random_apply=_random_apply)assert padding in ["same", "valid"], f"`padding` must be either `same` or `valid`. Got {padding}."diff --git a/kornia/augmentation/container/video.py b/kornia/augmentation/container/video.pyindex bd7250ea5..70af907f8 100644--- a/kornia/augmentation/container/video.py+++ b/kornia/augmentation/container/video.py@@ -82,9 +82,7 @@ class VideoSequential(ImageSequential):same_on_frame: bool = True,random_apply: Union[int, bool, Tuple[int, int]] = False,) -> None:- super(VideoSequential, self).__init__(- *args, same_on_batch=None, return_transform=None, keepdim=None, random_apply=random_apply- )+ super().__init__(*args, same_on_batch=None, return_transform=None, keepdim=None, random_apply=random_apply)self.same_on_frame = same_on_frameself.data_format = data_format.upper()if self.data_format not in ["BCTHW", "BTCHW"]:diff --git a/kornia/augmentation/mix_augmentation.py b/kornia/augmentation/mix_augmentation.pyindex 42200f704..05b9dc136 100644--- a/kornia/augmentation/mix_augmentation.py+++ b/kornia/augmentation/mix_augmentation.py@@ -85,7 +85,7 @@ class RandomMixUp(MixAugmentationBase):p: float = 1.0,keepdim: bool = False,) -> None:- super(RandomMixUp, self).__init__(p=1.0, p_batch=p, same_on_batch=same_on_batch, keepdim=keepdim)+ super().__init__(p=1.0, p_batch=p, same_on_batch=same_on_batch, keepdim=keepdim)self.lambda_val = lambda_valdef __repr__(self) -> str:@@ -212,7 +212,7 @@ class RandomCutMix(MixAugmentationBase):p: float = 1.0,keepdim: bool = False,) -> None:- super(RandomCutMix, self).__init__(p=1.0, p_batch=p, same_on_batch=same_on_batch, keepdim=keepdim)+ super().__init__(p=1.0, p_batch=p, same_on_batch=same_on_batch, keepdim=keepdim)self.height = heightself.width = widthself.num_mix = num_mixdiff --git a/kornia/augmentation/random_generator/random_generator.py b/kornia/augmentation/random_generator/random_generator.pyindex f81600a3d..96cf5d8a7 100644--- a/kornia/augmentation/random_generator/random_generator.py+++ b/kornia/augmentation/random_generator/random_generator.py@@ -677,7 +677,7 @@ def center_crop_generator("""_common_param_check(batch_size)if not isinstance(size, (tuple, list)) and len(size) == 2:- raise ValueError("Input size must be a tuple/list of length 2. Got {}".format(size))+ raise ValueError(f"Input size must be a tuple/list of length 2. Got {size}")if not (type(height) is int and height > 0 and type(width) is int and width > 0):raise AssertionError(f"'height' and 'width' must be integers. Got {height}, {width}.")if not (height >= size[0] and width >= size[1]):diff --git a/kornia/augmentation/random_generator/random_generator3d.py b/kornia/augmentation/random_generator/random_generator3d.pyindex d878a93ce..8aa9a7828 100644--- a/kornia/augmentation/random_generator/random_generator3d.py+++ b/kornia/augmentation/random_generator/random_generator3d.py@@ -264,7 +264,7 @@ def center_crop_generator3d(No random number will be generated."""if not isinstance(size, (tuple, list)) and len(size) == 3:- raise ValueError("Input size must be a tuple/list of length 3. Got {}".format(size))+ raise ValueError(f"Input size must be a tuple/list of length 3. Got {size}")if not (type(depth) is int and depth > 0 and type(height) is int and height > 0 and type(width) is int and width > 0):@@ -390,9 +390,7 @@ def random_crop_generator3d(z_diff = input_size[0] - size[:, 0] + 1if (x_diff < 0).any() or (y_diff < 0).any() or (z_diff < 0).any():- raise ValueError(- "input_size %s cannot be smaller than crop size %s in any dimension." % (str(input_size), str(size))- )+ raise ValueError(f"input_size {str(input_size)} cannot be smaller than crop size {str(size)} in any dimension.")if batch_size == 0:return dict(diff --git a/kornia/color/gray.py b/kornia/color/gray.pyindex 301f5a97b..bc8b8bb04 100644--- a/kornia/color/gray.py+++ b/kornia/color/gray.py@@ -29,7 +29,7 @@ def grayscale_to_rgb(image: torch.Tensor) -> torch.Tensor:rgb: torch.Tensor = torch.cat([image, image, image], dim=-3)image_is_float: bool = torch.is_floating_point(image)if not image_is_float:- warnings.warn("Input image is not of float dtype. Got {}".format(image.dtype))+ warnings.warn(f"Input image is not of float dtype. Got {image.dtype}")return rgb@@ -58,26 +58,26 @@ def rgb_to_grayscale(>>> gray = rgb_to_grayscale(input) # 2x1x4x5"""if not isinstance(image, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(image)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(image)}")if len(image.shape) < 3 or image.shape[-3] != 3:- raise ValueError("Input size must have a shape of (*, 3, H, W). Got {}".format(image.shape))+ raise ValueError(f"Input size must have a shape of (*, 3, H, W). Got {image.shape}")if not isinstance(rgb_weights, torch.Tensor):- raise TypeError("rgb_weights is not a torch.Tensor. Got {}".format(type(rgb_weights)))+ raise TypeError(f"rgb_weights is not a torch.Tensor. Got {type(rgb_weights)}")if rgb_weights.shape[-1] != 3:- raise ValueError("rgb_weights must have a shape of (*, 3). Got {}".format(rgb_weights.shape))+ raise ValueError(f"rgb_weights must have a shape of (*, 3). Got {rgb_weights.shape}")r: torch.Tensor = image[..., 0:1, :, :]g: torch.Tensor = image[..., 1:2, :, :]b: torch.Tensor = image[..., 2:3, :, :]image_is_float: bool = torch.is_floating_point(image)if not image_is_float:- warnings.warn("Input image is not of float dtype. Got {}".format(image.dtype))+ warnings.warn(f"Input image is not of float dtype. Got {image.dtype}")if (image.dtype != rgb_weights.dtype) and not image_is_float:raise TypeError(- "Input image and rgb_weights should be of same dtype. Got {} and {}".format(image.dtype, rgb_weights.dtype)+ f"Input image and rgb_weights should be of same dtype. Got {image.dtype} and {rgb_weights.dtype}")w_tmp: torch.Tensor = rgb_weights.to(image.device, image.dtype)gray: torch.Tensor = w_tmp[..., 0] * r + w_tmp[..., 1] * g + w_tmp[..., 2] * b@@ -100,10 +100,10 @@ def bgr_to_grayscale(image: torch.Tensor) -> torch.Tensor:>>> gray = bgr_to_grayscale(input) # 2x1x4x5"""if not isinstance(image, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(image)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(image)}")if len(image.shape) < 3 or image.shape[-3] != 3:- raise ValueError("Input size must have a shape of (*, 3, H, W). Got {}".format(image.shape))+ raise ValueError(f"Input size must have a shape of (*, 3, H, W). Got {image.shape}")image_rgb = bgr_to_rgb(image)gray: torch.Tensor = rgb_to_grayscale(image_rgb)@@ -151,7 +151,7 @@ class RgbToGrayscale(nn.Module):"""def __init__(self, rgb_weights: torch.Tensor = torch.tensor([0.299, 0.587, 0.114])) -> None:- super(RgbToGrayscale, self).__init__()+ super().__init__()self.rgb_weights = rgb_weightsdef forward(self, image: torch.Tensor) -> torch.Tensor: # type: ignorediff --git a/kornia/color/hsv.py b/kornia/color/hsv.pyindex 43344246e..80d7bc164 100644--- a/kornia/color/hsv.py+++ b/kornia/color/hsv.py@@ -28,10 +28,10 @@ def rgb_to_hsv(image: torch.Tensor, eps: float = 1e-6) -> torch.Tensor:>>> output = rgb_to_hsv(input) # 2x3x4x5"""if not isinstance(image, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(image)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(image)}")if len(image.shape) < 3 or image.shape[-3] != 3:- raise ValueError("Input size must have a shape of (*, 3, H, W). Got {}".format(image.shape))+ raise ValueError(f"Input size must have a shape of (*, 3, H, W). Got {image.shape}")# The first or last occurance is not guarenteed before 1.6.0# https://github.com/pytorch/pytorch/issues/20414@@ -82,10 +82,10 @@ def hsv_to_rgb(image: torch.Tensor) -> torch.Tensor:>>> output = hsv_to_rgb(input) # 2x3x4x5"""if not isinstance(image, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(image)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(image)}")if len(image.shape) < 3 or image.shape[-3] != 3:- raise ValueError("Input size must have a shape of (*, 3, H, W). Got {}".format(image.shape))+ raise ValueError(f"Input size must have a shape of (*, 3, H, W). Got {image.shape}")h: torch.Tensor = image[..., 0, :, :] / (2 * math.pi)s: torch.Tensor = image[..., 1, :, :]@@ -128,7 +128,7 @@ class RgbToHsv(nn.Module):"""def __init__(self, eps: float = 1e-6) -> None:- super(RgbToHsv, self).__init__()+ super().__init__()self.eps = epsdef forward(self, image: torch.Tensor) -> torch.Tensor:diff --git a/kornia/color/lab.py b/kornia/color/lab.pyindex 3ddd5a08e..e77e7b144 100644--- a/kornia/color/lab.py+++ b/kornia/color/lab.py@@ -31,10 +31,10 @@ def rgb_to_lab(image: torch.Tensor) -> torch.Tensor:>>> output = rgb_to_lab(input) # 2x3x4x5"""if not isinstance(image, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(image)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(image)}")if len(image.shape) < 3 or image.shape[-3] != 3:- raise ValueError("Input size must have a shape of (*, 3, H, W). Got {}".format(image.shape))+ raise ValueError(f"Input size must have a shape of (*, 3, H, W). Got {image.shape}")# Convert from sRGB to Linear RGBlin_rgb = rgb_to_linear_rgb(image)@@ -78,10 +78,10 @@ def lab_to_rgb(image: torch.Tensor, clip: bool = True) -> torch.Tensor:>>> output = lab_to_rgb(input) # 2x3x4x5"""if not isinstance(image, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(image)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(image)}")if len(image.shape) < 3 or image.shape[-3] != 3:- raise ValueError("Input size must have a shape of (*, 3, H, W). Got {}".format(image.shape))+ raise ValueError(f"Input size must have a shape of (*, 3, H, W). Got {image.shape}")L: torch.Tensor = image[..., 0, :, :]a: torch.Tensor = image[..., 1, :, :]diff --git a/kornia/color/luv.py b/kornia/color/luv.pyindex 7131964d2..d48f076df 100644--- a/kornia/color/luv.py+++ b/kornia/color/luv.py@@ -34,10 +34,10 @@ def rgb_to_luv(image: torch.Tensor, eps: float = 1e-12) -> torch.Tensor:>>> output = rgb_to_luv(input) # 2x3x4x5"""if not isinstance(image, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(image)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(image)}")if len(image.shape) < 3 or image.shape[-3] != 3:- raise ValueError("Input size must have a shape of (*, 3, H, W). Got {}".format(image.shape))+ raise ValueError(f"Input size must have a shape of (*, 3, H, W). Got {image.shape}")# Convert from sRGB to Linear RGBlin_rgb = rgb_to_linear_rgb(image)@@ -82,10 +82,10 @@ def luv_to_rgb(image: torch.Tensor, eps: float = 1e-12) -> torch.Tensor:>>> output = luv_to_rgb(input) # 2x3x4x5"""if not isinstance(image, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(image)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(image)}")if len(image.shape) < 3 or image.shape[-3] != 3:- raise ValueError("Input size must have a shape of (*, 3, H, W). Got {}".format(image.shape))+ raise ValueError(f"Input size must have a shape of (*, 3, H, W). Got {image.shape}")L: torch.Tensor = image[..., 0, :, :]u: torch.Tensor = image[..., 1, :, :]diff --git a/kornia/color/rgb.py b/kornia/color/rgb.pyindex 2c0398ccf..b3b215b4d 100644--- a/kornia/color/rgb.py+++ b/kornia/color/rgb.py@@ -24,10 +24,10 @@ def rgb_to_bgr(image: torch.Tensor) -> torch.Tensor:>>> output = rgb_to_bgr(input) # 2x3x4x5"""if not isinstance(image, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(image)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(image)}")if len(image.shape) < 3 or image.shape[-3] != 3:- raise ValueError("Input size must have a shape of (*, 3, H, W).Got {}".format(image.shape))+ raise ValueError(f"Input size must have a shape of (*, 3, H, W).Got {image.shape}")return bgr_to_rgb(image)@@ -50,10 +50,10 @@ def bgr_to_rgb(image: torch.Tensor) -> torch.Tensor:>>> output = bgr_to_rgb(input) # 2x3x4x5"""if not isinstance(image, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(image)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(image)}")if len(image.shape) < 3 or image.shape[-3] != 3:- raise ValueError("Input size must have a shape of (*, 3, H, W).Got {}".format(image.shape))+ raise ValueError(f"Input size must have a shape of (*, 3, H, W).Got {image.shape}")# flip image channelsout: torch.Tensor = image.flip(-3)@@ -200,10 +200,10 @@ def rgb_to_linear_rgb(image: torch.Tensor) -> torch.Tensor:"""if not isinstance(image, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(image)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(image)}")if len(image.shape) < 3 or image.shape[-3] != 3:- raise ValueError("Input size must have a shape of (*, 3, H, W).Got {}".format(image.shape))+ raise ValueError(f"Input size must have a shape of (*, 3, H, W).Got {image.shape}")lin_rgb: torch.Tensor = torch.where(image > 0.04045, torch.pow(((image + 0.055) / 1.055), 2.4), image / 12.92)@@ -225,10 +225,10 @@ def linear_rgb_to_rgb(image: torch.Tensor) -> torch.Tensor:"""if not isinstance(image, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(image)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(image)}")if len(image.shape) < 3 or image.shape[-3] != 3:- raise ValueError("Input size must have a shape of (*, 3, H, W).Got {}".format(image.shape))+ raise ValueError(f"Input size must have a shape of (*, 3, H, W).Got {image.shape}")threshold = 0.0031308rgb: torch.Tensor = torch.where(@@ -307,7 +307,7 @@ class RgbToRgba(nn.Module):"""def __init__(self, alpha_val: Union[float, torch.Tensor]) -> None:- super(RgbToRgba, self).__init__()+ super().__init__()self.alpha_val = alpha_valdef forward(self, image: torch.Tensor) -> torch.Tensor:@@ -339,7 +339,7 @@ class BgrToRgba(nn.Module):"""def __init__(self, alpha_val: Union[float, torch.Tensor]) -> None:- super(BgrToRgba, self).__init__()+ super().__init__()self.alpha_val = alpha_valdef forward(self, image: torch.Tensor) -> torch.Tensor:diff --git a/kornia/color/xyz.py b/kornia/color/xyz.pyindex 386f6a1fc..4927f3817 100644--- a/kornia/color/xyz.py+++ b/kornia/color/xyz.py@@ -18,10 +18,10 @@ def rgb_to_xyz(image: torch.Tensor) -> torch.Tensor:>>> output = rgb_to_xyz(input) # 2x3x4x5"""if not isinstance(image, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(image)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(image)}")if len(image.shape) < 3 or image.shape[-3] != 3:- raise ValueError("Input size must have a shape of (*, 3, H, W). Got {}".format(image.shape))+ raise ValueError(f"Input size must have a shape of (*, 3, H, W). Got {image.shape}")r: torch.Tensor = image[..., 0, :, :]g: torch.Tensor = image[..., 1, :, :]@@ -50,10 +50,10 @@ def xyz_to_rgb(image: torch.Tensor) -> torch.Tensor:>>> output = xyz_to_rgb(input) # 2x3x4x5"""if not isinstance(image, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(image)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(image)}")if len(image.shape) < 3 or image.shape[-3] != 3:- raise ValueError("Input size must have a shape of (*, 3, H, W). Got {}".format(image.shape))+ raise ValueError(f"Input size must have a shape of (*, 3, H, W). Got {image.shape}")x: torch.Tensor = image[..., 0, :, :]y: torch.Tensor = image[..., 1, :, :]diff --git a/kornia/color/ycbcr.py b/kornia/color/ycbcr.pyindex 53462ae1d..19f8f0d1f 100644--- a/kornia/color/ycbcr.py+++ b/kornia/color/ycbcr.py@@ -18,10 +18,10 @@ def rgb_to_ycbcr(image: torch.Tensor) -> torch.Tensor:>>> output = rgb_to_ycbcr(input) # 2x3x4x5"""if not isinstance(image, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(image)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(image)}")if len(image.shape) < 3 or image.shape[-3] != 3:- raise ValueError("Input size must have a shape of (*, 3, H, W). Got {}".format(image.shape))+ raise ValueError(f"Input size must have a shape of (*, 3, H, W). Got {image.shape}")r: torch.Tensor = image[..., 0, :, :]g: torch.Tensor = image[..., 1, :, :]@@ -50,10 +50,10 @@ def ycbcr_to_rgb(image: torch.Tensor) -> torch.Tensor:>>> output = ycbcr_to_rgb(input) # 2x3x4x5"""if not isinstance(image, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(image)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(image)}")if len(image.shape) < 3 or image.shape[-3] != 3:- raise ValueError("Input size must have a shape of (*, 3, H, W). Got {}".format(image.shape))+ raise ValueError(f"Input size must have a shape of (*, 3, H, W). Got {image.shape}")y: torch.Tensor = image[..., 0, :, :]cb: torch.Tensor = image[..., 1, :, :]diff --git a/kornia/color/yuv.py b/kornia/color/yuv.pyindex 043445a3d..46e101160 100644--- a/kornia/color/yuv.py+++ b/kornia/color/yuv.py@@ -20,10 +20,10 @@ def rgb_to_yuv(image: torch.Tensor) -> torch.Tensor:>>> output = rgb_to_yuv(input) # 2x3x4x5"""if not isinstance(image, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(image)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(image)}")if len(image.shape) < 3 or image.shape[-3] != 3:- raise ValueError("Input size must have a shape of (*, 3, H, W). Got {}".format(image.shape))+ raise ValueError(f"Input size must have a shape of (*, 3, H, W). Got {image.shape}")r: torch.Tensor = image[..., 0, :, :]g: torch.Tensor = image[..., 1, :, :]@@ -54,10 +54,10 @@ def yuv_to_rgb(image: torch.Tensor) -> torch.Tensor:>>> output = yuv_to_rgb(input) # 2x3x4x5"""if not isinstance(image, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(image)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(image)}")if len(image.shape) < 3 or image.shape[-3] != 3:- raise ValueError("Input size must have a shape of (*, 3, H, W). Got {}".format(image.shape))+ raise ValueError(f"Input size must have a shape of (*, 3, H, W). Got {image.shape}")y: torch.Tensor = image[..., 0, :, :]u: torch.Tensor = image[..., 1, :, :]diff --git a/kornia/contrib/extract_patches.py b/kornia/contrib/extract_patches.pyindex 700d4cd6a..4cab25271 100644--- a/kornia/contrib/extract_patches.py+++ b/kornia/contrib/extract_patches.py@@ -66,7 +66,7 @@ class ExtractTensorPatches(nn.Module):stride: Optional[Union[int, Tuple[int, int]]] = 1,padding: Optional[Union[int, Tuple[int, int]]] = 0,) -> None:- super(ExtractTensorPatches, self).__init__()+ super().__init__()self.window_size: Tuple[int, int] = _pair(window_size)self.stride: Tuple[int, int] = _pair(stride)self.padding: Tuple[int, int] = _pair(padding)@@ -87,7 +87,7 @@ def _extract_tensor_patchesnd(dims = range(2, input.dim())for dim, patch_size, stride in zip(dims, window_sizes, strides):input = input.unfold(dim, patch_size, stride)- input = input.permute(0, *dims, 1, *[dim + len(dims) for dim in dims]).contiguous()+ input = input.permute(0, *dims, 1, *(dim + len(dims) for dim in dims)).contiguous()return input.view(batch_size, -1, num_channels, *window_sizes)@@ -102,9 +102,9 @@ def extract_tensor_patches(See :class:`~kornia.contrib.ExtractTensorPatches` for details."""if not torch.is_tensor(input):- raise TypeError("Input input type is not a torch.Tensor. Got {}".format(type(input)))+ raise TypeError(f"Input input type is not a torch.Tensor. Got {type(input)}")if not len(input.shape) == 4:- raise ValueError("Invalid input shape, we expect BxCxHxW. Got: {}".format(input.shape))+ raise ValueError(f"Invalid input shape, we expect BxCxHxW. Got: {input.shape}")if padding:pad_vert, pad_horz = _pair(padding)diff --git a/kornia/contrib/max_blur_pool.py b/kornia/contrib/max_blur_pool.pyindex 4ec5109ee..da94b7502 100644--- a/kornia/contrib/max_blur_pool.py+++ b/kornia/contrib/max_blur_pool.py@@ -12,7 +12,7 @@ class MaxBlurPool2d(MaxBlurPool2D):__doc__ = MaxBlurPool2D.__doc__def __init__(self, kernel_size: int, ceil_mode: bool = False) -> None:- super(MaxBlurPool2d, self).__init__(kernel_size, stride=2, max_pool_size=2, ceil_mode=ceil_mode)+ super().__init__(kernel_size, stride=2, max_pool_size=2, ceil_mode=ceil_mode)warnings.warn("`MaxBlurPool2d` is deprecated and will be removed after > 0.6. ""Please use `kornia.filters.MaxBlurPool2D instead.`",diff --git a/kornia/enhance/adjust.py b/kornia/enhance/adjust.pyindex f132f3e17..745847eb0 100644--- a/kornia/enhance/adjust.py+++ b/kornia/enhance/adjust.py@@ -820,7 +820,7 @@ class AdjustSaturation(nn.Module):"""def __init__(self, saturation_factor: Union[float, torch.Tensor]) -> None:- super(AdjustSaturation, self).__init__()+ super().__init__()self.saturation_factor: Union[float, torch.Tensor] = saturation_factordef forward(self, input: torch.Tensor) -> torch.Tensor:@@ -864,7 +864,7 @@ class AdjustHue(nn.Module):"""def __init__(self, hue_factor: Union[float, torch.Tensor]) -> None:- super(AdjustHue, self).__init__()+ super().__init__()self.hue_factor: Union[float, torch.Tensor] = hue_factordef forward(self, input: torch.Tensor) -> torch.Tensor:@@ -901,7 +901,7 @@ class AdjustGamma(nn.Module):"""def __init__(self, gamma: Union[float, torch.Tensor], gain: Union[float, torch.Tensor] = 1.0) -> None:- super(AdjustGamma, self).__init__()+ super().__init__()self.gamma: Union[float, torch.Tensor] = gammaself.gain: Union[float, torch.Tensor] = gain@@ -939,7 +939,7 @@ class AdjustContrast(nn.Module):"""def __init__(self, contrast_factor: Union[float, torch.Tensor]) -> None:- super(AdjustContrast, self).__init__()+ super().__init__()self.contrast_factor: Union[float, torch.Tensor] = contrast_factordef forward(self, input: torch.Tensor) -> torch.Tensor:@@ -975,7 +975,7 @@ class AdjustBrightness(nn.Module):"""def __init__(self, brightness_factor: Union[float, torch.Tensor]) -> None:- super(AdjustBrightness, self).__init__()+ super().__init__()self.brightness_factor: Union[float, torch.Tensor] = brightness_factordef forward(self, input: torch.Tensor) -> torch.Tensor:@@ -1005,7 +1005,7 @@ class Invert(nn.Module):"""def __init__(self, max_val: torch.Tensor = torch.tensor(1.0)) -> None:- super(Invert, self).__init__()+ super().__init__()if not isinstance(max_val, nn.Parameter):self.register_buffer("max_val", max_val)else:diff --git a/kornia/enhance/core.py b/kornia/enhance/core.pyindex df2ea5158..24bf2f963 100644--- a/kornia/enhance/core.py+++ b/kornia/enhance/core.py@@ -33,19 +33,19 @@ def add_weighted(src1: torch.Tensor, alpha: float, src2: torch.Tensor, beta: flo"""if not isinstance(src1, torch.Tensor):- raise TypeError("src1 should be a tensor. Got {}".format(type(src1)))+ raise TypeError(f"src1 should be a tensor. Got {type(src1)}")if not isinstance(src2, torch.Tensor):- raise TypeError("src2 should be a tensor. Got {}".format(type(src2)))+ raise TypeError(f"src2 should be a tensor. Got {type(src2)}")if not isinstance(alpha, float):- raise TypeError("alpha should be a float. Got {}".format(type(alpha)))+ raise TypeError(f"alpha should be a float. Got {type(alpha)}")if not isinstance(beta, float):- raise TypeError("beta should be a float. Got {}".format(type(beta)))+ raise TypeError(f"beta should be a float. Got {type(beta)}")if not isinstance(gamma, float):- raise TypeError("gamma should be a float. Got {}".format(type(gamma)))+ raise TypeError(f"gamma should be a float. Got {type(gamma)}")return src1 * alpha + src2 * beta + gamma@@ -78,7 +78,7 @@ class AddWeighted(nn.Module):"""def __init__(self, alpha: float, beta: float, gamma: float) -> None:- super(AddWeighted, self).__init__()+ super().__init__()self.alpha = alphaself.beta = betaself.gamma = gammadiff --git a/kornia/enhance/histogram.py b/kornia/enhance/histogram.pyindex b426ae438..1b2a10f64 100644--- a/kornia/enhance/histogram.py+++ b/kornia/enhance/histogram.py@@ -26,13 +26,13 @@ def marginal_pdf("""if not isinstance(values, torch.Tensor):- raise TypeError("Input values type is not a torch.Tensor. Got {}".format(type(values)))+ raise TypeError(f"Input values type is not a torch.Tensor. Got {type(values)}")if not isinstance(bins, torch.Tensor):- raise TypeError("Input bins type is not a torch.Tensor. Got {}".format(type(bins)))+ raise TypeError(f"Input bins type is not a torch.Tensor. Got {type(bins)}")if not isinstance(sigma, torch.Tensor):- raise TypeError("Input sigma type is not a torch.Tensor. Got {}".format(type(sigma)))+ raise TypeError(f"Input sigma type is not a torch.Tensor. Got {type(sigma)}")if not values.dim() == 3:raise ValueError("Input values must be a of the shape BxNx1." " Got {}".format(values.shape))@@ -68,10 +68,10 @@ def joint_pdf(kernel_values1: torch.Tensor, kernel_values2: torch.Tensor, epsilo"""if not isinstance(kernel_values1, torch.Tensor):- raise TypeError("Input kernel_values1 type is not a torch.Tensor. Got {}".format(type(kernel_values1)))+ raise TypeError(f"Input kernel_values1 type is not a torch.Tensor. Got {type(kernel_values1)}")if not isinstance(kernel_values2, torch.Tensor):- raise TypeError("Input kernel_values2 type is not a torch.Tensor. Got {}".format(type(kernel_values2)))+ raise TypeError(f"Input kernel_values2 type is not a torch.Tensor. Got {type(kernel_values2)}")if not kernel_values1.dim() == 3:raise ValueError("Input kernel_values1 must be a of the shape BxN." " Got {}".format(kernel_values1.shape))diff --git a/kornia/enhance/normalize.py b/kornia/enhance/normalize.pyindex 2d7dd7448..7711d89f5 100644--- a/kornia/enhance/normalize.py+++ b/kornia/enhance/normalize.py@@ -43,7 +43,7 @@ class Normalize(nn.Module):mean: Union[torch.Tensor, Tuple[float], List[float], float],std: Union[torch.Tensor, Tuple[float], List[float], float],) -> None:- super(Normalize, self).__init__()+ super().__init__()if isinstance(mean, float):mean = torch.tensor([mean])@@ -64,7 +64,7 @@ class Normalize(nn.Module):return normalize(input, self.mean, self.std)def __repr__(self):- repr = "(mean={0}, std={1})".format(self.mean, self.std)+ repr = f"(mean={self.mean}, std={self.std})"return self.__class__.__name__ + repr@@ -158,7 +158,7 @@ class Denormalize(nn.Module):def __init__(self, mean: Union[torch.Tensor, float], std: Union[torch.Tensor, float]) -> None:- super(Denormalize, self).__init__()+ super().__init__()self.mean = meanself.std = std@@ -167,7 +167,7 @@ class Denormalize(nn.Module):return denormalize(input, self.mean, self.std)def __repr__(self):- repr = "(mean={0}, std={1})".format(self.mean, self.std)+ repr = f"(mean={self.mean}, std={self.std})"return self.__class__.__name__ + repr@@ -209,13 +209,13 @@ def denormalize(data: torch.Tensor, mean: Union[torch.Tensor, float], std: Unionstd = torch.tensor([std] * shape[1], device=data.device, dtype=data.dtype)if not isinstance(data, torch.Tensor):- raise TypeError("data should be a tensor. Got {}".format(type(data)))+ raise TypeError(f"data should be a tensor. Got {type(data)}")if not isinstance(mean, torch.Tensor):- raise TypeError("mean should be a tensor or a float. Got {}".format(type(mean)))+ raise TypeError(f"mean should be a tensor or a float. Got {type(mean)}")if not isinstance(std, torch.Tensor):- raise TypeError("std should be a tensor or float. Got {}".format(type(std)))+ raise TypeError(f"std should be a tensor or float. Got {type(std)}")# Allow broadcast on channel dimensionif mean.shape and mean.shape[0] != 1:diff --git a/kornia/enhance/zca.py b/kornia/enhance/zca.pyindex e0ad580b3..35254c32a 100644--- a/kornia/enhance/zca.py+++ b/kornia/enhance/zca.py@@ -72,7 +72,7 @@ class ZCAWhitening(nn.Module):compute_inv: bool = False,) -> None:- super(ZCAWhitening, self).__init__()+ super().__init__()self.dim = dimself.eps = eps@@ -195,7 +195,7 @@ def zca_mean("""if not isinstance(inp, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(inp)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(inp)}")if not isinstance(eps, float):raise TypeError(f"eps type is not a float. Got{type(eps)}")@@ -204,10 +204,10 @@ def zca_mean(raise TypeError(f"unbiased type is not bool. Got{type(unbiased)}")if not isinstance(dim, int):- raise TypeError("Argument 'dim' must be of type int. Got {}".format(type(dim)))+ raise TypeError(f"Argument 'dim' must be of type int. Got {type(dim)}")if not isinstance(return_inverse, bool):- raise TypeError("Argument return_inverse must be of type bool {}".format(type(return_inverse)))+ raise TypeError(f"Argument return_inverse must be of type bool {type(return_inverse)}")inp_size = inp.size()@@ -284,7 +284,7 @@ def zca_whiten(inp: torch.Tensor, dim: int = 0, unbiased: bool = True, eps: floa"""if not isinstance(inp, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(inp)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(inp)}")if not isinstance(eps, float):raise TypeError(f"eps type is not a float. Got{type(eps)}")@@ -293,7 +293,7 @@ def zca_whiten(inp: torch.Tensor, dim: int = 0, unbiased: bool = True, eps: floaraise TypeError(f"unbiased type is not bool. Got{type(unbiased)}")if not isinstance(dim, int):- raise TypeError("Argument 'dim' must be of type int. Got {}".format(type(dim)))+ raise TypeError(f"Argument 'dim' must be of type int. Got {type(dim)}")transform, mean, _ = zca_mean(inp, dim, unbiased, eps, False)diff --git a/kornia/feature/affine_shape.py b/kornia/feature/affine_shape.pyindex 98dc10368..f2f6c2624 100644--- a/kornia/feature/affine_shape.py+++ b/kornia/feature/affine_shape.py@@ -29,7 +29,7 @@ class PatchAffineShapeEstimator(nn.Module):"""def __init__(self, patch_size: int = 19, eps: float = 1e-10):- super(PatchAffineShapeEstimator, self).__init__()+ super().__init__()self.patch_size: int = patch_sizeself.gradient: nn.Module = SpatialGradient('sobel', 1)self.eps: float = eps@@ -45,9 +45,9 @@ class PatchAffineShapeEstimator(nn.Module):Returns:torch.Tensor: ellipse_shape shape [Bx1x3]"""if not isinstance(patch, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(patch)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(patch)}")if not len(patch.shape) == 4:- raise ValueError("Invalid input shape, we expect Bx1xHxW. Got: {}".format(patch.shape))+ raise ValueError(f"Invalid input shape, we expect Bx1xHxW. Got: {patch.shape}")B, CH, W, H = patch.size()if (W != self.patch_size) or (H != self.patch_size) or (CH != 1):raise TypeError(@@ -93,7 +93,7 @@ class LAFAffineShapeEstimator(nn.Module):""" # noqa pylint: disabledef __init__(self, patch_size: int = 32, affine_shape_detector: Optional[nn.Module] = None) -> None:- super(LAFAffineShapeEstimator, self).__init__()+ super().__init__()self.patch_size = patch_sizeself.affine_shape_detector = PatchAffineShapeEstimator(self.patch_size)return@@ -118,15 +118,13 @@ class LAFAffineShapeEstimator(nn.Module):Returns:torch.Tensor: laf_out shape [BxNx2x3]"""raise_error_if_laf_is_not_valid(laf)- img_message: str = "Invalid img shape, we expect BxCxHxW. Got: {}".format(img.shape)+ img_message: str = f"Invalid img shape, we expect BxCxHxW. Got: {img.shape}"if not isinstance(img, torch.Tensor):- raise TypeError("img type is not a torch.Tensor. Got {}".format(type(img)))+ raise TypeError(f"img type is not a torch.Tensor. Got {type(img)}")if len(img.shape) != 4:raise ValueError(img_message)if laf.size(0) != img.size(0):- raise ValueError(- "Batch size of laf and img should be the same. Got {}, {}".format(img.size(0), laf.size(0))- )+ raise ValueError(f"Batch size of laf and img should be the same. Got {img.size(0)}, {laf.size(0)}")B, N = laf.shape[:2]PS: int = self.patch_sizepatches: torch.Tensor = extract_patches_from_pyramid(img, make_upright(laf), PS, True).view(-1, 1, PS, PS)@@ -154,7 +152,7 @@ class LAFAffNetShapeEstimator(nn.Module):"""def __init__(self, pretrained: bool = False):- super(LAFAffNetShapeEstimator, self).__init__()+ super().__init__()self.features = nn.Sequential(nn.Conv2d(1, 16, kernel_size=3, padding=1, bias=False),nn.BatchNorm2d(16, affine=False),@@ -206,15 +204,13 @@ class LAFAffNetShapeEstimator(nn.Module):laf_out shape [BxNx2x3]"""raise_error_if_laf_is_not_valid(laf)- img_message: str = "Invalid img shape, we expect BxCxHxW. Got: {}".format(img.shape)+ img_message: str = f"Invalid img shape, we expect BxCxHxW. Got: {img.shape}"if not torch.is_tensor(img):- raise TypeError("img type is not a torch.Tensor. Got {}".format(type(img)))+ raise TypeError(f"img type is not a torch.Tensor. Got {type(img)}")if len(img.shape) != 4:raise ValueError(img_message)if laf.size(0) != img.size(0):- raise ValueError(- "Batch size of laf and img should be the same. Got {}, {}".format(img.size(0), laf.size(0))- )+ raise ValueError(f"Batch size of laf and img should be the same. Got {img.size(0)}, {laf.size(0)}")B, N = laf.shape[:2]PS: int = self.patch_sizepatches: torch.Tensor = extract_patches_from_pyramid(img, make_upright(laf), PS, True).view(-1, 1, PS, PS)diff --git a/kornia/feature/hardnet.py b/kornia/feature/hardnet.pyindex 84b43fd68..600083e8e 100644--- a/kornia/feature/hardnet.py+++ b/kornia/feature/hardnet.py@@ -35,7 +35,7 @@ class HardNet(nn.Module):"""def __init__(self, pretrained: bool = False) -> None:- super(HardNet, self).__init__()+ super().__init__()self.features = nn.Sequential(nn.Conv2d(1, 32, kernel_size=3, padding=1, bias=False),nn.BatchNorm2d(32, affine=False),@@ -106,7 +106,7 @@ class HardNet8(nn.Module):"""def __init__(self, pretrained: bool = False):- super(HardNet8, self).__init__()+ super().__init__()self.features = nn.Sequential(nn.Conv2d(1, 32, kernel_size=3, padding=1, bias=False),nn.BatchNorm2d(32, affine=False),diff --git a/kornia/feature/laf.py b/kornia/feature/laf.pyindex 7c5fa988d..0c7ee0160 100644--- a/kornia/feature/laf.py+++ b/kornia/feature/laf.py@@ -14,9 +14,9 @@ def raise_error_if_laf_is_not_valid(laf: torch.Tensor) -> None:Args:laf: [BxNx2x3] shape."""- laf_message: str = "Invalid laf shape, we expect BxNx2x3. Got: {}".format(laf.shape)+ laf_message: str = f"Invalid laf shape, we expect BxNx2x3. Got: {laf.shape}"if not isinstance(laf, torch.Tensor):- raise TypeError("Laf type is not a torch.Tensor. Got {}".format(type(laf)))+ raise TypeError(f"Laf type is not a torch.Tensor. Got {type(laf)}")if len(laf.shape) != 4:raise ValueError(laf_message)if laf.size(2) != 2 or laf.size(3) != 3:@@ -129,7 +129,7 @@ def laf_from_center_scale_ori(xy: torch.Tensor, scale: torch.Tensor, ori: torch.names = ['xy', 'scale', 'ori']for var_name, var, req_shape in zip(names, [xy, scale, ori], [("B", "N", 2), ("B", "N", 1, 1), ("B", "N", 1)]):if not isinstance(var, torch.Tensor):- raise TypeError("{} type is not a torch.Tensor. Got {}".format(var_name, type(var)))+ raise TypeError(f"{var_name} type is not a torch.Tensor. Got {type(var)}")if len(var.shape) != len(req_shape): # type: ignore # because it does not like len(tensor.shape)raise TypeError("{} shape should be must be [{}]. " "Got {}".format(var_name, str(req_shape), var.size()))for i, dim in enumerate(req_shape): # type: ignore # because it wants typing for dimdiff --git a/kornia/feature/mkd.py b/kornia/feature/mkd.pyindex dbcaad67b..f35dffbaa 100644--- a/kornia/feature/mkd.py+++ b/kornia/feature/mkd.py@@ -73,9 +73,9 @@ class MKDGradients(nn.Module):def forward(self, x: torch.Tensor) -> torch.Tensor:if not isinstance(x, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(x)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(x)}")if not len(x.shape) == 4:- raise ValueError("Invalid input shape, we expect Bx1xHxW. Got: {}".format(x.shape))+ raise ValueError(f"Invalid input shape, we expect Bx1xHxW. Got: {x.shape}")# Modify 'diff' gradient. Before we had lambda function, but it is not jittablegrads_xy = -self.grad(x)gx = grads_xy[:, :, 0, :, :]@@ -136,10 +136,10 @@ class VonMisesKernel(nn.Module):def forward(self, x: torch.Tensor) -> torch.Tensor:if not isinstance(x, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(x)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(x)}")if not len(x.shape) == 4 or x.shape[1] != 1:- raise ValueError("Invalid input shape, we expect Bx1xHxW. Got: {}".format(x.shape))+ raise ValueError(f"Invalid input shape, we expect Bx1xHxW. Got: {x.shape}")# TODO: unify the two lines below when pytorch 1.6 support is droppedemb0: torch.Tensor = torch.jit.annotate(torch.Tensor, self.emb0)@@ -212,9 +212,9 @@ class EmbedGradients(nn.Module):def forward(self, grads: torch.Tensor) -> torch.Tensor:if not isinstance(grads, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(grads)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(grads)}")if not len(grads.shape) == 4:- raise ValueError("Invalid input shape, we expect Bx2xHxW. Got: {}".format(grads.shape))+ raise ValueError(f"Invalid input shape, we expect Bx2xHxW. Got: {grads.shape}")mags = grads[:, :1, :, :]oris = grads[:, 1:, :, :]if self.relative:@@ -348,9 +348,9 @@ class ExplicitSpacialEncoding(nn.Module):def forward(self, x: torch.Tensor) -> torch.Tensor:if not isinstance(x, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(x)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(x)}")if not ((len(x.shape) == 4) | (x.shape[1] == self.in_dims)):- raise ValueError("Invalid input shape, we expect Bx{}xHxW. Got: {}".format(self.in_dims, x.shape))+ raise ValueError(f"Invalid input shape, we expect Bx{self.in_dims}xHxW. Got: {x.shape}")idx1 = torch.jit.annotate(torch.Tensor, self.idx1)emb1 = torch.index_select(x, 1, idx1)output = emb1 * self.emb2@@ -485,9 +485,9 @@ class Whitening(nn.Module):def forward(self, x: torch.Tensor) -> torch.Tensor:if not isinstance(x, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(x)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(x)}")if not len(x.shape) == 2:- raise ValueError("Invalid input shape, we expect NxD. Got: {}".format(x.shape))+ raise ValueError(f"Invalid input shape, we expect NxD. Got: {x.shape}")x = x - self.mean # Center the data.x = x @ self.evecs # Apply rotation and/or scaling.x = torch.sign(x) * torch.pow(torch.abs(x), self.pval) # Powerlaw.@@ -590,9 +590,9 @@ class MKDDescriptor(nn.Module):def forward(self, patches: torch.Tensor) -> torch.Tensor:if not isinstance(patches, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(patches)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(patches)}")if not len(patches.shape) == 4:- raise ValueError("Invalid input shape, we expect Bx1xHxW. Got: {}".format(patches.shape))+ raise ValueError(f"Invalid input shape, we expect Bx1xHxW. Got: {patches.shape}")# Extract gradients.g = self.smoothing(patches)g = self.gradients(g)diff --git a/kornia/feature/nms.py b/kornia/feature/nms.pyindex 29741ccb3..a48ee0b99 100644--- a/kornia/feature/nms.py+++ b/kornia/feature/nms.py@@ -27,7 +27,7 @@ class NonMaximaSuppression2d(nn.Module):r"""Applies non maxima suppression to filter."""def __init__(self, kernel_size: Tuple[int, int]):- super(NonMaximaSuppression2d, self).__init__()+ super().__init__()self.kernel_size: Tuple[int, int] = kernel_sizeself.padding: Tuple[int, int, int, int] = self._compute_zero_padding2d(kernel_size)self.kernel = _get_nms_kernel2d(*kernel_size)@@ -70,7 +70,7 @@ class NonMaximaSuppression3d(nn.Module):r"""Applies non maxima suppression to filter."""def __init__(self, kernel_size: Tuple[int, int, int]):- super(NonMaximaSuppression3d, self).__init__()+ super().__init__()self.kernel_size: Tuple[int, int, int] = kernel_sizeself.padding: Tuple[int, int, int, int, int, int] = self._compute_zero_padding3d(kernel_size)self.kernel = _get_nms_kernel3d(*kernel_size)diff --git a/kornia/feature/orientation.py b/kornia/feature/orientation.pyindex 81b9ac1ed..3e45a357a 100644--- a/kornia/feature/orientation.py+++ b/kornia/feature/orientation.py@@ -45,7 +45,7 @@ class PatchDominantGradientOrientation(nn.Module):"""def __init__(self, patch_size: int = 32, num_angular_bins: int = 36, eps: float = 1e-8):- super(PatchDominantGradientOrientation, self).__init__()+ super().__init__()self.patch_size = patch_sizeself.num_ang_bins = num_angular_binsself.gradient = SpatialGradient('sobel', 1)@@ -76,9 +76,9 @@ class PatchDominantGradientOrientation(nn.Module):Returns:torch.Tensor: angle shape [B]"""if not isinstance(patch, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(patch)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(patch)}")if not len(patch.shape) == 4:- raise ValueError("Invalid input shape, we expect Bx1xHxW. Got: {}".format(patch.shape))+ raise ValueError(f"Invalid input shape, we expect Bx1xHxW. Got: {patch.shape}")B, CH, W, H = patch.size()if (W != self.patch_size) or (H != self.patch_size) or (CH != 1):raise TypeError(@@ -140,7 +140,7 @@ class OriNet(nn.Module):"""def __init__(self, pretrained: bool = False, eps: float = 1e-8):- super(OriNet, self).__init__()+ super().__init__()self.features = nn.Sequential(nn.Conv2d(1, 16, kernel_size=3, padding=1, bias=False),nn.BatchNorm2d(16, affine=False),@@ -206,7 +206,7 @@ class LAFOrienter(nn.Module):""" # noqa pylint: disabledef __init__(self, patch_size: int = 32, num_angular_bins: int = 36, angle_detector: Optional[nn.Module] = None):- super(LAFOrienter, self).__init__()+ super().__init__()self.patch_size = patch_sizeself.num_ang_bins = num_angular_binsself.angle_detector: nn.Module@@ -231,15 +231,13 @@ class LAFOrienter(nn.Module):laf_out, shape [BxNx2x3]"""raise_error_if_laf_is_not_valid(laf)- img_message: str = "Invalid img shape, we expect BxCxHxW. Got: {}".format(img.shape)+ img_message: str = f"Invalid img shape, we expect BxCxHxW. Got: {img.shape}"if not isinstance(img, torch.Tensor):- raise TypeError("img type is not a torch.Tensor. Got {}".format(type(img)))+ raise TypeError(f"img type is not a torch.Tensor. Got {type(img)}")if len(img.shape) != 4:raise ValueError(img_message)if laf.size(0) != img.size(0):- raise ValueError(- "Batch size of laf and img should be the same. Got {}, {}".format(img.size(0), laf.size(0))- )+ raise ValueError(f"Batch size of laf and img should be the same. Got {img.size(0)}, {laf.size(0)}")B, N = laf.shape[:2]patches: torch.Tensor = extract_patches_from_pyramid(img, laf, self.patch_size).view(-1, 1, self.patch_size, self.patch_sizediff --git a/kornia/feature/responses.py b/kornia/feature/responses.pyindex 1b16d2a8f..ac966aea5 100644--- a/kornia/feature/responses.py+++ b/kornia/feature/responses.py@@ -64,16 +64,16 @@ def harris_response("""# TODO: Recompute doctestif not isinstance(input, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(input)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(input)}")if not len(input.shape) == 4:- raise ValueError("Invalid input shape, we expect BxCxHxW. Got: {}".format(input.shape))+ raise ValueError(f"Invalid input shape, we expect BxCxHxW. Got: {input.shape}")if sigmas is not None:if not isinstance(sigmas, torch.Tensor):- raise TypeError("sigmas type is not a torch.Tensor. Got {}".format(type(sigmas)))+ raise TypeError(f"sigmas type is not a torch.Tensor. Got {type(sigmas)}")if (not len(sigmas.shape) == 1) or (sigmas.size(0) != input.size(0)):- raise ValueError("Invalid sigmas shape, we expect B == input.size(0). Got: {}".format(sigmas.shape))+ raise ValueError(f"Invalid sigmas shape, we expect B == input.size(0). Got: {sigmas.shape}")gradients: torch.Tensor = spatial_gradient(input, grads_mode)dx: torch.Tensor = gradients[:, :, 0]@@ -148,10 +148,10 @@ def gftt_response("""# TODO: Recompute doctestif not isinstance(input, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(input)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(input)}")if not len(input.shape) == 4:- raise ValueError("Invalid input shape, we expect BxCxHxW. Got: {}".format(input.shape))+ raise ValueError(f"Invalid input shape, we expect BxCxHxW. Got: {input.shape}")gradients: torch.Tensor = spatial_gradient(input, grads_mode)dx: torch.Tensor = gradients[:, :, 0]@@ -230,17 +230,17 @@ def hessian_response("""# TODO: Recompute doctestif not isinstance(input, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(input)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(input)}")if not len(input.shape) == 4:- raise ValueError("Invalid input shape, we expect BxCxHxW. Got: {}".format(input.shape))+ raise ValueError(f"Invalid input shape, we expect BxCxHxW. Got: {input.shape}")if sigmas is not None:if not isinstance(sigmas, torch.Tensor):- raise TypeError("sigmas type is not a torch.Tensor. Got {}".format(type(sigmas)))+ raise TypeError(f"sigmas type is not a torch.Tensor. Got {type(sigmas)}")if (not len(sigmas.shape) == 1) or (sigmas.size(0) != input.size(0)):- raise ValueError("Invalid sigmas shape, we expect B == input.size(0). Got: {}".format(sigmas.shape))+ raise ValueError(f"Invalid sigmas shape, we expect B == input.size(0). Got: {sigmas.shape}")gradients: torch.Tensor = spatial_gradient(input, grads_mode, 2)dxx: torch.Tensor = gradients[:, :, 0]@@ -266,10 +266,10 @@ def dog_response(input: torch.Tensor) -> torch.Tensor:"""if not isinstance(input, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(input)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(input)}")if not len(input.shape) == 5:- raise ValueError("Invalid input shape, we expect BxCxDxHxW. Got: {}".format(input.shape))+ raise ValueError(f"Invalid input shape, we expect BxCxDxHxW. Got: {input.shape}")return input[:, :, 1:] - input[:, :, :-1]@@ -281,7 +281,7 @@ class BlobDoG(nn.Module):"""def __init__(self) -> None:- super(BlobDoG, self).__init__()+ super().__init__()returndef __repr__(self) -> str:@@ -298,7 +298,7 @@ class CornerHarris(nn.Module):"""def __init__(self, k: Union[float, torch.Tensor], grads_mode='sobel') -> None:- super(CornerHarris, self).__init__()+ super().__init__()if type(k) is float:self.register_buffer('k', torch.tensor(k))else:@@ -320,7 +320,7 @@ class CornerGFTT(nn.Module):"""def __init__(self, grads_mode='sobel') -> None:- super(CornerGFTT, self).__init__()+ super().__init__()self.grads_mode: str = grads_modereturn@@ -338,7 +338,7 @@ class BlobHessian(nn.Module):"""def __init__(self, grads_mode='sobel') -> None:- super(BlobHessian, self).__init__()+ super().__init__()self.grads_mode: str = grads_modereturndiff --git a/kornia/feature/scale_space_detector.py b/kornia/feature/scale_space_detector.pyindex ba11a1657..ed49e2904 100644--- a/kornia/feature/scale_space_detector.py+++ b/kornia/feature/scale_space_detector.py@@ -86,7 +86,7 @@ class ScaleSpaceDetector(nn.Module):minima_are_also_good: bool = False,scale_space_response=False,):- super(ScaleSpaceDetector, self).__init__()+ super().__init__()self.mr_size = mr_sizeself.num_features = num_featuresself.scale_pyr = scale_pyr_modulediff --git a/kornia/feature/siftdesc.py b/kornia/feature/siftdesc.pyindex 205290707..5cc9347b0 100644--- a/kornia/feature/siftdesc.py+++ b/kornia/feature/siftdesc.py@@ -100,7 +100,7 @@ class SIFTDescriptor(nn.Module):rootsift: bool = True,clipval: float = 0.2,) -> None:- super(SIFTDescriptor, self).__init__()+ super().__init__()self.eps = 1e-10self.num_ang_bins = num_ang_binsself.num_spatial_bins = num_spatial_bins@@ -134,9 +134,9 @@ class SIFTDescriptor(nn.Module):def forward(self, input):if not isinstance(input, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(input)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(input)}")if not len(input.shape) == 4:- raise ValueError("Invalid input shape, we expect Bx1xHxW. Got: {}".format(input.shape))+ raise ValueError(f"Invalid input shape, we expect Bx1xHxW. Got: {input.shape}")B, CH, W, H = input.size()if (W != self.patch_size) or (H != self.patch_size) or (CH != 1):raise TypeError(diff --git a/kornia/feature/sosnet.py b/kornia/feature/sosnet.pyindex ad5c3f73f..4721ef983 100644--- a/kornia/feature/sosnet.py+++ b/kornia/feature/sosnet.py@@ -28,7 +28,7 @@ class SOSNet(nn.Module):"""def __init__(self, pretrained: bool = False) -> None:- super(SOSNet, self).__init__()+ super().__init__()self.layers = nn.Sequential(nn.InstanceNorm2d(1, affine=False),diff --git a/kornia/feature/tfeat.py b/kornia/feature/tfeat.pyindex 0474af3c0..0288f65f5 100644--- a/kornia/feature/tfeat.py+++ b/kornia/feature/tfeat.py@@ -39,7 +39,7 @@ class TFeat(nn.Module):"""def __init__(self, pretrained: bool = False) -> None:- super(TFeat, self).__init__()+ super().__init__()self.features = nn.Sequential(nn.InstanceNorm2d(1, affine=False),nn.Conv2d(1, 32, kernel_size=7),diff --git a/kornia/filters/blur.py b/kornia/filters/blur.pyindex a898b791f..d039754ad 100644--- a/kornia/filters/blur.py+++ b/kornia/filters/blur.py@@ -88,7 +88,7 @@ class BoxBlur(nn.Module):"""def __init__(self, kernel_size: Tuple[int, int], border_type: str = 'reflect', normalized: bool = True) -> None:- super(BoxBlur, self).__init__()+ super().__init__()self.kernel_size: Tuple[int, int] = kernel_sizeself.border_type: str = border_typeself.normalized: bool = normalizeddiff --git a/kornia/filters/blur_pool.py b/kornia/filters/blur_pool.pyindex efaeb220a..ca95a1350 100644--- a/kornia/filters/blur_pool.py+++ b/kornia/filters/blur_pool.py@@ -42,7 +42,7 @@ class BlurPool2D(nn.Module):"""def __init__(self, kernel_size: int, stride: int = 2):- super(BlurPool2D, self).__init__()+ super().__init__()self.kernel_size = kernel_sizeself.stride = strideself.register_buffer('kernel', get_pascal_kernel_2d(kernel_size, norm=True))@@ -88,7 +88,7 @@ class MaxBlurPool2D(nn.Module):"""def __init__(self, kernel_size: int, stride: int = 2, max_pool_size: int = 2, ceil_mode: bool = False):- super(MaxBlurPool2D, self).__init__()+ super().__init__()self.kernel_size = kernel_sizeself.stride = strideself.max_pool_size = max_pool_sizediff --git a/kornia/filters/canny.py b/kornia/filters/canny.pyindex 785e85edb..9bc740b58 100644--- a/kornia/filters/canny.py+++ b/kornia/filters/canny.py@@ -52,10 +52,10 @@ def canny(torch.Size([5, 1, 4, 4])"""if not isinstance(input, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(input)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(input)}")if not len(input.shape) == 4:- raise ValueError("Invalid input shape, we expect BxCxHxW. Got: {}".format(input.shape))+ raise ValueError(f"Invalid input shape, we expect BxCxHxW. Got: {input.shape}")if low_threshold > high_threshold:raise ValueError(@@ -65,14 +65,10 @@ def canny()if low_threshold < 0 and low_threshold > 1:- raise ValueError(- "Invalid input threshold. low_threshold should be in range (0,1). Got: {}".format(low_threshold)- )+ raise ValueError(f"Invalid input threshold. low_threshold should be in range (0,1). Got: {low_threshold}")if high_threshold < 0 and high_threshold > 1:- raise ValueError(- "Invalid input threshold. high_threshold should be in range (0,1). Got: {}".format(high_threshold)- )+ raise ValueError(f"Invalid input threshold. high_threshold should be in range (0,1). Got: {high_threshold}")device: torch.device = input.devicedtype: torch.dtype = input.dtype@@ -191,7 +187,7 @@ class Canny(nn.Module):hysteresis: bool = True,eps: float = 1e-6,) -> None:- super(Canny, self).__init__()+ super().__init__()if low_threshold > high_threshold:raise ValueError(@@ -202,14 +198,10 @@ class Canny(nn.Module):)if low_threshold < 0 or low_threshold > 1:- raise ValueError(- "Invalid input threshold. low_threshold should be in range (0,1). Got: {}".format(low_threshold)- )+ raise ValueError(f"Invalid input threshold. low_threshold should be in range (0,1). Got: {low_threshold}")if high_threshold < 0 or high_threshold > 1:- raise ValueError(- "Invalid input threshold. high_threshold should be in range (0,1). Got: {}".format(high_threshold)- )+ raise ValueError(f"Invalid input threshold. high_threshold should be in range (0,1). Got: {high_threshold}")# Gaussian blur parametersself.kernel_size = kernel_sizediff --git a/kornia/filters/filter.py b/kornia/filters/filter.pyindex 4e619d8cf..d9d86881b 100644--- a/kornia/filters/filter.py+++ b/kornia/filters/filter.py@@ -70,19 +70,19 @@ def filter2d([0., 0., 0., 0., 0.]]]])"""if not isinstance(input, torch.Tensor):- raise TypeError("Input border_type is not torch.Tensor. Got {}".format(type(input)))+ raise TypeError(f"Input border_type is not torch.Tensor. Got {type(input)}")if not isinstance(kernel, torch.Tensor):- raise TypeError("Input border_type is not torch.Tensor. Got {}".format(type(kernel)))+ raise TypeError(f"Input border_type is not torch.Tensor. Got {type(kernel)}")if not isinstance(border_type, str):- raise TypeError("Input border_type is not string. Got {}".format(type(kernel)))+ raise TypeError(f"Input border_type is not string. Got {type(kernel)}")if not len(input.shape) == 4:- raise ValueError("Invalid input shape, we expect BxCxHxW. Got: {}".format(input.shape))+ raise ValueError(f"Invalid input shape, we expect BxCxHxW. Got: {input.shape}")if not len(kernel.shape) == 3 and kernel.shape[0] != 1:- raise ValueError("Invalid kernel shape, we expect 1xHxW. Got: {}".format(kernel.shape))+ raise ValueError(f"Invalid kernel shape, we expect 1xHxW. Got: {kernel.shape}")# prepare kernelb, c, h, w = input.shape@@ -171,19 +171,19 @@ def filter3d([0., 0., 0., 0., 0.]]]]])"""if not isinstance(input, torch.Tensor):- raise TypeError("Input border_type is not torch.Tensor. Got {}".format(type(input)))+ raise TypeError(f"Input border_type is not torch.Tensor. Got {type(input)}")if not isinstance(kernel, torch.Tensor):- raise TypeError("Input border_type is not torch.Tensor. Got {}".format(type(kernel)))+ raise TypeError(f"Input border_type is not torch.Tensor. Got {type(kernel)}")if not isinstance(border_type, str):- raise TypeError("Input border_type is not string. Got {}".format(type(kernel)))+ raise TypeError(f"Input border_type is not string. Got {type(kernel)}")if not len(input.shape) == 5:- raise ValueError("Invalid input shape, we expect BxCxDxHxW. Got: {}".format(input.shape))+ raise ValueError(f"Invalid input shape, we expect BxCxDxHxW. Got: {input.shape}")if not len(kernel.shape) == 4 and kernel.shape[0] != 1:- raise ValueError("Invalid kernel shape, we expect 1xDxHxW. Got: {}".format(kernel.shape))+ raise ValueError(f"Invalid kernel shape, we expect 1xDxHxW. Got: {kernel.shape}")# prepare kernelb, c, d, h, w = input.shapediff --git a/kornia/filters/gaussian.py b/kornia/filters/gaussian.pyindex f891065c1..aab39c885 100644--- a/kornia/filters/gaussian.py+++ b/kornia/filters/gaussian.py@@ -73,7 +73,7 @@ class GaussianBlur2d(nn.Module):"""def __init__(self, kernel_size: Tuple[int, int], sigma: Tuple[float, float], border_type: str = 'reflect') -> None:- super(GaussianBlur2d, self).__init__()+ super().__init__()self.kernel_size: Tuple[int, int] = kernel_sizeself.sigma: Tuple[float, float] = sigmaself.border_type = border_typediff --git a/kornia/filters/kernels.py b/kornia/filters/kernels.pyindex 06d70b6aa..fddf959bf 100644--- a/kornia/filters/kernels.py+++ b/kornia/filters/kernels.py@@ -7,7 +7,7 @@ import torchdef normalize_kernel2d(input: torch.Tensor) -> torch.Tensor:r"""Normalizes both derivative and smoothing kernel."""if len(input.size()) < 2:- raise TypeError("input should be at least 2D tensor. Got {}".format(input.size()))+ raise TypeError(f"input should be at least 2D tensor. Got {input.size()}")norm: torch.Tensor = input.abs().sum(dim=-1).sum(dim=-1)return input / (norm.unsqueeze(-1).unsqueeze(-1))@@ -19,7 +19,7 @@ def gaussian(window_size: int, sigma: float) -> torch.Tensor:x = torch.arange(window_size, device=device, dtype=dtype) - window_size // 2if window_size % 2 == 0:x = x + 0.5- gauss = torch.exp((-x.pow(2.0) / (2 * sigma ** 2)))+ gauss = torch.exp(-x.pow(2.0) / (2 * sigma ** 2))return gauss / gauss.sum()@@ -450,9 +450,9 @@ def get_gaussian_kernel2d([0.0370, 0.0720, 0.0899, 0.0720, 0.0370]])"""if not isinstance(kernel_size, tuple) or len(kernel_size) != 2:- raise TypeError("kernel_size must be a tuple of length two. Got {}".format(kernel_size))+ raise TypeError(f"kernel_size must be a tuple of length two. Got {kernel_size}")if not isinstance(sigma, tuple) or len(sigma) != 2:- raise TypeError("sigma must be a tuple of length two. Got {}".format(sigma))+ raise TypeError(f"sigma must be a tuple of length two. Got {sigma}")ksize_x, ksize_y = kernel_sizesigma_x, sigma_y = sigmakernel_x: torch.Tensor = get_gaussian_kernel1d(ksize_x, sigma_x, force_even)@@ -481,7 +481,7 @@ def get_laplacian_kernel1d(kernel_size: int) -> torch.Tensor:"""if not isinstance(kernel_size, int) or kernel_size % 2 == 0 or kernel_size <= 0:- raise TypeError("ksize must be an odd positive integer. Got {}".format(kernel_size))+ raise TypeError(f"ksize must be an odd positive integer. Got {kernel_size}")window_1d: torch.Tensor = laplacian_1d(kernel_size)return window_1d@@ -511,7 +511,7 @@ def get_laplacian_kernel2d(kernel_size: int) -> torch.Tensor:[ 1., 1., 1., 1., 1.]])"""if not isinstance(kernel_size, int) or kernel_size % 2 == 0 or kernel_size <= 0:- raise TypeError("ksize must be an odd positive integer. Got {}".format(kernel_size))+ raise TypeError(f"ksize must be an odd positive integer. Got {kernel_size}")kernel = torch.ones((kernel_size, kernel_size))mid = kernel_size // 2diff --git a/kornia/filters/laplacian.py b/kornia/filters/laplacian.pyindex 2b94dd2ba..7e6722997 100644--- a/kornia/filters/laplacian.py+++ b/kornia/filters/laplacian.py@@ -70,7 +70,7 @@ class Laplacian(nn.Module):"""def __init__(self, kernel_size: int, border_type: str = 'reflect', normalized: bool = True) -> None:- super(Laplacian, self).__init__()+ super().__init__()self.kernel_size: int = kernel_sizeself.border_type: str = border_typeself.normalized: bool = normalizeddiff --git a/kornia/filters/median.py b/kornia/filters/median.pyindex f338ea31c..831d63314 100644--- a/kornia/filters/median.py+++ b/kornia/filters/median.py@@ -36,10 +36,10 @@ def median_blur(input: torch.Tensor, kernel_size: Tuple[int, int]) -> torch.Tenstorch.Size([2, 4, 5, 7])"""if not isinstance(input, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(input)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(input)}")if not len(input.shape) == 4:- raise ValueError("Invalid input shape, we expect BxCxHxW. Got: {}".format(input.shape))+ raise ValueError(f"Invalid input shape, we expect BxCxHxW. Got: {input.shape}")padding: Tuple[int, int] = _compute_zero_padding(kernel_size)@@ -79,7 +79,7 @@ class MedianBlur(nn.Module):"""def __init__(self, kernel_size: Tuple[int, int]) -> None:- super(MedianBlur, self).__init__()+ super().__init__()self.kernel_size: Tuple[int, int] = kernel_sizedef forward(self, input: torch.Tensor) -> torch.Tensor:diff --git a/kornia/filters/motion.py b/kornia/filters/motion.pyindex f8c3d08af..774b983ed 100644--- a/kornia/filters/motion.py+++ b/kornia/filters/motion.py@@ -34,7 +34,7 @@ class MotionBlur(nn.Module):"""def __init__(self, kernel_size: int, angle: float, direction: float, border_type: str = 'constant') -> None:- super(MotionBlur, self).__init__()+ super().__init__()self.kernel_size = kernel_sizeself.angle: float = angleself.direction: float = direction@@ -83,7 +83,7 @@ class MotionBlur3D(nn.Module):direction: float,border_type: str = 'constant',) -> None:- super(MotionBlur3D, self).__init__()+ super().__init__()self.kernel_size = kernel_sizeself.angle: Tuple[float, float, float]if isinstance(angle, float):diff --git a/kornia/filters/sobel.py b/kornia/filters/sobel.pyindex f1213e009..2ceb4cac0 100644--- a/kornia/filters/sobel.py+++ b/kornia/filters/sobel.py@@ -31,10 +31,10 @@ def spatial_gradient(input: torch.Tensor, mode: str = 'sobel', order: int = 1, ntorch.Size([1, 3, 2, 4, 4])"""if not isinstance(input, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(input)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(input)}")if not len(input.shape) == 4:- raise ValueError("Invalid input shape, we expect BxCxHxW. Got: {}".format(input.shape))+ raise ValueError(f"Invalid input shape, we expect BxCxHxW. Got: {input.shape}")# allocate kernelkernel: torch.Tensor = get_spatial_gradient_kernel2d(mode, order)if normalized:@@ -79,10 +79,10 @@ def spatial_gradient3d(input: torch.Tensor, mode: str = 'diff', order: int = 1)torch.Size([1, 4, 3, 2, 4, 4])"""if not isinstance(input, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(input)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(input)}")if not len(input.shape) == 5:- raise ValueError("Invalid input shape, we expect BxCxDxHxW. Got: {}".format(input.shape))+ raise ValueError(f"Invalid input shape, we expect BxCxDxHxW. Got: {input.shape}")# allocate kernelkernel: torch.Tensor = get_spatial_gradient_kernel3d(mode, order)@@ -133,10 +133,10 @@ def sobel(input: torch.Tensor, normalized: bool = True, eps: float = 1e-6) -> totorch.Size([1, 3, 4, 4])"""if not isinstance(input, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(input)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(input)}")if not len(input.shape) == 4:- raise ValueError("Invalid input shape, we expect BxCxHxW. Got: {}".format(input.shape))+ raise ValueError(f"Invalid input shape, we expect BxCxHxW. Got: {input.shape}")# comput the x/y gradientsedges: torch.Tensor = spatial_gradient(input, normalized=normalized)@@ -173,7 +173,7 @@ class SpatialGradient(nn.Module):"""def __init__(self, mode: str = 'sobel', order: int = 1, normalized: bool = True) -> None:- super(SpatialGradient, self).__init__()+ super().__init__()self.normalized: bool = normalizedself.order: int = orderself.mode: str = mode@@ -211,7 +211,7 @@ class SpatialGradient3d(nn.Module):"""def __init__(self, mode: str = 'diff', order: int = 1) -> None:- super(SpatialGradient3d, self).__init__()+ super().__init__()self.order: int = orderself.mode: str = modeself.kernel = get_spatial_gradient_kernel3d(mode, order)@@ -244,7 +244,7 @@ class Sobel(nn.Module):"""def __init__(self, normalized: bool = True, eps: float = 1e-6) -> None:- super(Sobel, self).__init__()+ super().__init__()self.normalized: bool = normalizedself.eps: float = epsdiff --git a/kornia/filters/unsharp.py b/kornia/filters/unsharp.pyindex 18951381e..1464baee5 100644--- a/kornia/filters/unsharp.py+++ b/kornia/filters/unsharp.py@@ -65,7 +65,7 @@ class UnsharpMask(nn.Module):"""def __init__(self, kernel_size: Tuple[int, int], sigma: Tuple[float, float], border_type: str = 'reflect') -> None:- super(UnsharpMask, self).__init__()+ super().__init__()self.kernel_size: Tuple[int, int] = kernel_sizeself.sigma: Tuple[float, float] = sigmaself.border_type = border_typediff --git a/kornia/geometry/camera/perspective.py b/kornia/geometry/camera/perspective.pyindex 7ab8538f8..f3ae5060d 100644--- a/kornia/geometry/camera/perspective.py+++ b/kornia/geometry/camera/perspective.py@@ -17,10 +17,10 @@ def project_points(point_3d: torch.Tensor, camera_matrix: torch.Tensor) -> torchtensor of (u, v) cam coordinates with shape :math:`(*, 2)`."""if not isinstance(point_3d, torch.Tensor):- raise TypeError("Input point_3d type is not a torch.Tensor. Got {}".format(type(point_3d)))+ raise TypeError(f"Input point_3d type is not a torch.Tensor. Got {type(point_3d)}")if not isinstance(camera_matrix, torch.Tensor):- raise TypeError("Input camera_matrix type is not a torch.Tensor. Got {}".format(type(camera_matrix)))+ raise TypeError(f"Input camera_matrix type is not a torch.Tensor. Got {type(camera_matrix)}")if not (point_3d.device == camera_matrix.device):raise ValueError("Input tensors must be all in the same device.")@@ -75,13 +75,13 @@ def unproject_points(tensor of (x, y, z) world coordinates with shape :math:`(*, 3)`."""if not isinstance(point_2d, torch.Tensor):- raise TypeError("Input point_2d type is not a torch.Tensor. Got {}".format(type(point_2d)))+ raise TypeError(f"Input point_2d type is not a torch.Tensor. Got {type(point_2d)}")if not isinstance(depth, torch.Tensor):- raise TypeError("Input depth type is not a torch.Tensor. Got {}".format(type(depth)))+ raise TypeError(f"Input depth type is not a torch.Tensor. Got {type(depth)}")if not isinstance(camera_matrix, torch.Tensor):- raise TypeError("Input camera_matrix type is not a torch.Tensor. Got {}".format(type(camera_matrix)))+ raise TypeError(f"Input camera_matrix type is not a torch.Tensor. Got {type(camera_matrix)}")if not (point_2d.device == depth.device == camera_matrix.device):raise ValueError("Input tensors must be all in the same device.")diff --git a/kornia/geometry/camera/pinhole.py b/kornia/geometry/camera/pinhole.pyindex ee58b2104..ae9488708 100644--- a/kornia/geometry/camera/pinhole.py+++ b/kornia/geometry/camera/pinhole.py@@ -46,8 +46,8 @@ class PinholeCamera:def _check_valid_params(data: torch.Tensor, data_name: str) -> bool:if len(data.shape) not in (3, 4) and data.shape[-2:] != (4, 4): # Shouldn't this be an OR logic than AND?raise ValueError(- "Argument {0} shape must be in the following shape"- " Bx4x4 or BxNx4x4. Got {1}".format(data_name, data.shape)+ "Argument {} shape must be in the following shape"+ " Bx4x4 or BxNx4x4. Got {}".format(data_name, data.shape))return True@@ -55,7 +55,7 @@ class PinholeCamera:def _check_valid_shape(data: torch.Tensor, data_name: str) -> bool:if not len(data.shape) == 1:raise ValueError(- "Argument {0} shape must be in the following shape" " B. Got {1}".format(data_name, data.shape)+ "Argument {} shape must be in the following shape" " B. Got {}".format(data_name, data.shape))return True@@ -326,7 +326,7 @@ class PinholeCamerasList(PinholeCamera):def _initialize_parameters(self, pinholes: Iterable[PinholeCamera]) -> 'PinholeCamerasList':r"""Initialises the class attributes given a cameras list."""if not isinstance(pinholes, (list, tuple)):- raise TypeError("pinhole must of type list or tuple. Got {}".format(type(pinholes)))+ raise TypeError(f"pinhole must of type list or tuple. Got {type(pinholes)}")height, width = [], []intrinsics, extrinsics = [], []for pinhole in pinholes:diff --git a/kornia/geometry/conversions.py b/kornia/geometry/conversions.pyindex 6c93eaad6..c986eeac3 100644--- a/kornia/geometry/conversions.py+++ b/kornia/geometry/conversions.py@@ -52,7 +52,7 @@ def rad2deg(tensor: torch.Tensor) -> torch.Tensor:>>> output = rad2deg(input)"""if not isinstance(tensor, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(tensor)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(tensor)}")return 180.0 * tensor / pi.to(tensor.device).type(tensor.dtype)@@ -71,7 +71,7 @@ def deg2rad(tensor: torch.Tensor) -> torch.Tensor:>>> output = deg2rad(input)"""if not isinstance(tensor, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(tensor)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(tensor)}")return tensor * pi.to(tensor.device).type(tensor.dtype) / 180.0@@ -92,7 +92,7 @@ def pol2cart(rho: torch.Tensor, phi: torch.Tensor) -> Tuple[torch.Tensor, torch.>>> x, y = pol2cart(rho, phi)"""if not (isinstance(rho, torch.Tensor) & isinstance(phi, torch.Tensor)):- raise TypeError("Input type is not a torch.Tensor. Got {}, {}".format(type(rho), type(phi)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(rho)}, {type(phi)}")x = rho * torch.cos(phi)y = rho * torch.sin(phi)@@ -116,7 +116,7 @@ def cart2pol(x: torch.Tensor, y: torch.Tensor, eps: float = 1.0e-8) -> Tuple[tor>>> rho, phi = cart2pol(x, y)"""if not (isinstance(x, torch.Tensor) & isinstance(y, torch.Tensor)):- raise TypeError("Input type is not a torch.Tensor. Got {}, {}".format(type(x), type(y)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(x)}, {type(y)}")rho = torch.sqrt(x ** 2 + y ** 2 + eps)phi = torch.atan2(y, x)@@ -138,10 +138,10 @@ def convert_points_from_homogeneous(points: torch.Tensor, eps: float = 1e-8) ->>>> output = convert_points_from_homogeneous(input) # BxNx2"""if not isinstance(points, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(points)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(points)}")if len(points.shape) < 2:- raise ValueError("Input must be at least a 2D tensor. Got {}".format(points.shape))+ raise ValueError(f"Input must be at least a 2D tensor. Got {points.shape}")# we check for points at max_valz_vec: torch.Tensor = points[..., -1:]@@ -169,9 +169,9 @@ def convert_points_to_homogeneous(points: torch.Tensor) -> torch.Tensor:>>> output = convert_points_to_homogeneous(input) # BxNx4"""if not isinstance(points, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(points)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(points)}")if len(points.shape) < 2:- raise ValueError("Input must be at least a 2D tensor. Got {}".format(points.shape))+ raise ValueError(f"Input must be at least a 2D tensor. Got {points.shape}")return torch.nn.functional.pad(points, [0, 1], "constant", 1.0)@@ -196,9 +196,9 @@ def convert_affinematrix_to_homography(A: torch.Tensor) -> torch.Tensor:>>> output = convert_affinematrix_to_homography(input) # Bx3x3"""if not isinstance(A, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(A)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(A)}")if not (len(A.shape) == 3 and A.shape[-2:] == (2, 3)):- raise ValueError("Input matrix must be a Bx2x3 tensor. Got {}".format(A.shape))+ raise ValueError(f"Input matrix must be a Bx2x3 tensor. Got {A.shape}")return _convert_affinematrix_to_homography_impl(A)@@ -216,9 +216,9 @@ def convert_affinematrix_to_homography3d(A: torch.Tensor) -> torch.Tensor:>>> output = convert_affinematrix_to_homography3d(input) # Bx4x4"""if not isinstance(A, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(A)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(A)}")if not (len(A.shape) == 3 and A.shape[-2:] == (3, 4)):- raise ValueError("Input matrix must be a Bx3x4 tensor. Got {}".format(A.shape))+ raise ValueError(f"Input matrix must be a Bx3x4 tensor. Got {A.shape}")return _convert_affinematrix_to_homography_impl(A)@@ -240,10 +240,10 @@ def angle_axis_to_rotation_matrix(angle_axis: torch.Tensor) -> torch.Tensor:>>> output = angle_axis_to_rotation_matrix(input) # Nx3x3"""if not isinstance(angle_axis, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(angle_axis)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(angle_axis)}")if not angle_axis.shape[-1] == 3:- raise ValueError("Input size must be a (*, 3) tensor. Got {}".format(angle_axis.shape))+ raise ValueError(f"Input size must be a (*, 3) tensor. Got {angle_axis.shape}")def _compute_rotation_matrix(angle_axis, theta2, eps=1e-6):# We want to be careful to only evaluate the square root if the@@ -445,10 +445,10 @@ def normalize_quaternion(quaternion: torch.Tensor, eps: float = 1.0e-12) -> torctensor([0.7071, 0.0000, 0.7071, 0.0000])"""if not isinstance(quaternion, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(quaternion)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(quaternion)}")if not quaternion.shape[-1] == 4:- raise ValueError("Input must be a tensor of shape (*, 4). Got {}".format(quaternion.shape))+ raise ValueError(f"Input must be a tensor of shape (*, 4). Got {quaternion.shape}")return F.normalize(quaternion, p=2.0, dim=-1, eps=eps)diff --git a/kornia/geometry/depth.py b/kornia/geometry/depth.pyindex 5c10d3e44..8e0a2b452 100644--- a/kornia/geometry/depth.py+++ b/kornia/geometry/depth.py@@ -197,7 +197,7 @@ class DepthWarper(nn.Module):padding_mode: str = 'zeros',align_corners: bool = True,):- super(DepthWarper, self).__init__()+ super().__init__()# constructor membersself.width: int = widthself.height: int = heightdiff --git a/kornia/geometry/epipolar/metrics.py b/kornia/geometry/epipolar/metrics.pyindex 324ea7141..93dc9a4c9 100644--- a/kornia/geometry/epipolar/metrics.py+++ b/kornia/geometry/epipolar/metrics.py@@ -25,10 +25,10 @@ def sampson_epipolar_distance("""if not isinstance(Fm, torch.Tensor):- raise TypeError("Fm type is not a torch.Tensor. Got {}".format(type(Fm)))+ raise TypeError(f"Fm type is not a torch.Tensor. Got {type(Fm)}")if (len(Fm.shape) != 3) or not Fm.shape[-2:] == (3, 3):- raise ValueError("Fm must be a (*, 3, 3) tensor. Got {}".format(Fm.shape))+ raise ValueError(f"Fm must be a (*, 3, 3) tensor. Got {Fm.shape}")if pts1.size(-1) == 2:pts1 = kornia.convert_points_to_homogeneous(pts1)@@ -77,10 +77,10 @@ def symmetrical_epipolar_distance("""if not isinstance(Fm, torch.Tensor):- raise TypeError("Fm type is not a torch.Tensor. Got {}".format(type(Fm)))+ raise TypeError(f"Fm type is not a torch.Tensor. Got {type(Fm)}")if (len(Fm.shape) != 3) or not Fm.shape[-2:] == (3, 3):- raise ValueError("Fm must be a (*, 3, 3) tensor. Got {}".format(Fm.shape))+ raise ValueError(f"Fm must be a (*, 3, 3) tensor. Got {Fm.shape}")if pts1.size(-1) == 2:pts1 = kornia.convert_points_to_homogeneous(pts1)diff --git a/kornia/geometry/epipolar/projection.py b/kornia/geometry/epipolar/projection.pyindex 91b126265..2d1602564 100644--- a/kornia/geometry/epipolar/projection.py+++ b/kornia/geometry/epipolar/projection.py@@ -47,7 +47,7 @@ def random_intrinsics(low: Union[float, torch.Tensor], high: Union[float, torch."""sampler = torch.distributions.Uniform(low, high)- fx, fy, cx, cy = [sampler.sample((1,)) for _ in range(4)]+ fx, fy, cx, cy = (sampler.sample((1,)) for _ in range(4))zeros, ones = torch.zeros_like(fx), torch.ones_like(fx)camera_matrix: torch.Tensor = torch.cat([fx, zeros, cx, zeros, fy, cy, zeros, zeros, ones])return camera_matrix.view(1, 3, 3)diff --git a/kornia/geometry/linalg.py b/kornia/geometry/linalg.pyindex a1f9d7056..be936e219 100644--- a/kornia/geometry/linalg.py+++ b/kornia/geometry/linalg.py@@ -42,10 +42,10 @@ def compose_transformations(trans_01: torch.Tensor, trans_12: torch.Tensor) -> t"""if not torch.is_tensor(trans_01):- raise TypeError("Input trans_01 type is not a torch.Tensor. Got {}".format(type(trans_01)))+ raise TypeError(f"Input trans_01 type is not a torch.Tensor. Got {type(trans_01)}")if not torch.is_tensor(trans_12):- raise TypeError("Input trans_12 type is not a torch.Tensor. Got {}".format(type(trans_12)))+ raise TypeError(f"Input trans_12 type is not a torch.Tensor. Got {type(trans_12)}")if not trans_01.dim() in (2, 3) and trans_01.shape[-2:] == (4, 4):raise ValueError("Input trans_01 must be a of the shape Nx4x4 or 4x4." " Got {}".format(trans_01.shape))@@ -54,7 +54,7 @@ def compose_transformations(trans_01: torch.Tensor, trans_12: torch.Tensor) -> traise ValueError("Input trans_12 must be a of the shape Nx4x4 or 4x4." " Got {}".format(trans_12.shape))if not trans_01.dim() == trans_12.dim():- raise ValueError("Input number of dims must match. Got {} and {}".format(trans_01.dim(), trans_12.dim()))+ raise ValueError(f"Input number of dims must match. Got {trans_01.dim()} and {trans_12.dim()}")# unpack input datarmat_01: torch.Tensor = trans_01[..., :3, :3] # Nx3x3@@ -96,9 +96,9 @@ def inverse_transformation(trans_12):>>> trans_21 = inverse_transformation(trans_12) # Nx4x4"""if not torch.is_tensor(trans_12):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(trans_12)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(trans_12)}")if not trans_12.dim() in (2, 3) and trans_12.shape[-2:] == (4, 4):- raise ValueError("Input size must be a Nx4x4 or 4x4. Got {}".format(trans_12.shape))+ raise ValueError(f"Input size must be a Nx4x4 or 4x4. Got {trans_12.shape}")# unpack input tensorrmat_12: torch.Tensor = trans_12[..., :3, 0:3] # Nx3x3tvec_12: torch.Tensor = trans_12[..., :3, 3:4] # Nx3x1@@ -140,15 +140,15 @@ def relative_transformation(trans_01: torch.Tensor, trans_02: torch.Tensor) -> t>>> trans_12 = relative_transformation(trans_01, trans_02) # 4x4"""if not torch.is_tensor(trans_01):- raise TypeError("Input trans_01 type is not a torch.Tensor. Got {}".format(type(trans_01)))+ raise TypeError(f"Input trans_01 type is not a torch.Tensor. Got {type(trans_01)}")if not torch.is_tensor(trans_02):- raise TypeError("Input trans_02 type is not a torch.Tensor. Got {}".format(type(trans_02)))+ raise TypeError(f"Input trans_02 type is not a torch.Tensor. Got {type(trans_02)}")if not trans_01.dim() in (2, 3) and trans_01.shape[-2:] == (4, 4):raise ValueError("Input must be a of the shape Nx4x4 or 4x4." " Got {}".format(trans_01.shape))if not trans_02.dim() in (2, 3) and trans_02.shape[-2:] == (4, 4):raise ValueError("Input must be a of the shape Nx4x4 or 4x4." " Got {}".format(trans_02.shape))if not trans_01.dim() == trans_02.dim():- raise ValueError("Input number of dims must match. Got {} and {}".format(trans_01.dim(), trans_02.dim()))+ raise ValueError(f"Input number of dims must match. Got {trans_01.dim()} and {trans_02.dim()}")trans_10: torch.Tensor = inverse_transformation(trans_01)trans_12: torch.Tensor = compose_transformations(trans_10, trans_02)return trans_12diff --git a/kornia/geometry/subpix/dsnt.py b/kornia/geometry/subpix/dsnt.pyindex 9fef4ac8a..4d0bf0248 100644--- a/kornia/geometry/subpix/dsnt.py+++ b/kornia/geometry/subpix/dsnt.py@@ -15,7 +15,7 @@ from kornia.utils.grid import create_meshgriddef _validate_batched_image_tensor_input(tensor):check_is_tensor(tensor)if not len(tensor.shape) == 4:- raise ValueError("Invalid input shape, we expect BxCxHxW. Got: {}".format(tensor.shape))+ raise ValueError(f"Invalid input shape, we expect BxCxHxW. Got: {tensor.shape}")def spatial_softmax2d(input: torch.Tensor, temperature: torch.Tensor = torch.tensor(1.0)) -> torch.Tensor:diff --git a/kornia/geometry/subpix/spatial_soft_argmax.py b/kornia/geometry/subpix/spatial_soft_argmax.pyindex 19b3dbb02..6770761e3 100644--- a/kornia/geometry/subpix/spatial_soft_argmax.py+++ b/kornia/geometry/subpix/spatial_soft_argmax.py@@ -55,7 +55,7 @@ def _get_center_kernel2d(h: int, w: int, device: torch.device = torch.device('cpelse:w_i1 = (w // 2) - 1w_i2 = (w // 2) + 1- center_kernel[(0, 1), (0, 1), h_i1:h_i2, w_i1:w_i2] = 1.0 / float(((h_i2 - h_i1) * (w_i2 - w_i1)))+ center_kernel[(0, 1), (0, 1), h_i1:h_i2, w_i1:w_i2] = 1.0 / float((h_i2 - h_i1) * (w_i2 - w_i1))return center_kernel@@ -136,7 +136,7 @@ class ConvSoftArgmax2d(nn.Module):eps: float = 1e-8,output_value: bool = False,) -> None:- super(ConvSoftArgmax2d, self).__init__()+ super().__init__()self.kernel_size = kernel_sizeself.stride = strideself.padding = padding@@ -202,7 +202,7 @@ class ConvSoftArgmax3d(nn.Module):output_value: bool = True,strict_maxima_bonus: float = 0.0,) -> None:- super(ConvSoftArgmax3d, self).__init__()+ super().__init__()self.kernel_size = kernel_sizeself.stride = strideself.padding = padding@@ -308,13 +308,13 @@ def conv_soft_argmax2d(>>> nms_coords, nms_val = conv_soft_argmax2d(input, (3,3), (2,2), (1,1), output_value=True)"""if not torch.is_tensor(input):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(input)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(input)}")if not len(input.shape) == 4:- raise ValueError("Invalid input shape, we expect BxCxHxW. Got: {}".format(input.shape))+ raise ValueError(f"Invalid input shape, we expect BxCxHxW. Got: {input.shape}")if temperature <= 0:- raise ValueError("Temperature should be positive float or tensor. Got: {}".format(temperature))+ raise ValueError(f"Temperature should be positive float or tensor. Got: {temperature}")b, c, h, w = input.shapekx, ky = kernel_size@@ -428,13 +428,13 @@ def conv_soft_argmax3d(>>> nms_coords, nms_val = conv_soft_argmax3d(input, (3, 3, 3), (1, 2, 2), (0, 1, 1))"""if not torch.is_tensor(input):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(input)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(input)}")if not len(input.shape) == 5:- raise ValueError("Invalid input shape, we expect BxCxDxHxW. Got: {}".format(input.shape))+ raise ValueError(f"Invalid input shape, we expect BxCxDxHxW. Got: {input.shape}")if temperature <= 0:- raise ValueError("Temperature should be positive float or tensor. Got: {}".format(temperature))+ raise ValueError(f"Temperature should be positive float or tensor. Got: {temperature}")b, c, d, h, w = input.shapekx, ky, kz = kernel_size@@ -539,7 +539,7 @@ class SpatialSoftArgmax2d(nn.Module):def __init__(self, temperature: torch.Tensor = torch.tensor(1.0), normalized_coordinates: bool = True, eps: float = 1e-8) -> None:- super(SpatialSoftArgmax2d, self).__init__()+ super().__init__()self.temperature: torch.Tensor = temperatureself.normalized_coordinates: bool = normalized_coordinatesself.eps: float = eps@@ -596,10 +596,10 @@ def conv_quad_interp3d(>>> nms_coords, nms_val = conv_quad_interp3d(input, 1.0)"""if not torch.is_tensor(input):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(input)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(input)}")if not len(input.shape) == 5:- raise ValueError("Invalid input shape, we expect BxCxDxHxW. Got: {}".format(input.shape))+ raise ValueError(f"Invalid input shape, we expect BxCxDxHxW. Got: {input.shape}")B, CH, D, H, W = input.shapedev: torch.device = input.device@@ -652,7 +652,7 @@ class ConvQuadInterp3d(nn.Module):"""def __init__(self, strict_maxima_bonus: float = 10.0, eps: float = 1e-7) -> None:- super(ConvQuadInterp3d, self).__init__()+ super().__init__()self.strict_maxima_bonus = strict_maxima_bonusself.eps = epsreturndiff --git a/kornia/geometry/transform/affwarp.py b/kornia/geometry/transform/affwarp.pyindex c04416643..1a1677790 100644--- a/kornia/geometry/transform/affwarp.py+++ b/kornia/geometry/transform/affwarp.py@@ -263,13 +263,13 @@ def rotate(torch.Size([1, 3, 4, 4])"""if not isinstance(tensor, torch.Tensor):- raise TypeError("Input tensor type is not a torch.Tensor. Got {}".format(type(tensor)))+ raise TypeError(f"Input tensor type is not a torch.Tensor. Got {type(tensor)}")if not isinstance(angle, torch.Tensor):- raise TypeError("Input angle type is not a torch.Tensor. Got {}".format(type(angle)))+ raise TypeError(f"Input angle type is not a torch.Tensor. Got {type(angle)}")if center is not None and not isinstance(center, torch.Tensor):- raise TypeError("Input center type is not a torch.Tensor. Got {}".format(type(center)))+ raise TypeError(f"Input center type is not a torch.Tensor. Got {type(center)}")if len(tensor.shape) not in (3, 4):raise ValueError("Invalid tensor shape, we expect CxHxW or BxCxHxW. " "Got: {}".format(tensor.shape))@@ -321,19 +321,19 @@ def rotate3d(torch.Tensor: The rotated tensor with shape as input."""if not isinstance(tensor, torch.Tensor):- raise TypeError("Input tensor type is not a torch.Tensor. Got {}".format(type(tensor)))+ raise TypeError(f"Input tensor type is not a torch.Tensor. Got {type(tensor)}")if not isinstance(yaw, torch.Tensor):- raise TypeError("yaw is not a torch.Tensor. Got {}".format(type(yaw)))+ raise TypeError(f"yaw is not a torch.Tensor. Got {type(yaw)}")if not isinstance(pitch, torch.Tensor):- raise TypeError("pitch is not a torch.Tensor. Got {}".format(type(pitch)))+ raise TypeError(f"pitch is not a torch.Tensor. Got {type(pitch)}")if not isinstance(roll, torch.Tensor):- raise TypeError("roll is not a torch.Tensor. Got {}".format(type(roll)))+ raise TypeError(f"roll is not a torch.Tensor. Got {type(roll)}")if center is not None and not isinstance(center, torch.Tensor):- raise TypeError("Input center type is not a torch.Tensor. Got {}".format(type(center)))+ raise TypeError(f"Input center type is not a torch.Tensor. Got {type(center)}")if len(tensor.shape) not in (4, 5):raise ValueError("Invalid tensor shape, we expect CxDxHxW or BxCxDxHxW. " "Got: {}".format(tensor.shape))@@ -387,10 +387,10 @@ def translate(torch.Size([1, 3, 4, 4])"""if not isinstance(tensor, torch.Tensor):- raise TypeError("Input tensor type is not a torch.Tensor. Got {}".format(type(tensor)))+ raise TypeError(f"Input tensor type is not a torch.Tensor. Got {type(tensor)}")if not isinstance(translation, torch.Tensor):- raise TypeError("Input translation type is not a torch.Tensor. Got {}".format(type(translation)))+ raise TypeError(f"Input translation type is not a torch.Tensor. Got {type(translation)}")if len(tensor.shape) not in (3, 4):raise ValueError("Invalid tensor shape, we expect CxHxW or BxCxHxW. " "Got: {}".format(tensor.shape))@@ -440,10 +440,10 @@ def scale(torch.Size([1, 3, 4, 4])"""if not isinstance(tensor, torch.Tensor):- raise TypeError("Input tensor type is not a torch.Tensor. Got {}".format(type(tensor)))+ raise TypeError(f"Input tensor type is not a torch.Tensor. Got {type(tensor)}")if not isinstance(scale_factor, torch.Tensor):- raise TypeError("Input scale_factor type is not a torch.Tensor. Got {}".format(type(scale_factor)))+ raise TypeError(f"Input scale_factor type is not a torch.Tensor. Got {type(scale_factor)}")if len(scale_factor.shape) == 1:# convert isotropic scaling to x-y direction@@ -496,10 +496,10 @@ def shear(torch.Size([1, 3, 4, 4])"""if not isinstance(tensor, torch.Tensor):- raise TypeError("Input tensor type is not a torch.Tensor. Got {}".format(type(tensor)))+ raise TypeError(f"Input tensor type is not a torch.Tensor. Got {type(tensor)}")if not isinstance(shear, torch.Tensor):- raise TypeError("Input shear type is not a torch.Tensor. Got {}".format(type(shear)))+ raise TypeError(f"Input shear type is not a torch.Tensor. Got {type(shear)}")if len(tensor.shape) not in (3, 4):raise ValueError("Invalid tensor shape, we expect CxHxW or BxCxHxW. " "Got: {}".format(tensor.shape))@@ -561,10 +561,10 @@ def resize(torch.Size([1, 3, 6, 8])"""if not isinstance(input, torch.Tensor):- raise TypeError("Input tensor type is not a torch.Tensor. Got {}".format(type(input)))+ raise TypeError(f"Input tensor type is not a torch.Tensor. Got {type(input)}")if len(input.shape) < 2:- raise ValueError('Input tensor must have at least two dimensions. Got {}'.format(len(input.shape)))+ raise ValueError(f'Input tensor must have at least two dimensions. Got {len(input.shape)}')input_size = h, w = input.shape[-2:]if isinstance(size, int):@@ -677,7 +677,7 @@ class Resize(nn.Module):side: str = "short",antialias: bool = False,) -> None:- super(Resize, self).__init__()+ super().__init__()self.size: Union[int, Tuple[int, int]] = sizeself.interpolation: str = interpolationself.align_corners: Optional[bool] = align_corners@@ -868,7 +868,7 @@ class Rotate(nn.Module):padding_mode: str = 'zeros',align_corners: Optional[bool] = None,) -> None:- super(Rotate, self).__init__()+ super().__init__()self.angle: torch.Tensor = angleself.center: Union[None, torch.Tensor] = centerself.mode: str = mode@@ -910,7 +910,7 @@ class Translate(nn.Module):padding_mode: str = 'zeros',align_corners: Optional[bool] = None,) -> None:- super(Translate, self).__init__()+ super().__init__()self.translation: torch.Tensor = translationself.mode: str = modeself.padding_mode: str = padding_mode@@ -956,7 +956,7 @@ class Scale(nn.Module):padding_mode: str = 'zeros',align_corners: Optional[bool] = None,) -> None:- super(Scale, self).__init__()+ super().__init__()self.scale_factor: torch.Tensor = scale_factorself.center: Union[None, torch.Tensor] = centerself.mode: str = mode@@ -994,7 +994,7 @@ class Shear(nn.Module):def __init__(self, shear: torch.Tensor, mode: str = 'bilinear', padding_mode: str = 'zeros', align_corners: bool = False) -> None:- super(Shear, self).__init__()+ super().__init__()self.shear: torch.Tensor = shearself.mode: str = modeself.padding_mode: str = padding_modediff --git a/kornia/geometry/transform/crop/crop2d.py b/kornia/geometry/transform/crop/crop2d.pyindex 4fc2c2fb5..cc8d3397b 100644--- a/kornia/geometry/transform/crop/crop2d.py+++ b/kornia/geometry/transform/crop/crop2d.py@@ -66,13 +66,13 @@ def crop_and_resize([10., 11.]]]])"""if not isinstance(tensor, torch.Tensor):- raise TypeError("Input tensor type is not a torch.Tensor. Got {}".format(type(tensor)))+ raise TypeError(f"Input tensor type is not a torch.Tensor. Got {type(tensor)}")if not isinstance(boxes, torch.Tensor):- raise TypeError("Input boxes type is not a torch.Tensor. Got {}".format(type(boxes)))+ raise TypeError(f"Input boxes type is not a torch.Tensor. Got {type(boxes)}")if not isinstance(size, (tuple, list)) and len(size) == 2:- raise ValueError("Input size must be a tuple/list of length 2. Got {}".format(size))+ raise ValueError(f"Input size must be a tuple/list of length 2. Got {size}")if len(tensor.shape) != 4:raise AssertionError(f"Only tensor with shape (B, C, H, W) supported. Got {tensor.shape}.")@@ -127,10 +127,10 @@ def center_crop([ 9., 10., 11., 12.]]]])"""if not isinstance(tensor, torch.Tensor):- raise TypeError("Input tensor type is not a torch.Tensor. Got {}".format(type(tensor)))+ raise TypeError(f"Input tensor type is not a torch.Tensor. Got {type(tensor)}")if not isinstance(size, (tuple, list)) and len(size) == 2:- raise ValueError("Input size must be a tuple/list of length 2. Got {}".format(size))+ raise ValueError(f"Input size must be a tuple/list of length 2. Got {size}")if len(tensor.shape) != 4:raise AssertionError(f"Only tensor with shape (B, C, H, W) supported. Got {tensor.shape}.")diff --git a/kornia/geometry/transform/crop/crop3d.py b/kornia/geometry/transform/crop/crop3d.pyindex 8830b26a1..74f3b08e5 100644--- a/kornia/geometry/transform/crop/crop3d.py+++ b/kornia/geometry/transform/crop/crop3d.py@@ -84,11 +84,11 @@ def crop_and_resize3d([45.0000, 47.0000]]]]])"""if not isinstance(tensor, (torch.Tensor)):- raise TypeError("Input tensor type is not a torch.Tensor. Got {}".format(type(tensor)))+ raise TypeError(f"Input tensor type is not a torch.Tensor. Got {type(tensor)}")if not isinstance(boxes, (torch.Tensor)):- raise TypeError("Input boxes type is not a torch.Tensor. Got {}".format(type(boxes)))+ raise TypeError(f"Input boxes type is not a torch.Tensor. Got {type(boxes)}")if not isinstance(size, (tuple, list)) and len(size) != 3:- raise ValueError("Input size must be a tuple/list of length 3. Got {}".format(size))+ raise ValueError(f"Input size must be a tuple/list of length 3. Got {size}")if len(tensor.shape) != 5:raise AssertionError(f"Only tensor with shape (B, C, D, H, W) supported. Got {tensor.shape}.")# unpack input data@@ -167,13 +167,13 @@ def center_crop3d([41.0000, 42.0000]]]]])"""if not isinstance(tensor, (torch.Tensor)):- raise TypeError("Input tensor type is not a torch.Tensor. Got {}".format(type(tensor)))+ raise TypeError(f"Input tensor type is not a torch.Tensor. Got {type(tensor)}")if len(tensor.shape) != 5:raise AssertionError(f"Only tensor with shape (B, C, D, H, W) supported. Got {tensor.shape}.")if not isinstance(size, (tuple, list)) and len(size) == 3:- raise ValueError("Input size must be a tuple/list of length 3. Got {}".format(size))+ raise ValueError(f"Input size must be a tuple/list of length 3. Got {size}")# unpack input sizesdst_d, dst_h, dst_w = sizediff --git a/kornia/geometry/transform/homography_warper.py b/kornia/geometry/transform/homography_warper.pyindex dab3d68f1..dea9f5687 100644--- a/kornia/geometry/transform/homography_warper.py+++ b/kornia/geometry/transform/homography_warper.py@@ -192,7 +192,7 @@ class HomographyWarper(nn.Module):normalized_coordinates: bool = True,align_corners: bool = False,) -> None:- super(HomographyWarper, self).__init__()+ super().__init__()self.width: int = widthself.height: int = heightself.mode: str = mode@@ -366,9 +366,7 @@ def normalize_homography(check_is_tensor(dst_pix_trans_src_pix)if not (len(dst_pix_trans_src_pix.shape) == 3 or dst_pix_trans_src_pix.shape[-2:] == (3, 3)):- raise ValueError(- "Input dst_pix_trans_src_pix must be a Bx3x3 tensor. Got {}".format(dst_pix_trans_src_pix.shape)- )+ raise ValueError(f"Input dst_pix_trans_src_pix must be a Bx3x3 tensor. Got {dst_pix_trans_src_pix.shape}")# source and destination sizessrc_h, src_w = dsize_src@@ -402,9 +400,7 @@ def denormalize_homography(check_is_tensor(dst_pix_trans_src_pix)if not (len(dst_pix_trans_src_pix.shape) == 3 or dst_pix_trans_src_pix.shape[-2:] == (3, 3)):- raise ValueError(- "Input dst_pix_trans_src_pix must be a Bx3x3 tensor. Got {}".format(dst_pix_trans_src_pix.shape)- )+ raise ValueError(f"Input dst_pix_trans_src_pix must be a Bx3x3 tensor. Got {dst_pix_trans_src_pix.shape}")# source and destination sizessrc_h, src_w = dsize_src@@ -440,9 +436,7 @@ def normalize_homography3d(check_is_tensor(dst_pix_trans_src_pix)if not (len(dst_pix_trans_src_pix.shape) == 3 or dst_pix_trans_src_pix.shape[-2:] == (4, 4)):- raise ValueError(- "Input dst_pix_trans_src_pix must be a Bx3x3 tensor. Got {}".format(dst_pix_trans_src_pix.shape)- )+ raise ValueError(f"Input dst_pix_trans_src_pix must be a Bx3x3 tensor. Got {dst_pix_trans_src_pix.shape}")# source and destination sizessrc_d, src_h, src_w = dsize_srcdiff --git a/kornia/geometry/transform/imgwarp.py b/kornia/geometry/transform/imgwarp.pyindex bcfbd43b6..734bc9139 100644--- a/kornia/geometry/transform/imgwarp.py+++ b/kornia/geometry/transform/imgwarp.py@@ -78,16 +78,16 @@ def warp_perspective(latest/warp_perspective.html>`_."""if not isinstance(src, torch.Tensor):- raise TypeError("Input src type is not a torch.Tensor. Got {}".format(type(src)))+ raise TypeError(f"Input src type is not a torch.Tensor. Got {type(src)}")if not isinstance(M, torch.Tensor):- raise TypeError("Input M type is not a torch.Tensor. Got {}".format(type(M)))+ raise TypeError(f"Input M type is not a torch.Tensor. Got {type(M)}")if not len(src.shape) == 4:- raise ValueError("Input src must be a BxCxHxW tensor. Got {}".format(src.shape))+ raise ValueError(f"Input src must be a BxCxHxW tensor. Got {src.shape}")if not (len(M.shape) == 3 and M.shape[-2:] == (3, 3)):- raise ValueError("Input M must be a Bx3x3 tensor. Got {}".format(M.shape))+ raise ValueError(f"Input M must be a Bx3x3 tensor. Got {M.shape}")# TODO: remove the statement below in kornia v0.6if align_corners is None:@@ -163,16 +163,16 @@ def warp_affine(torch.Size([1, 4, 4, 2])"""if not isinstance(src, torch.Tensor):- raise TypeError("Input src type is not a torch.Tensor. Got {}".format(type(src)))+ raise TypeError(f"Input src type is not a torch.Tensor. Got {type(src)}")if not isinstance(M, torch.Tensor):- raise TypeError("Input M type is not a torch.Tensor. Got {}".format(type(M)))+ raise TypeError(f"Input M type is not a torch.Tensor. Got {type(M)}")if not len(src.shape) == 4:- raise ValueError("Input src must be a BxCxHxW tensor. Got {}".format(src.shape))+ raise ValueError(f"Input src must be a BxCxHxW tensor. Got {src.shape}")if not (len(M.shape) == 3 or M.shape[-2:] == (2, 3)):- raise ValueError("Input M must be a Bx2x3 tensor. Got {}".format(M.shape))+ raise ValueError(f"Input M must be a Bx2x3 tensor. Got {M.shape}")# TODO: remove the statement below in kornia v0.6if align_corners is None:@@ -237,21 +237,19 @@ def get_perspective_transform(src, dst):This function is often used in conjuntion with :func:`warp_perspective`."""if not isinstance(src, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(src)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(src)}")if not isinstance(dst, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(dst)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(dst)}")if not src.shape[-2:] == (4, 2):- raise ValueError("Inputs must be a Bx4x2 tensor. Got {}".format(src.shape))+ raise ValueError(f"Inputs must be a Bx4x2 tensor. Got {src.shape}")if not src.shape == dst.shape:- raise ValueError("Inputs must have the same shape. Got {}".format(dst.shape))+ raise ValueError(f"Inputs must have the same shape. Got {dst.shape}")if not (src.shape[0] == dst.shape[0]):- raise ValueError(- "Inputs must have same batch size dimension. Expect {} but got {}".format(src.shape, dst.shape)- )+ raise ValueError(f"Inputs must have same batch size dimension. Expect {src.shape} but got {dst.shape}")# we build matrix A by using only 4 point correspondence. The linear# system is solved with the least square method, so here@@ -373,22 +371,22 @@ def get_rotation_matrix2d(center: torch.Tensor, angle: torch.Tensor, scale: torcThis function is often used in conjuntion with :func:`warp_affine`."""if not isinstance(center, torch.Tensor):- raise TypeError("Input center type is not a torch.Tensor. Got {}".format(type(center)))+ raise TypeError(f"Input center type is not a torch.Tensor. Got {type(center)}")if not isinstance(angle, torch.Tensor):- raise TypeError("Input angle type is not a torch.Tensor. Got {}".format(type(angle)))+ raise TypeError(f"Input angle type is not a torch.Tensor. Got {type(angle)}")if not isinstance(scale, torch.Tensor):- raise TypeError("Input scale type is not a torch.Tensor. Got {}".format(type(scale)))+ raise TypeError(f"Input scale type is not a torch.Tensor. Got {type(scale)}")if not (len(center.shape) == 2 and center.shape[1] == 2):- raise ValueError("Input center must be a Bx2 tensor. Got {}".format(center.shape))+ raise ValueError(f"Input center must be a Bx2 tensor. Got {center.shape}")if not len(angle.shape) == 1:- raise ValueError("Input angle must be a B tensor. Got {}".format(angle.shape))+ raise ValueError(f"Input angle must be a B tensor. Got {angle.shape}")if not (len(scale.shape) == 2 and scale.shape[1] == 2):- raise ValueError("Input scale must be a Bx2 tensor. Got {}".format(scale.shape))+ raise ValueError(f"Input scale must be a Bx2 tensor. Got {scale.shape}")if not (center.shape[0] == angle.shape[0] == scale.shape[0]):raise ValueError(@@ -479,13 +477,13 @@ def remap(This function is often used in conjuntion with :func:`kornia.utils.create_meshgrid`."""if not isinstance(tensor, torch.Tensor):- raise TypeError("Input tensor type is not a torch.Tensor. Got {}".format(type(tensor)))+ raise TypeError(f"Input tensor type is not a torch.Tensor. Got {type(tensor)}")if not isinstance(map_x, torch.Tensor):- raise TypeError("Input map_x type is not a torch.Tensor. Got {}".format(type(map_x)))+ raise TypeError(f"Input map_x type is not a torch.Tensor. Got {type(map_x)}")if not isinstance(map_y, torch.Tensor):- raise TypeError("Input map_y type is not a torch.Tensor. Got {}".format(type(map_y)))+ raise TypeError(f"Input map_y type is not a torch.Tensor. Got {type(map_y)}")if not tensor.shape[-2:] == map_x.shape[-2:] == map_y.shape[-2:]:raise ValueError("Inputs last two dimensions must match.")@@ -534,10 +532,10 @@ def invert_affine_transform(matrix: torch.Tensor) -> torch.Tensor:This function is often used in conjuntion with :func:`warp_affine`."""if not isinstance(matrix, torch.Tensor):- raise TypeError("Input matrix type is not a torch.Tensor. Got {}".format(type(matrix)))+ raise TypeError(f"Input matrix type is not a torch.Tensor. Got {type(matrix)}")if not (len(matrix.shape) == 3 and matrix.shape[-2:] == (2, 3)):- raise ValueError("Input matrix must be a Bx2x3 tensor. Got {}".format(matrix.shape))+ raise ValueError(f"Input matrix must be a Bx2x3 tensor. Got {matrix.shape}")matrix_tmp: torch.Tensor = convert_affinematrix_to_homography(matrix)matrix_inv: torch.Tensor = torch.inverse(matrix_tmp)diff --git a/kornia/geometry/transform/projwarp.py b/kornia/geometry/transform/projwarp.pyindex 88a96166b..8e1803e01 100644--- a/kornia/geometry/transform/projwarp.py+++ b/kornia/geometry/transform/projwarp.py@@ -234,21 +234,19 @@ def get_perspective_transform3d(src: torch.Tensor, dst: torch.Tensor) -> torch.TThis function is often used in conjuntion with :func:`warp_perspective3d`."""if not isinstance(src, (torch.Tensor)):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(src)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(src)}")if not isinstance(dst, (torch.Tensor)):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(dst)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(dst)}")if not src.shape[-2:] == (8, 3):- raise ValueError("Inputs must be a Bx8x3 tensor. Got {}".format(src.shape))+ raise ValueError(f"Inputs must be a Bx8x3 tensor. Got {src.shape}")if not src.shape == dst.shape:- raise ValueError("Inputs must have the same shape. Got {}".format(dst.shape))+ raise ValueError(f"Inputs must have the same shape. Got {dst.shape}")if not (src.shape[0] == dst.shape[0]):- raise ValueError(- "Inputs must have same batch size dimension. Expect {} but got {}".format(src.shape, dst.shape)- )+ raise ValueError(f"Inputs must have same batch size dimension. Expect {src.shape} but got {dst.shape}")if not (src.device == dst.device and src.dtype == dst.dtype):raise AssertionError(@@ -417,10 +415,10 @@ def warp_perspective3d(check_is_tensor(M)if not len(src.shape) == 5:- raise ValueError("Input src must be a BxCxDxHxW tensor. Got {}".format(src.shape))+ raise ValueError(f"Input src must be a BxCxDxHxW tensor. Got {src.shape}")if not (len(M.shape) == 3 or M.shape[-2:] == (4, 4)):- raise ValueError("Input M must be a Bx4x4 tensor. Got {}".format(M.shape))+ raise ValueError(f"Input M must be a Bx4x4 tensor. Got {M.shape}")# launches the warperd, h, w = src.shape[-3:]diff --git a/kornia/geometry/transform/pyramid.py b/kornia/geometry/transform/pyramid.pyindex 851751db6..ab8e3ac84 100644--- a/kornia/geometry/transform/pyramid.py+++ b/kornia/geometry/transform/pyramid.py@@ -51,7 +51,7 @@ class PyrDown(nn.Module):"""def __init__(self, border_type: str = 'reflect', align_corners: bool = False) -> None:- super(PyrDown, self).__init__()+ super().__init__()self.border_type: str = border_typeself.align_corners: bool = align_corners@@ -81,7 +81,7 @@ class PyrUp(nn.Module):"""def __init__(self, border_type: str = 'reflect', align_corners: bool = False):- super(PyrUp, self).__init__()+ super().__init__()self.border_type: str = border_typeself.align_corners: bool = align_corners@@ -117,7 +117,7 @@ class ScalePyramid(nn.Module):"""def __init__(self, n_levels: int = 3, init_sigma: float = 1.6, min_size: int = 15, double_image: bool = False):- super(ScalePyramid, self).__init__()+ super().__init__()# 3 extra levels are needed for DoG nms.self.n_levels = n_levelsself.extra_levels: int = 3diff --git a/kornia/geometry/warp/depth_warper.py b/kornia/geometry/warp/depth_warper.pyindex 194ed27d2..2347919bb 100644--- a/kornia/geometry/warp/depth_warper.py+++ b/kornia/geometry/warp/depth_warper.py@@ -21,7 +21,7 @@ class DepthWarper(_DepthWarper):padding_mode: str = 'zeros',align_corners: bool = True,):- super(DepthWarper, self).__init__(+ super().__init__(pinhole_dst=pinhole_dst,height=height,width=width,diff --git a/kornia/geometry/warp/homography_warper.py b/kornia/geometry/warp/homography_warper.pyindex 87869e521..3c1d93835 100644--- a/kornia/geometry/warp/homography_warper.py+++ b/kornia/geometry/warp/homography_warper.py@@ -94,7 +94,7 @@ class HomographyWarper(HMW.HomographyWarper):normalized_coordinates: bool = True,align_corners: bool = False,) -> None:- super(HomographyWarper, self).__init__(height, width, mode, padding_mode, normalized_coordinates, align_corners)+ super().__init__(height, width, mode, padding_mode, normalized_coordinates, align_corners)warnings.warn("`HomographyWarper` is deprecated and will be removed > 0.6.0. ""Please use `kornia.geometry.transform.HomographyWarper instead.`",diff --git a/kornia/losses/depth_smooth.py b/kornia/losses/depth_smooth.pyindex d76d61822..ba97da229 100644--- a/kornia/losses/depth_smooth.py+++ b/kornia/losses/depth_smooth.py@@ -39,27 +39,25 @@ def inverse_depth_smoothness_loss(idepth: torch.Tensor, image: torch.Tensor) ->>>> loss = inverse_depth_smoothness_loss(idepth, image)"""if not isinstance(idepth, torch.Tensor):- raise TypeError("Input idepth type is not a torch.Tensor. Got {}".format(type(idepth)))+ raise TypeError(f"Input idepth type is not a torch.Tensor. Got {type(idepth)}")if not isinstance(image, torch.Tensor):- raise TypeError("Input image type is not a torch.Tensor. Got {}".format(type(image)))+ raise TypeError(f"Input image type is not a torch.Tensor. Got {type(image)}")if not len(idepth.shape) == 4:- raise ValueError("Invalid idepth shape, we expect BxCxHxW. Got: {}".format(idepth.shape))+ raise ValueError(f"Invalid idepth shape, we expect BxCxHxW. Got: {idepth.shape}")if not len(image.shape) == 4:- raise ValueError("Invalid image shape, we expect BxCxHxW. Got: {}".format(image.shape))+ raise ValueError(f"Invalid image shape, we expect BxCxHxW. Got: {image.shape}")if not idepth.shape[-2:] == image.shape[-2:]:- raise ValueError("idepth and image shapes must be the same. Got: {} and {}".format(idepth.shape, image.shape))+ raise ValueError(f"idepth and image shapes must be the same. Got: {idepth.shape} and {image.shape}")if not idepth.device == image.device:- raise ValueError(- "idepth and image must be in the same device. Got: {} and {}".format(idepth.device, image.device)- )+ raise ValueError(f"idepth and image must be in the same device. Got: {idepth.device} and {image.device}")if not idepth.dtype == image.dtype:- raise ValueError("idepth and image must be in the same dtype. Got: {} and {}".format(idepth.dtype, image.dtype))+ raise ValueError(f"idepth and image must be in the same dtype. Got: {idepth.dtype} and {image.dtype}")# compute the gradientsidepth_dx: torch.Tensor = _gradient_x(idepth)diff --git a/kornia/losses/dice.py b/kornia/losses/dice.pyindex e93da37a9..f5a3ac0f6 100644--- a/kornia/losses/dice.py+++ b/kornia/losses/dice.py@@ -47,18 +47,16 @@ def dice_loss(input: torch.Tensor, target: torch.Tensor, eps: float = 1e-8) -> t>>> output.backward()"""if not isinstance(input, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(input)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(input)}")if not len(input.shape) == 4:- raise ValueError("Invalid input shape, we expect BxNxHxW. Got: {}".format(input.shape))+ raise ValueError(f"Invalid input shape, we expect BxNxHxW. Got: {input.shape}")if not input.shape[-2:] == target.shape[-2:]:- raise ValueError("input and target shapes must be the same. Got: {} and {}".format(input.shape, target.shape))+ raise ValueError(f"input and target shapes must be the same. Got: {input.shape} and {target.shape}")if not input.device == target.device:- raise ValueError(- "input and target must be in the same device. Got: {} and {}".format(input.device, target.device)- )+ raise ValueError(f"input and target must be in the same device. Got: {input.device} and {target.device}")# compute softmax over the classes axisinput_soft: torch.Tensor = F.softmax(input, dim=1)@@ -116,7 +114,7 @@ class DiceLoss(nn.Module):"""def __init__(self, eps: float = 1e-8) -> None:- super(DiceLoss, self).__init__()+ super().__init__()self.eps: float = epsdef forward(self, input: torch.Tensor, target: torch.Tensor) -> torch.Tensor:diff --git a/kornia/losses/focal.py b/kornia/losses/focal.pyindex 61f44fbf6..b135c5c80 100644--- a/kornia/losses/focal.py+++ b/kornia/losses/focal.py@@ -50,25 +50,21 @@ def focal_loss(>>> output.backward()"""if not isinstance(input, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(input)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(input)}")if not len(input.shape) >= 2:- raise ValueError("Invalid input shape, we expect BxCx*. Got: {}".format(input.shape))+ raise ValueError(f"Invalid input shape, we expect BxCx*. Got: {input.shape}")if input.size(0) != target.size(0):- raise ValueError(- 'Expected input batch_size ({}) to match target batch_size ({}).'.format(input.size(0), target.size(0))- )+ raise ValueError(f'Expected input batch_size ({input.size(0)}) to match target batch_size ({target.size(0)}).')n = input.size(0)out_size = (n,) + input.size()[2:]if target.size()[1:] != input.size()[2:]:- raise ValueError('Expected target size {}, got {}'.format(out_size, target.size()))+ raise ValueError(f'Expected target size {out_size}, got {target.size()}')if not input.device == target.device:- raise ValueError(- "input and target must be in the same device. Got: {} and {}".format(input.device, target.device)- )+ raise ValueError(f"input and target must be in the same device. Got: {input.device} and {target.device}")# compute softmax over the classes axisinput_soft: torch.Tensor = F.softmax(input, dim=1) + eps@@ -89,7 +85,7 @@ def focal_loss(elif reduction == 'sum':loss = torch.sum(loss_tmp)else:- raise NotImplementedError("Invalid reduction mode: {}".format(reduction))+ raise NotImplementedError(f"Invalid reduction mode: {reduction}")return loss@@ -131,7 +127,7 @@ class FocalLoss(nn.Module):"""def __init__(self, alpha: float, gamma: float = 2.0, reduction: str = 'none', eps: float = 1e-8) -> None:- super(FocalLoss, self).__init__()+ super().__init__()self.alpha: float = alphaself.gamma: float = gammaself.reduction: str = reduction@@ -183,15 +179,13 @@ def binary_focal_loss_with_logits("""if not isinstance(input, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(input)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(input)}")if not len(input.shape) >= 2:- raise ValueError("Invalid input shape, we expect BxCx*. Got: {}".format(input.shape))+ raise ValueError(f"Invalid input shape, we expect BxCx*. Got: {input.shape}")if input.size(0) != target.size(0):- raise ValueError(- 'Expected input batch_size ({}) to match target batch_size ({}).'.format(input.size(0), target.size(0))- )+ raise ValueError(f'Expected input batch_size ({input.size(0)}) to match target batch_size ({target.size(0)}).')probs = torch.sigmoid(input)target = target.unsqueeze(dim=1)@@ -208,7 +202,7 @@ def binary_focal_loss_with_logits(elif reduction == 'sum':loss = torch.sum(loss_tmp)else:- raise NotImplementedError("Invalid reduction mode: {}".format(reduction))+ raise NotImplementedError(f"Invalid reduction mode: {reduction}")return loss@@ -248,7 +242,7 @@ class BinaryFocalLossWithLogits(nn.Module):"""def __init__(self, alpha: float, gamma: float = 2.0, reduction: str = 'none') -> None:- super(BinaryFocalLossWithLogits, self).__init__()+ super().__init__()self.alpha: float = alphaself.gamma: float = gammaself.reduction: str = reductiondiff --git a/kornia/losses/psnr.py b/kornia/losses/psnr.pyindex 77419200d..a6400cb6a 100644--- a/kornia/losses/psnr.py+++ b/kornia/losses/psnr.py@@ -105,7 +105,7 @@ class PSNRLoss(nn.Module):"""def __init__(self, max_val: float) -> None:- super(PSNRLoss, self).__init__()+ super().__init__()self.max_val: float = max_valdef forward(self, input: torch.Tensor, target: torch.Tensor) -> torch.Tensor:diff --git a/kornia/losses/ssim.py b/kornia/losses/ssim.pyindex 761806078..16a6f5afa 100644--- a/kornia/losses/ssim.py+++ b/kornia/losses/ssim.py@@ -40,22 +40,22 @@ def ssim(>>> ssim_map = ssim(input1, input2, 5) # 1x4x5x5"""if not isinstance(img1, torch.Tensor):- raise TypeError("Input img1 type is not a torch.Tensor. Got {}".format(type(img1)))+ raise TypeError(f"Input img1 type is not a torch.Tensor. Got {type(img1)}")if not isinstance(img2, torch.Tensor):- raise TypeError("Input img2 type is not a torch.Tensor. Got {}".format(type(img2)))+ raise TypeError(f"Input img2 type is not a torch.Tensor. Got {type(img2)}")if not isinstance(max_val, float):raise TypeError(f"Input max_val type is not a float. Got {type(max_val)}")if not len(img1.shape) == 4:- raise ValueError("Invalid img1 shape, we expect BxCxHxW. Got: {}".format(img1.shape))+ raise ValueError(f"Invalid img1 shape, we expect BxCxHxW. Got: {img1.shape}")if not len(img2.shape) == 4:- raise ValueError("Invalid img2 shape, we expect BxCxHxW. Got: {}".format(img2.shape))+ raise ValueError(f"Invalid img2 shape, we expect BxCxHxW. Got: {img2.shape}")if not img1.shape == img2.shape:- raise ValueError("img1 and img2 shapes must be the same. Got: {} and {}".format(img1.shape, img2.shape))+ raise ValueError(f"img1 and img2 shapes must be the same. Got: {img1.shape} and {img2.shape}")# prepare kernelkernel: torch.Tensor = get_gaussian_kernel2d((window_size, window_size), (1.5, 1.5)).unsqueeze(0)@@ -172,7 +172,7 @@ class SSIM(nn.Module):"""def __init__(self, window_size: int, max_val: float = 1.0, eps: float = 1e-12) -> None:- super(SSIM, self).__init__()+ super().__init__()self.window_size: int = window_sizeself.max_val: float = max_valself.eps = eps@@ -212,7 +212,7 @@ class SSIMLoss(nn.Module):"""def __init__(self, window_size: int, max_val: float = 1.0, eps: float = 1e-12, reduction: str = 'mean') -> None:- super(SSIMLoss, self).__init__()+ super().__init__()self.window_size: int = window_sizeself.max_val: float = max_valself.eps: float = epsdiff --git a/kornia/losses/tversky.py b/kornia/losses/tversky.pyindex 46fc96a72..ae73fb39f 100644--- a/kornia/losses/tversky.py+++ b/kornia/losses/tversky.py@@ -50,18 +50,16 @@ def tversky_loss(>>> output.backward()"""if not isinstance(input, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(input)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(input)}")if not len(input.shape) == 4:- raise ValueError("Invalid input shape, we expect BxNxHxW. Got: {}".format(input.shape))+ raise ValueError(f"Invalid input shape, we expect BxNxHxW. Got: {input.shape}")if not input.shape[-2:] == target.shape[-2:]:- raise ValueError("input and target shapes must be the same. Got: {} and {}".format(input.shape, input.shape))+ raise ValueError(f"input and target shapes must be the same. Got: {input.shape} and {input.shape}")if not input.device == target.device:- raise ValueError(- "input and target must be in the same device. Got: {} and {}".format(input.device, target.device)- )+ raise ValueError(f"input and target must be in the same device. Got: {input.device} and {target.device}")# compute softmax over the classes axisinput_soft: torch.Tensor = F.softmax(input, dim=1)@@ -123,7 +121,7 @@ class TverskyLoss(nn.Module):"""def __init__(self, alpha: float, beta: float, eps: float = 1e-8) -> None:- super(TverskyLoss, self).__init__()+ super().__init__()self.alpha: float = alphaself.beta: float = betaself.eps: float = epsdiff --git a/kornia/morphology/morphology.py b/kornia/morphology/morphology.pyindex ee4a74cac..6e798cf6b 100644--- a/kornia/morphology/morphology.py+++ b/kornia/morphology/morphology.py@@ -48,16 +48,16 @@ def dilation("""if not isinstance(tensor, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(tensor)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(tensor)}")if len(tensor.shape) != 4:- raise ValueError("Input size must have 4 dimensions. Got {}".format(tensor.dim()))+ raise ValueError(f"Input size must have 4 dimensions. Got {tensor.dim()}")if not isinstance(kernel, torch.Tensor):- raise TypeError("Kernel type is not a torch.Tensor. Got {}".format(type(kernel)))+ raise TypeError(f"Kernel type is not a torch.Tensor. Got {type(kernel)}")if len(kernel.shape) != 2:- raise ValueError("Kernel size must have 2 dimensions. Got {}".format(kernel.dim()))+ raise ValueError(f"Kernel size must have 2 dimensions. Got {kernel.dim()}")# originse_h, se_w = kernel.shape@@ -130,16 +130,16 @@ def erosion("""if not isinstance(tensor, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(tensor)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(tensor)}")if len(tensor.shape) != 4:- raise ValueError("Input size must have 4 dimensions. Got {}".format(tensor.dim()))+ raise ValueError(f"Input size must have 4 dimensions. Got {tensor.dim()}")if not isinstance(kernel, torch.Tensor):- raise TypeError("Kernel type is not a torch.Tensor. Got {}".format(type(kernel)))+ raise TypeError(f"Kernel type is not a torch.Tensor. Got {type(kernel)}")if len(kernel.shape) != 2:- raise ValueError("Kernel size must have 2 dimensions. Got {}".format(kernel.dim()))+ raise ValueError(f"Kernel size must have 2 dimensions. Got {kernel.dim()}")# originse_h, se_w = kernel.shape@@ -212,16 +212,16 @@ def opening("""if not isinstance(tensor, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(tensor)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(tensor)}")if len(tensor.shape) != 4:- raise ValueError("Input size must have 4 dimensions. Got {}".format(tensor.dim()))+ raise ValueError(f"Input size must have 4 dimensions. Got {tensor.dim()}")if not isinstance(kernel, torch.Tensor):- raise TypeError("Kernel type is not a torch.Tensor. Got {}".format(type(kernel)))+ raise TypeError(f"Kernel type is not a torch.Tensor. Got {type(kernel)}")if len(kernel.shape) != 2:- raise ValueError("Kernel size must have 2 dimensions. Got {}".format(kernel.dim()))+ raise ValueError(f"Kernel size must have 2 dimensions. Got {kernel.dim()}")return dilation(erosion(@@ -286,16 +286,16 @@ def closing("""if not isinstance(tensor, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(tensor)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(tensor)}")if len(tensor.shape) != 4:- raise ValueError("Input size must have 4 dimensions. Got {}".format(tensor.dim()))+ raise ValueError(f"Input size must have 4 dimensions. Got {tensor.dim()}")if not isinstance(kernel, torch.Tensor):- raise TypeError("Kernel type is not a torch.Tensor. Got {}".format(type(kernel)))+ raise TypeError(f"Kernel type is not a torch.Tensor. Got {type(kernel)}")if len(kernel.shape) != 2:- raise ValueError("Kernel size must have 2 dimensions. Got {}".format(kernel.dim()))+ raise ValueError(f"Kernel size must have 2 dimensions. Got {kernel.dim()}")return erosion(dilation(@@ -427,16 +427,16 @@ def top_hat("""if not isinstance(tensor, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(tensor)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(tensor)}")if len(tensor.shape) != 4:- raise ValueError("Input size must have 4 dimensions. Got {}".format(tensor.dim()))+ raise ValueError(f"Input size must have 4 dimensions. Got {tensor.dim()}")if not isinstance(kernel, torch.Tensor):- raise TypeError("Kernel type is not a torch.Tensor. Got {}".format(type(kernel)))+ raise TypeError(f"Kernel type is not a torch.Tensor. Got {type(kernel)}")if len(kernel.shape) != 2:- raise ValueError("Kernel size must have 2 dimensions. Got {}".format(kernel.dim()))+ raise ValueError(f"Kernel size must have 2 dimensions. Got {kernel.dim()}")return tensor - opening(tensor,@@ -496,16 +496,16 @@ def bottom_hat("""if not isinstance(tensor, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(tensor)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(tensor)}")if len(tensor.shape) != 4:- raise ValueError("Input size must have 4 dimensions. Got {}".format(tensor.dim()))+ raise ValueError(f"Input size must have 4 dimensions. Got {tensor.dim()}")if not isinstance(kernel, torch.Tensor):- raise TypeError("Kernel type is not a torch.Tensor. Got {}".format(type(kernel)))+ raise TypeError(f"Kernel type is not a torch.Tensor. Got {type(kernel)}")if len(kernel.shape) != 2:- raise ValueError("Kernel size must have 2 dimensions. Got {}".format(kernel.dim()))+ raise ValueError(f"Kernel size must have 2 dimensions. Got {kernel.dim()}")return (closing(diff --git a/kornia/testing/__init__.py b/kornia/testing/__init__.pyindex f8db05c43..8f41173f9 100644--- a/kornia/testing/__init__.py+++ b/kornia/testing/__init__.py@@ -50,7 +50,7 @@ def compute_patch_error(x, y, h, w):def check_is_tensor(obj):"""Checks whether the supplied object is a tensor."""if not isinstance(obj, torch.Tensor):- raise TypeError("Input type is not a torch.Tensor. Got {}".format(type(obj)))+ raise TypeError(f"Input type is not a torch.Tensor. Got {type(obj)}")def create_rectified_fundamental_matrix(batch_size):diff --git a/kornia/utils/image.py b/kornia/utils/image.pyindex 7dd7b8850..5f8fd5274 100644--- a/kornia/utils/image.py+++ b/kornia/utils/image.py@@ -38,7 +38,7 @@ def image_to_tensor(image: "np.ndarray", keepdim: bool = True) -> torch.Tensor:tensor = tensor.permute(0, 3, 1, 2)keepdim = True # no need to unsqueezeelse:- raise ValueError("Cannot process image with shape {}".format(input_shape))+ raise ValueError(f"Cannot process image with shape {input_shape}")return tensor.unsqueeze(0) if not keepdim else tensordiff --git a/kornia/utils/one_hot.py b/kornia/utils/one_hot.pyindex 603c94d37..76dbc2a04 100644--- a/kornia/utils/one_hot.py+++ b/kornia/utils/one_hot.py@@ -36,10 +36,10 @@ def one_hot("""if not isinstance(labels, torch.Tensor):- raise TypeError("Input labels type is not a torch.Tensor. Got {}".format(type(labels)))+ raise TypeError(f"Input labels type is not a torch.Tensor. Got {type(labels)}")if not labels.dtype == torch.int64:- raise ValueError("labels must be of the same dtype torch.int64. Got: {}".format(labels.dtype))+ raise ValueError(f"labels must be of the same dtype torch.int64. Got: {labels.dtype}")if num_classes < 1:raise ValueError("The number of classes must be bigger than one." " Got: {}".format(num_classes))diff --git a/kornia/utils/pointcloud_io.py b/kornia/utils/pointcloud_io.pyindex 09f770892..8a4af8258 100644--- a/kornia/utils/pointcloud_io.py+++ b/kornia/utils/pointcloud_io.py@@ -17,7 +17,7 @@ def save_pointcloud_ply(filename: str, pointcloud: torch.Tensor) -> None:raise TypeError("Input filename must be a string in with the .ply " "extension. Got {}".format(filename))if not torch.is_tensor(pointcloud):- raise TypeError("Input pointcloud type is not a torch.Tensor. Got {}".format(type(pointcloud)))+ raise TypeError(f"Input pointcloud type is not a torch.Tensor. Got {type(pointcloud)}")if not len(pointcloud.shape) == 3 and pointcloud.shape[-1] == 3:raise TypeError("Input pointcloud must be in the following shape " "HxWx3. Got {}.".format(pointcloud.shape))@@ -35,7 +35,7 @@ def save_pointcloud_ply(filename: str, pointcloud: torch.Tensor) -> None:x: float = xyz[0].item()y: float = xyz[1].item()z: float = xyz[2].item()- data_str += '{0} {1} {2}\n'.format(x, y, z)+ data_str += f'{x} {y} {z}\n'f.write("ply\n")f.write("format ascii 1.0\n")@@ -65,9 +65,9 @@ def load_pointcloud_ply(filename: str, header_size: int = 8) -> torch.Tensor:if not os.path.isfile(filename):raise ValueError("Input filename is not an existing file.")if not (isinstance(header_size, int) and header_size > 0):- raise TypeError("Input header_size must be a positive integer. Got {}.".format(header_size))+ raise TypeError(f"Input header_size must be a positive integer. Got {header_size}.")# open the file and populate tensor- with open(filename, 'r') as f:+ with open(filename) as f:points = []# skip headerdiff --git a/setup.py b/setup.pyindex 040f0805f..a46092451 100644--- a/setup.py+++ b/setup.py@@ -71,29 +71,29 @@ elif os.getenv('KORNIA_RELEASE'):passelif sha != 'Unknown':version += '+' + sha[:7]-print("Building wheel {}-{}".format(package_name, version))+print(f"Building wheel {package_name}-{version}")def write_version_file():version_path = os.path.join(cwd, 'kornia', 'version.py')with open(version_path, 'w') as f:- f.write("__version__ = '{}'\n".format(version))- f.write("git_version = {}\n".format(repr(sha)))+ f.write(f"__version__ = '{version}'\n")+ f.write(f"git_version = {repr(sha)}\n")def read(*names, **kwargs):- with io.open(os.path.join(os.path.dirname(__file__), *names), encoding=kwargs.get("encoding", "utf8")) as fp:+ with open(os.path.join(os.path.dirname(__file__), *names), encoding=kwargs.get("encoding", "utf8")) as fp:return fp.read()# open readme file and set long description-with open("README.md", "r", encoding="utf-8") as fh:+with open("README.md", encoding="utf-8") as fh:long_description = fh.read()class clean(distutils.command.clean.clean):def run(self):- with open('.gitignore', 'r') as f:+ with open('.gitignore') as f:ignores = f.read()for wildcard in filter(None, ignores.split('\n')):for filename in glob.glob(wildcard):diff --git a/test/geometry/epipolar/test_essential.py b/test/geometry/epipolar/test_essential.pyindex 356e41568..6d5fd01eb 100644--- a/test/geometry/epipolar/test_essential.py+++ b/test/geometry/epipolar/test_essential.py@@ -224,7 +224,7 @@ class TestMotionFromEssential:Rs, ts = epi.motion_from_essential(E_mat)rot_error = (Rs - R).abs().sum((-2, -1))- vec_error = (ts - t).abs().sum((-1))+ vec_error = (ts - t).abs().sum(-1)rtol: float = 1e-4assert (rot_error < rtol).any() & (vec_error < rtol).any()diff --git a/test/integration/test_focal.py b/test/integration/test_focal.pyindex 1bb08cddd..c9d956f2a 100644--- a/test/integration/test_focal.py+++ b/test/integration/test_focal.py@@ -52,7 +52,7 @@ class TestIntegrationFocalLoss:sample = self.generate_sample(target).to(device)output = m(sample)loss = criterion(output, target.to(device))- logger.debug("Loss: {}".format(loss.item()))+ logger.debug(f"Loss: {loss.item()}")optimizer.zero_grad()loss.backward()@@ -60,7 +60,7 @@ class TestIntegrationFocalLoss:sample = self.generate_sample(target).to(device)output_argmax = torch.argmax(m(sample), dim=1)- logger.debug("Output argmax: \n{}".format(output_argmax))+ logger.debug(f"Output argmax: \n{output_argmax}")# TODO(edgar): replace by IoU or find a more stable solution# for this test. The issue is that depending ondiff --git a/test/integration/test_soft_argmax2d.py b/test/integration/test_soft_argmax2d.pyindex 995d4453c..fcd423c6d 100644--- a/test/integration/test_soft_argmax2d.py+++ b/test/integration/test_soft_argmax2d.py@@ -52,7 +52,7 @@ class TestIntegrationSoftArgmax2d:sample = self.generate_sample(target).to(device)pred = soft_argmax2d(temperature * x)loss = criterion(pred, sample)- logger.debug("Loss: {0:.3f} Pred: {1}".format(loss.item(), pred))+ logger.debug(f"Loss: {loss.item():.3f} Pred: {pred}")optimizer.zero_grad()loss.backward()