π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
[pre-commit.ci] pre-commit suggestions (#3519)
pre-commit-ci[bot]a0d263b4e307
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlindex 47e8b9808..fb3c4a38f 100644--- a/.pre-commit-config.yaml+++ b/.pre-commit-config.yaml@@ -21,7 +21,7 @@ repos:exclude: ^$|.devcontainer- repo: https://github.com/astral-sh/ruff-pre-commit- rev: v0.14.11+ rev: v0.15.1hooks:- id: ruff-checkargs: [--fix, --exit-non-zero-on-fix]@@ -33,7 +33,7 @@ repos:- id: codespell- repo: https://github.com/arkinmodi/add-license-header- rev: v2.4.0+ rev: v2.4.1hooks:- id: add-license-headertypes: [python]diff --git a/kornia/augmentation/_2d/intensity/color_jiggle.py b/kornia/augmentation/_2d/intensity/color_jiggle.pyindex 1d25977c2..816b3221b 100644--- a/kornia/augmentation/_2d/intensity/color_jiggle.py+++ b/kornia/augmentation/_2d/intensity/color_jiggle.py@@ -98,15 +98,17 @@ class ColorJiggle(IntensityAugmentationBase2D):transform: Optional[torch.Tensor] = None,) -> torch.Tensor:transforms = [- lambda img: adjust_brightness(img, params["brightness_factor"] - 1)- if (params["brightness_factor"] - 1 != 0).any()- else img,- lambda img: adjust_contrast(img, params["contrast_factor"])- if (params["contrast_factor"] != 1).any()- else img,- lambda img: adjust_saturation(img, params["saturation_factor"])- if (params["saturation_factor"] != 1).any()- else img,+ lambda img: (+ adjust_brightness(img, params["brightness_factor"] - 1)+ if (params["brightness_factor"] - 1 != 0).any()+ else img+ ),+ lambda img: (+ adjust_contrast(img, params["contrast_factor"]) if (params["contrast_factor"] != 1).any() else img+ ),+ lambda img: (+ adjust_saturation(img, params["saturation_factor"]) if (params["saturation_factor"] != 1).any() else img+ ),lambda img: adjust_hue(img, params["hue_factor"] * 2 * pi) if (params["hue_factor"] != 0).any() else img,]diff --git a/kornia/augmentation/_2d/intensity/color_jitter.py b/kornia/augmentation/_2d/intensity/color_jitter.pyindex 338152036..bae5b22dd 100644--- a/kornia/augmentation/_2d/intensity/color_jitter.py+++ b/kornia/augmentation/_2d/intensity/color_jitter.py@@ -130,9 +130,7 @@ class ColorJitter(IntensityAugmentationBase2D):if (params["saturation_factor"] != 1).any()else img),- lambda img: (- self._hue_fn(img, params["hue_factor"] * 2 * pi) if (params["hue_factor"] != 0).any() else img- ),+ lambda img: self._hue_fn(img, params["hue_factor"] * 2 * pi) if (params["hue_factor"] != 0).any() else img,]jittered = inputdiff --git a/kornia/augmentation/random_generator/_2d/crop.py b/kornia/augmentation/random_generator/_2d/crop.pyindex 5e48b654f..ad6ae4765 100644--- a/kornia/augmentation/random_generator/_2d/crop.py+++ b/kornia/augmentation/random_generator/_2d/crop.py@@ -285,7 +285,7 @@ def center_crop_generator(height: int,width: int,size: Tuple[int, int],- device: Optional[Union[str, torch.device, None]] = None,+ device: Union[None, str, torch.device] = None,) -> Dict[str, torch.Tensor]:r"""Get parameters for ```center_crop``` transformation for center crop transform.diff --git a/kornia/augmentation/random_generator/_3d/crop.py b/kornia/augmentation/random_generator/_3d/crop.pyindex b78861c58..57f522224 100644--- a/kornia/augmentation/random_generator/_3d/crop.py+++ b/kornia/augmentation/random_generator/_3d/crop.py@@ -161,7 +161,7 @@ def center_crop_generator3d(height: int,width: int,size: Tuple[int, int, int],- device: Optional[Union[str, torch.device, None]] = None,+ device: Union[None, str, torch.device] = None,) -> Dict[str, torch.Tensor]:r"""Get parameters for ```center_crop3d``` transformation for center crop transform.diff --git a/kornia/augmentation/random_generator/base.py b/kornia/augmentation/random_generator/base.pyindex df4b2fc44..7fcda8f07 100644--- a/kornia/augmentation/random_generator/base.py+++ b/kornia/augmentation/random_generator/base.py@@ -38,7 +38,7 @@ class _PostInitInjectionMetaClass(type):class RandomGeneratorBase(nn.Module, metaclass=_PostInitInjectionMetaClass):"""Base class for generating random augmentation parameters."""- device: Optional[Union[str, torch.device, None]] = None+ device: Union[None, str, torch.device] = Nonedtype: torch.dtypedef __init__(self) -> None:diff --git a/kornia/feature/integrated.py b/kornia/feature/integrated.pyindex 0ae4a5753..fd0062d95 100644--- a/kornia/feature/integrated.py+++ b/kornia/feature/integrated.py@@ -187,7 +187,7 @@ class SIFTFeature(LocalFeature):num_features: int = 8000,upright: bool = False,rootsift: bool = True,- device: Optional[Union[str, torch.device, None]] = None,+ device: Union[None, str, torch.device] = None,config: Optional[Detector_config] = None,) -> None:patch_size: int = 41@@ -221,7 +221,7 @@ class SIFTFeatureScaleSpace(LocalFeature):num_features: int = 8000,upright: bool = False,rootsift: bool = True,- device: Optional[Union[str, torch.device, None]] = None,+ device: Union[None, str, torch.device] = None,) -> None:if device is None:device = torch.device("cpu")@@ -249,7 +249,7 @@ class GFTTAffNetHardNet(LocalFeature):self,num_features: int = 8000,upright: bool = False,- device: Optional[Union[str, torch.device, None]] = None,+ device: Union[None, str, torch.device] = None,config: Optional[Detector_config] = None,) -> None:if device is None:@@ -274,7 +274,7 @@ class HesAffNetHardNet(LocalFeature):self,num_features: int = 2048,upright: bool = False,- device: Optional[Union[str, torch.device, None]] = None,+ device: Union[None, str, torch.device] = None,config: Optional[Detector_config] = None,) -> None:if device is None:@@ -299,7 +299,7 @@ class KeyNetHardNet(LocalFeature):self,num_features: int = 8000,upright: bool = False,- device: Optional[Union[str, torch.device, None]] = None,+ device: Union[None, str, torch.device] = None,scale_laf: float = 1.0,) -> None:if device is None:@@ -320,7 +320,7 @@ class KeyNetAffNetHardNet(LocalFeature):self,num_features: int = 8000,upright: bool = False,- device: Optional[Union[str, torch.device, None]] = None,+ device: Union[None, str, torch.device] = None,scale_laf: float = 1.0,) -> None:if device is None:diff --git a/kornia/geometry/liegroup/se2.py b/kornia/geometry/liegroup/se2.pyindex 4ed7bea46..264c937e9 100644--- a/kornia/geometry/liegroup/se2.py+++ b/kornia/geometry/liegroup/se2.py@@ -262,7 +262,7 @@ class Se2(nn.Module):def identity(cls,batch_size: Optional[int] = None,- device: Optional[Union[str, torch.device, None]] = None,+ device: Union[None, str, torch.device] = None,dtype: Union[torch.dtype, None] = None,) -> Se2:"""Create a Se2 group representing an identity rotation and zero translation.@@ -352,7 +352,7 @@ class Se2(nn.Module):def random(cls,batch_size: Optional[int] = None,- device: Optional[Union[str, torch.device, None]] = None,+ device: Union[None, str, torch.device] = 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 d073221af..bc6d65bd6 100644--- a/kornia/geometry/liegroup/se3.py+++ b/kornia/geometry/liegroup/se3.py@@ -258,7 +258,7 @@ class Se3(nn.Module):def identity(cls,batch_size: Optional[int] = None,- device: Optional[Union[str, torch.device, None]] = None,+ device: Union[None, str, torch.device] = None,dtype: Union[torch.dtype, None] = None,) -> Se3:"""Create a Se3 group representing an identity rotation and zero translation.@@ -368,7 +368,7 @@ class Se3(nn.Module):def random(cls,batch_size: Optional[int] = None,- device: Optional[Union[str, torch.device, None]] = None,+ device: Union[None, str, torch.device] = 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 d7459b7e2..3ca562928 100644--- a/kornia/geometry/liegroup/so2.py+++ b/kornia/geometry/liegroup/so2.py@@ -231,8 +231,8 @@ class So2(nn.Module):def identity(cls,batch_size: Optional[int] = None,- device: Optional[Union[str, torch.device, None]] = None,- dtype: Optional[Union[torch.dtype, None]] = None,+ device: Union[None, str, torch.device] = None,+ dtype: Union[None, torch.dtype] = None,) -> So2:"""Create a So2 group representing an identity rotation.@@ -272,8 +272,8 @@ class So2(nn.Module):def random(cls,batch_size: Optional[int] = None,- device: Optional[Union[str, torch.device, None]] = None,- dtype: Optional[Union[torch.dtype, None]] = None,+ device: Union[None, str, torch.device] = None,+ dtype: Union[None, torch.dtype] = None,) -> So2:"""Create a So2 group representing a random rotation.diff --git a/kornia/geometry/liegroup/so3.py b/kornia/geometry/liegroup/so3.pyindex f76be1160..77e79aea1 100644--- a/kornia/geometry/liegroup/so3.py+++ b/kornia/geometry/liegroup/so3.py@@ -277,8 +277,8 @@ class So3(nn.Module):def identity(cls,batch_size: Optional[int] = None,- device: Optional[Union[str, torch.device, None]] = None,- dtype: Optional[Union[torch.dtype, None]] = None,+ device: Union[None, str, torch.device] = None,+ dtype: Union[None, torch.dtype] = None,) -> So3:"""Create a So3 group representing an identity rotation.@@ -315,8 +315,8 @@ class So3(nn.Module):def random(cls,batch_size: Optional[int] = None,- device: Optional[Union[str, torch.device, None]] = None,- dtype: Optional[Union[torch.dtype, None]] = None,+ device: Union[None, str, torch.device] = None,+ dtype: Union[None, torch.dtype] = None,) -> So3:"""Create a So3 group representing a random rotation.diff --git a/kornia/geometry/quaternion.py b/kornia/geometry/quaternion.pyindex 2a821b62f..34e83d521 100644--- a/kornia/geometry/quaternion.py+++ b/kornia/geometry/quaternion.py@@ -482,7 +482,7 @@ class Quaternion(nn.Module):def identity(cls,batch_size: Optional[int] = None,- device: Optional[Union[str, torch.device, None]] = None,+ device: Union[None, str, torch.device] = None,dtype: Union[torch.dtype, None] = None,) -> "Quaternion":"""Create a quaternion representing an identity rotation.@@ -527,7 +527,7 @@ class Quaternion(nn.Module):def random(cls,batch_size: Optional[int] = None,- device: Optional[Union[str, torch.device, None]] = None,+ device: Union[None, str, torch.device] = None,dtype: Union[torch.dtype, None] = None,) -> "Quaternion":"""Create a random unit quaternion of shape :math:`(B, 4)`.diff --git a/tests/io/test_io_image.py b/tests/io/test_io_image.pyindex a2800e455..132ebfde3 100644--- a/tests/io/test_io_image.py+++ b/tests/io/test_io_image.py@@ -48,7 +48,7 @@ def create_random_img8_torch(height: int, width: int, channels: int, device=Nonedef _download_image(url: str, filename: str = "") -> Path:# TODO: move this to testing- filename = url.split("/")[-1] if len(filename) == 0 else filename+ filename = url.rsplit("/", maxsplit=1)[-1] if len(filename) == 0 else filename# Downloadbytesio = io.BytesIO(requests.get(url, timeout=60).content)# Save file