π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
[pre-commit.ci] pre-commit suggestions (#3611)
pre-commit-ci[bot]0e5db23e1bd0
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlindex fb3c4a38f..9f017a1fc 100644--- a/.pre-commit-config.yaml+++ b/.pre-commit-config.yaml@@ -21,14 +21,14 @@ repos:exclude: ^$|.devcontainer- repo: https://github.com/astral-sh/ruff-pre-commit- rev: v0.15.1+ rev: v0.16.1hooks:- id: ruff-checkargs: [--fix, --exit-non-zero-on-fix]- id: ruff-format- repo: https://github.com/codespell-project/codespell- rev: v2.4.1+ rev: v2.4.3hooks:- id: codespelldiff --git a/kornia/augmentation/__init__.py b/kornia/augmentation/__init__.pyindex fea7e1723..af3d894de 100644--- a/kornia/augmentation/__init__.py+++ b/kornia/augmentation/__init__.py@@ -180,7 +180,6 @@ __all__ = ["RandomPlasmaShadow","RandomPosterize","RandomRGBShift",- "RandomRGBShift","RandomRain","RandomResizedCrop","RandomRotation",diff --git a/kornia/contrib/kmeans.py b/kornia/contrib/kmeans.pyindex 51175c588..d78e7fb26 100644--- a/kornia/contrib/kmeans.py+++ b/kornia/contrib/kmeans.py@@ -61,8 +61,8 @@ class KMeans:self.tolerance = toleranceself.max_iterations = max_iterations- self._final_cluster_assignments: None | torch.Tensor = None- self._final_cluster_centers: None | torch.Tensor = None+ self._final_cluster_assignments: torch.Tensor | None = None+ self._final_cluster_centers: torch.Tensor | None = Noneif seed is not None:torch.manual_seed(seed)diff --git a/kornia/contrib/visual_prompter.py b/kornia/contrib/visual_prompter.pyindex 77688ffb4..c194d6dc7 100644--- a/kornia/contrib/visual_prompter.py+++ b/kornia/contrib/visual_prompter.py@@ -95,9 +95,9 @@ class VisualPrompter:self.device = deviceself.dtype = dtype- self._original_image_size: None | tuple[int, int] = None- self._input_image_size: None | tuple[int, int] = None- self._input_encoder_size: None | tuple[int, int] = None+ self._original_image_size: tuple[int, int] | None = None+ self._input_image_size: tuple[int, int] | None = None+ self._input_encoder_size: tuple[int, int] | None = Noneself.reset_image()def preprocess_image(diff --git a/kornia/enhance/__init__.py b/kornia/enhance/__init__.pyindex a2492775a..7f5ace440 100644--- a/kornia/enhance/__init__.py+++ b/kornia/enhance/__init__.py@@ -79,7 +79,6 @@ __all__ = ["IntegralTensor","Invert","JPEGCodecDifferentiable",- "JPEGCodecDifferentiable","Normalize","Rescale","Threshold",diff --git a/kornia/feature/__init__.py b/kornia/feature/__init__.pyindex 16a595f82..21e081f39 100644--- a/kornia/feature/__init__.py+++ b/kornia/feature/__init__.py@@ -113,10 +113,8 @@ __all__ = ["DeFMO","DenseSIFTDescriptor","DescriptorMatcher",- "DescriptorMatcher","FilterResponseNorm2d","GFTTAffNetHardNet",- "GFTTAffNetHardNet","GeometryAwareDescriptorMatcher","HardNet","HardNet8",@@ -124,21 +122,17 @@ __all__ = ["HyNet","InterpolateSparse2d","KeyNet",- "KeyNet","KeyNetAffNetHardNet","KeyNetDetector","KeyNetHardNet","LAFAffNetShapeEstimator","LAFAffineShapeEstimator","LAFDescriptor",- "LAFDescriptor","LAFOrienter","LightGlue","LightGlueMatcher","LoFTR","LocalFeature",- "LocalFeature",- "LocalFeatureMatcher","LocalFeatureMatcher","MKDDescriptor","MultiResolutionDetector",@@ -149,7 +143,6 @@ __all__ = ["PatchDominantGradientOrientation","SIFTDescriptor","SIFTFeature",- "SIFTFeature","SIFTFeatureScaleSpace","SOLD2_detector","SOSNet",@@ -165,7 +158,6 @@ __all__ = ["extract_patches_simple","get_laf_center","get_laf_descriptors",- "get_laf_descriptors","get_laf_orientation","get_laf_scale","gftt_response",@@ -180,13 +172,9 @@ __all__ = ["match_adalam","match_fginn","match_mnn",- "match_mnn","match_nn",- "match_nn",- "match_smnn","match_smnn","match_snn",- "match_snn","normalize_laf","perspective_transform_lafs","rotate_laf",diff --git a/kornia/feature/disk/disk.py b/kornia/feature/disk/disk.pyindex 82e5cf24e..f1a4c8c6a 100644--- a/kornia/feature/disk/disk.py+++ b/kornia/feature/disk/disk.py@@ -50,7 +50,7 @@ class DISK(nn.Module):"""- def __init__(self, desc_dim: int = 128, unet: None | nn.Module = None) -> None:+ def __init__(self, desc_dim: int = 128, unet: nn.Module | None = None) -> None:super().__init__()self.desc_dim = desc_dimdiff --git a/kornia/feature/loftr/loftr_module/transformer.py b/kornia/feature/loftr/loftr_module/transformer.pyindex f77be52d7..252a8bd94 100644--- a/kornia/feature/loftr/loftr_module/transformer.py+++ b/kornia/feature/loftr/loftr_module/transformer.py@@ -114,8 +114,8 @@ class LocalFeatureTransformer(nn.Module):self,feat0: torch.Tensor,feat1: torch.Tensor,- mask0: None | torch.Tensor = None,- mask1: None | torch.Tensor = None,+ mask0: torch.Tensor | None = None,+ mask1: torch.Tensor | None = None,) -> tuple[torch.Tensor, torch.Tensor]:"""Run forward.diff --git a/kornia/geometry/depth.py b/kornia/geometry/depth.pyindex 4d368ce4f..cda776ca6 100644--- a/kornia/geometry/depth.py+++ b/kornia/geometry/depth.py@@ -363,8 +363,8 @@ class DepthWarper(nn.Module):if not isinstance(pinhole_dst, PinholeCamera):raise TypeError(f"Expected pinhole_dst as PinholeCamera, got {type(pinhole_dst)}")self._pinhole_dst: PinholeCamera = pinhole_dst- self._pinhole_src: None | PinholeCamera = None- self._dst_proj_src: None | torch.Tensor = None+ self._pinhole_src: PinholeCamera | None = None+ self._dst_proj_src: torch.Tensor | None = None# Meshgrid only depends on (height, width), can be staticmethod cachedself.grid: torch.Tensor = self._create_meshgrid(height, width)diff --git a/kornia/geometry/liegroup/se2.py b/kornia/geometry/liegroup/se2.pyindex 1c7fc4a5e..10a1ebc79 100644--- a/kornia/geometry/liegroup/se2.py+++ b/kornia/geometry/liegroup/se2.py@@ -272,7 +272,7 @@ class Se2(nn.Module):def identity(cls,batch_size: Optional[int] = None,- device: Union[None, str, torch.device] = None,+ device: Union[str, torch.device, None] = None,dtype: Union[torch.dtype, None] = None,) -> Se2:"""Create a Se2 group representing an identity rotation and zero translation.@@ -362,7 +362,7 @@ class Se2(nn.Module):def random(cls,batch_size: Optional[int] = None,- device: Union[None, str, torch.device] = None,+ device: Union[str, torch.device, None] = None,dtype: Union[torch.dtype, None] = None,) -> Se2:"""Create a Se2 group representing a random transformation.diff --git a/kornia/geometry/liegroup/se3.py b/kornia/geometry/liegroup/se3.pyindex 41b148efd..332f4c60b 100644--- a/kornia/geometry/liegroup/se3.py+++ b/kornia/geometry/liegroup/se3.py@@ -260,7 +260,7 @@ class Se3(nn.Module):def identity(cls,batch_size: Optional[int] = None,- device: Union[None, str, torch.device] = None,+ device: Union[str, torch.device, None] = None,dtype: Union[torch.dtype, None] = None,) -> Se3:"""Create a Se3 group representing an identity rotation and zero translation.@@ -370,7 +370,7 @@ class Se3(nn.Module):def random(cls,batch_size: Optional[int] = None,- device: Union[None, str, torch.device] = None,+ device: Union[str, torch.device, None] = None,dtype: Union[torch.dtype, None] = None,) -> Se3:"""Create a Se3 group representing a random transformation.diff --git a/kornia/geometry/liegroup/so2.py b/kornia/geometry/liegroup/so2.pyindex 731f12b30..a5b126a0b 100644--- a/kornia/geometry/liegroup/so2.py+++ b/kornia/geometry/liegroup/so2.py@@ -253,8 +253,8 @@ class So2(nn.Module):def identity(cls,batch_size: Optional[int] = None,- device: Union[None, str, torch.device] = None,- dtype: Union[None, torch.dtype] = None,+ device: Union[str, torch.device, None] = None,+ dtype: Union[torch.dtype, None] = None,) -> So2:"""Create a So2 group representing an identity rotation.@@ -294,8 +294,8 @@ class So2(nn.Module):def random(cls,batch_size: Optional[int] = None,- device: Union[None, str, torch.device] = None,- dtype: Union[None, torch.dtype] = None,+ device: Union[str, torch.device, None] = None,+ dtype: Union[torch.dtype, None] = None,) -> So2:"""Create a So2 group representing a random rotation.diff --git a/kornia/geometry/liegroup/so3.py b/kornia/geometry/liegroup/so3.pyindex 5f223aca5..462b8b3d1 100644--- a/kornia/geometry/liegroup/so3.py+++ b/kornia/geometry/liegroup/so3.py@@ -278,8 +278,8 @@ class So3(nn.Module):def identity(cls,batch_size: Optional[int] = None,- device: Union[None, str, torch.device] = None,- dtype: Union[None, torch.dtype] = None,+ device: Union[str, torch.device, None] = None,+ dtype: Union[torch.dtype, None] = None,) -> So3:"""Create a So3 group representing an identity rotation.@@ -316,8 +316,8 @@ class So3(nn.Module):def random(cls,batch_size: Optional[int] = None,- device: Union[None, str, torch.device] = None,- dtype: Union[None, torch.dtype] = None,+ device: Union[str, torch.device, None] = None,+ dtype: Union[torch.dtype, None] = None,) -> So3:"""Create a So3 group representing a random rotation.diff --git a/kornia/geometry/transform/affwarp.py b/kornia/geometry/transform/affwarp.pyindex 068df0d20..3ca429887 100644--- a/kornia/geometry/transform/affwarp.py+++ b/kornia/geometry/transform/affwarp.py@@ -1053,7 +1053,7 @@ class Rotate(nn.Module):) -> None:super().__init__()self.angle: torch.Tensor = angle- self.center: Union[None, torch.Tensor] = center+ self.center: Union[torch.Tensor, None] = centerself.mode: str = modeself.padding_mode: str = padding_modeself.align_corners: bool = align_corners@@ -1174,7 +1174,7 @@ class Scale(nn.Module):) -> None:super().__init__()self.scale_factor: torch.Tensor = scale_factor- self.center: Union[None, torch.Tensor] = center+ self.center: Union[torch.Tensor, None] = centerself.mode: str = modeself.padding_mode: str = padding_modeself.align_corners: bool = align_corners