π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
[pre-commit.ci] pre-commit suggestions (#2596)
pre-commit-ci[bot]ffd90adec856
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlindex 836cead8c..f37bb4296 100644--- a/.pre-commit-config.yaml+++ b/.pre-commit-config.yaml@@ -15,12 +15,12 @@ repos:exclude: ^$|.devcontainer- repo: https://github.com/tox-dev/pyproject-fmt- rev: "1.1.0"+ rev: "1.2.0"hooks:- id: pyproject-fmt- repo: https://github.com/astral-sh/ruff-pre-commit- rev: v0.0.291+ rev: v0.0.292hooks:- id: ruffargs: [--fix, --exit-non-zero-on-fix]@@ -31,12 +31,12 @@ repos:- id: black- repo: https://github.com/codespell-project/codespell- rev: v2.2.5+ rev: v2.2.6hooks:- id: codespellargs:- --ignore-words-list- - "ans,hist,laf"+ - "ans,hist,laf,cofusion"- --skip- "*.bib,*.ipynb"diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 31dd3c0ed..5706f524f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -60,7 +60,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0* Replace `assert_allclose` by `assert_close` by @johnnv1 in https://github.com/kornia/kornia/pull/2210* Fix random crop for keypoints on CUDA device by @johnnv1 in https://github.com/kornia/kornia/pull/2209* Remove outdated augmentation example by @johnnv1 in https://github.com/kornia/kornia/pull/2206-* Fix CUDA failling tests of same device on `Augmentations` by @johnnv1 in https://github.com/kornia/kornia/pull/2215+* Fix CUDA failing tests of same device on `Augmentations` by @johnnv1 in https://github.com/kornia/kornia/pull/2215diff --git a/docs/source/get-started/training.rst b/docs/source/get-started/training.rstindex f7a7063a7..29ea2747a 100644--- a/docs/source/get-started/training.rst+++ b/docs/source/get-started/training.rst@@ -44,7 +44,7 @@ Design PrinciplesTrainer Usage--------------The entry point to start traning with Kornia is through the :py:class:`~kornia.x.Trainer` class.+The entry point to start training with Kornia is through the :py:class:`~kornia.x.Trainer` class.The main API is a self contained module that heavily relies on `accelerate <https://github.com/huggingface/accelerate/>`_to easily scale the training over multi-GPUs/TPU/fp16 `(see more) <https://github.com/huggingface/accelerate#supported-integrations/>`_diff --git a/kornia/augmentation/_2d/geometric/affine.py b/kornia/augmentation/_2d/geometric/affine.pyindex f0aad424e..101e69af4 100644--- a/kornia/augmentation/_2d/geometric/affine.py+++ b/kornia/augmentation/_2d/geometric/affine.py@@ -33,7 +33,7 @@ class RandomAffine(GeometricAugmentationBase2D):If (a, b, c, d), then x-axis shear in (shear[0], shear[1]) and y-axis shear in (shear[2], shear[3])will be applied. Will not apply shear by default.resample: resample mode from "nearest" (0) or "bilinear" (1).- padding_mode: padding mode from "zeros" (0), "border" (1) or "refection" (2).+ padding_mode: padding mode from "zeros" (0), "border" (1) or "reflection" (2).same_on_batch: apply the same transformation across the batch.align_corners: interpolation flag.p: probability of applying the transformation.diff --git a/kornia/augmentation/_2d/geometric/base.py b/kornia/augmentation/_2d/geometric/base.pyindex 4601b29b8..5843d1ce1 100644--- a/kornia/augmentation/_2d/geometric/base.py+++ b/kornia/augmentation/_2d/geometric/base.py@@ -220,7 +220,7 @@ class GeometricAugmentationBase2D(RigidAffineAugmentationBase2D):input: input keypoints tensor or object.params: the corresponding parameters for an operation.flags: static parameters.- transform: the inverse tansformation matrix+ transform: the inverse transformation matrix"""output = input.clone()batch_prob = params['batch_prob']diff --git a/kornia/augmentation/_2d/geometric/shear.py b/kornia/augmentation/_2d/geometric/shear.pyindex 68876b57a..f10e9e157 100644--- a/kornia/augmentation/_2d/geometric/shear.py+++ b/kornia/augmentation/_2d/geometric/shear.py@@ -20,7 +20,7 @@ class RandomShear(GeometricAugmentationBase2D):If (a, b, c, d), then x-axis shear in (shear[0], shear[1]) and y-axis shear in (shear[2], shear[3])will be applied. Will not apply shear by default.resample: resample mode from "nearest" (0) or "bilinear" (1).- padding_mode: padding mode from "zeros" (0), "border" (1) or "refection" (2).+ padding_mode: padding mode from "zeros" (0), "border" (1) or "reflection" (2).same_on_batch: apply the same transformation across the batch.align_corners: interpolation flag.p: probability of applying the transformation.diff --git a/kornia/augmentation/_2d/geometric/translate.py b/kornia/augmentation/_2d/geometric/translate.pyindex 2ce50fb85..13f91defe 100644--- a/kornia/augmentation/_2d/geometric/translate.py+++ b/kornia/augmentation/_2d/geometric/translate.py@@ -18,7 +18,7 @@ class RandomTranslate(GeometricAugmentationBase2D):For example translate_y=(a, b), then vertical shiftis randomly sampled in the range img_height * a < dy < img_height * b.resample: resample mode from "nearest" (0) or "bilinear" (1).- padding_mode: padding mode from "zeros" (0), "border" (1) or "refection" (2).+ padding_mode: padding mode from "zeros" (0), "border" (1) or "reflection" (2).same_on_batch: apply the same transformation across the batch.align_corners: interpolation flag.p: probability of applying the transformation.diff --git a/kornia/contrib/diamond_square.py b/kornia/contrib/diamond_square.pyindex a0f2d80b2..2bd1b9ef0 100644--- a/kornia/contrib/diamond_square.py+++ b/kornia/contrib/diamond_square.py@@ -89,7 +89,7 @@ def _one_diamond_one_square(img: a 4D tensor where dimensions are Batch, Channel, Width, Height. Width and Height must both be 2^N+1 andBatch and Channels should in the usual case be 1.random_scale: a float number in [0,1] controlling the randomness created pixels get. I the usual case, it is- halved at every applycation of this function.+ halved at every application of this function.random_fn: the random function to generate the image seed.diamond_kernel: the 3x3 kernel to perform the diamond step.square_kernel: the 3x3 kernel to perform the square step.diff --git a/kornia/contrib/image_prompter.py b/kornia/contrib/image_prompter.pyindex bfd61780c..8513574b6 100644--- a/kornia/contrib/image_prompter.py+++ b/kornia/contrib/image_prompter.py@@ -85,7 +85,7 @@ class ImagePrompter:def preprocess_image(self, x: Tensor, mean: Tensor | None = None, std: Tensor | None = None) -> Tensor:"""Normalize and pad a tensor.- For normalize the tensor: will priorize the `mean` and `std` passed as argument, if None will use the default+ For normalize the tensor: will prioritize the `mean` and `std` passed as argument, if None will use the defaultSam Dataset values.For pad the tensor: Will pad the tensor into the right and bottom to match with the size ofdiff --git a/kornia/contrib/models/sam/architecture/mask_decoder.py b/kornia/contrib/models/sam/architecture/mask_decoder.pyindex c1817dd96..dbf1d7dfd 100644--- a/kornia/contrib/models/sam/architecture/mask_decoder.py+++ b/kornia/contrib/models/sam/architecture/mask_decoder.py@@ -23,7 +23,7 @@ class MaskDecoder(Module):iou_head_depth: int = 3,iou_head_hidden_dim: int = 256,) -> None:- """Predicts masks given an image and prompt embeddings, using a tranformer architecture.+ """Predicts masks given an image and prompt embeddings, using a transformer architecture.Args:transformer_dim: the channel dimension of the transformerdiff --git a/kornia/contrib/visual_prompter.py b/kornia/contrib/visual_prompter.pyindex f25ab22b1..7a1afe060 100644--- a/kornia/contrib/visual_prompter.py+++ b/kornia/contrib/visual_prompter.py@@ -78,7 +78,7 @@ class VisualPrompter:def preprocess_image(self, x: Tensor, mean: Tensor | None = None, std: Tensor | None = None) -> Tensor:"""Normalize and pad a tensor.- For normalize the tensor: will priorize the `mean` and `std` passed as argument, if None will use the default+ For normalize the tensor: will prioritize the `mean` and `std` passed as argument, if None will use the defaultSam Dataset values.For pad the tensor: Will pad the tensor into the right and bottom to match with the size ofdiff --git a/kornia/feature/hynet.py b/kornia/feature/hynet.pyindex a30f85726..4d0aa9fc8 100644--- a/kornia/feature/hynet.py+++ b/kornia/feature/hynet.py@@ -137,7 +137,7 @@ class HyNet(Module):pretrained: Download and set pretrained weights to the model.is_bias: use bias in TLU layersis_bias_FRN: use bias in FRN layers- dim_desc: descriptor dimentionality,+ dim_desc: descriptor dimensionality,drop_rate: dropout rate,eps_l2_norm: to avoid div by zerodiff --git a/kornia/feature/keynet.py b/kornia/feature/keynet.pyindex ded908ff9..25aab03e1 100644--- a/kornia/feature/keynet.py+++ b/kornia/feature/keynet.py@@ -118,7 +118,7 @@ class KeyNet(Module):Args:pretrained: Download and set pretrained weights to the model.- keynet_conf: Dict with initiliazation parameters. Do not pass it, unless you know what you are doing`.+ keynet_conf: Dict with initialization parameters. Do not pass it, unless you know what you are doing`.Returns:KeyNet response score.@@ -176,7 +176,7 @@ class KeyNetDetector(MultiResolutionDetector):Args:pretrained: Download and set pretrained weights to the model.num_features: Number of features to detect.- keynet_conf: Dict with initiliazation parameters. Do not pass it, unless you know what you are doing`.+ keynet_conf: Dict with initialization parameters. Do not pass it, unless you know what you are doing`.ori_module: for local feature orientation estimation. Default: :class:`~kornia.feature.PassLAF`,which does nothing. See :class:`~kornia.feature.LAFOrienter` for details.aff_module: for local feature affine shape estimation. Default: :class:`~kornia.feature.PassLAF`,diff --git a/kornia/feature/loftr/loftr.py b/kornia/feature/loftr/loftr.pyindex 5dc19dddb..9f77c3159 100644--- a/kornia/feature/loftr/loftr.py+++ b/kornia/feature/loftr/loftr.py@@ -60,7 +60,7 @@ class LoFTR(Module):If the distance matrix dm is not provided, :py:func:`torch.cdist` is used.Args:- config: Dict with initiliazation parameters. Do not pass it, unless you know what you are doing`.+ config: Dict with initialization parameters. Do not pass it, unless you know what you are doing`.pretrained: Download and set pretrained weights to the model. Options: 'outdoor', 'indoor'.'outdoor' is trained on the MegaDepth dataset and 'indoor'on the ScanNet.diff --git a/kornia/feature/scale_space_detector.py b/kornia/feature/scale_space_detector.pyindex 25c3f9353..a232efc94 100644--- a/kornia/feature/scale_space_detector.py+++ b/kornia/feature/scale_space_detector.py@@ -254,7 +254,7 @@ class MultiResolutionDetector(Module):Args:model: response function, such as KeyNet or BlobHessiannum_features: Number of features to detect.- conf: Dict with initiliazation parameters. Do not pass it, unless you know what you are doing`.+ conf: Dict with initialization parameters. Do not pass it, unless you know what you are doing`.ori_module: for local feature orientation estimation. Default: :class:`~kornia.feature.PassLAF`,which does nothing. See :class:`~kornia.feature.LAFOrienter` for details.aff_module: for local feature affine shape estimation. Default: :class:`~kornia.feature.PassLAF`,diff --git a/kornia/geometry/bbox.py b/kornia/geometry/bbox.pyindex 1438e84d1..63572fd20 100644--- a/kornia/geometry/bbox.py+++ b/kornia/geometry/bbox.py@@ -195,7 +195,7 @@ def bbox_to_mask(boxes: torch.Tensor, width: int, height: int) -> torch.Tensor:[0., 0., 0., 0., 0.]]])"""validate_bbox(boxes)- # zero padding the surroudings+ # zero padding the surroundingsmask = torch.zeros((len(boxes), height + 2, width + 2), dtype=boxes.dtype, device=boxes.device)# push all points one pixel off# in order to zero-out the fully filled rows or columnsdiff --git a/kornia/geometry/camera/pinhole.py b/kornia/geometry/camera/pinhole.pyindex 1df00fdfe..76cfce2a5 100644--- a/kornia/geometry/camera/pinhole.py+++ b/kornia/geometry/camera/pinhole.py@@ -407,7 +407,7 @@ class PinholeCamerasList(PinholeCamera):width.append(pinhole.width)intrinsics.append(pinhole.intrinsics)extrinsics.append(pinhole.extrinsics)- # contatenate and set members. We will assume BxNx4x4+ # concatenate and set members. We will assume BxNx4x4self.height: Tensor = torch.stack(height, dim=1)self.width: Tensor = torch.stack(width, dim=1)self._intrinsics: Tensor = torch.stack(intrinsics, dim=1)diff --git a/kornia/geometry/epipolar/projection.py b/kornia/geometry/epipolar/projection.pyindex 7fdccbe21..040c66b51 100644--- a/kornia/geometry/epipolar/projection.py+++ b/kornia/geometry/epipolar/projection.py@@ -12,7 +12,7 @@ from .numeric import cross_product_matrixdef intrinsics_like(focal: float, input: Tensor) -> Tensor:- r"""Return a 3x3 instrinsics matrix, with same size as the input.+ r"""Return a 3x3 intrinsics matrix, with same size as the input.The center of projection will be based in the input image size.@@ -83,7 +83,7 @@ def projection_from_KRt(K: Tensor, R: Tensor, t: Tensor) -> Tensor:This function estimate the projection matrix by solving the following equation: :math:`P = K * [R|t]`.Args:- K: the camera matrix with the instrinsics with shape :math:`(B, 3, 3)`.+ K: the camera matrix with the intrinsics with shape :math:`(B, 3, 3)`.R: The rotation matrix with shape :math:`(B, 3, 3)`.t: The translation vector with shape :math:`(B, 3, 1)`.diff --git a/kornia/geometry/homography.py b/kornia/geometry/homography.pyindex cad46d5bc..d3540e900 100644--- a/kornia/geometry/homography.py+++ b/kornia/geometry/homography.py@@ -84,9 +84,10 @@ def symmetric_transfer_error(pts1: Tensor, pts2: Tensor, H: Tensor, squared: boodef line_segment_transfer_error_one_way(ls1: Tensor, ls2: Tensor, H: Tensor, squared: bool = False) -> Tensor:- r"""Return transfer error in image 2 for line segment correspondences given the homography matrix. Line segment- end points are reprojected into image 2, and point-to-line error is calculted w.r.t. line, induced by line- segment in image 2. See :cite:`homolines2001` for details.+ r"""Return transfer error in image 2 for line segment correspondences given the homography matrix.++ Line segment end points are reprojected into image 2, and point-to-line error is calculated w.r.t. line,+ induced by line segment in image 2. See :cite:`homolines2001` for details.Args:ls1: line segment correspondences from the left images with shapediff --git a/kornia/nerf/rays.py b/kornia/nerf/rays.pyindex 92e7883a3..6d08fba8c 100755--- a/kornia/nerf/rays.py+++ b/kornia/nerf/rays.py@@ -405,7 +405,7 @@ def sample_ray_points(Args:origins: tensor containing ray origins in 3d world coordinates. Tensor shape :math:`(*, 3)`.directions: tensor containing ray directions in 3d world coordinates. Tensor shape :math:`(*, 3)`.- lengths: tensor cotaining sampled distances along each ray. Tensor shape :math:`(*, num_ray_points)`.+ lengths: tensor containing sampled distances along each ray. Tensor shape :math:`(*, num_ray_points)`.Returns:points_3d: Points along rays :math:`(*, num_ray_points, 3)`diff --git a/pyproject.toml b/pyproject.tomlindex da06efbc5..0cc9e8e31 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -25,6 +25,7 @@ classifiers = ["Programming Language :: Python :: 3.9","Programming Language :: Python :: 3.10","Programming Language :: Python :: 3.11",+ "Programming Language :: Python :: 3.12","Topic :: Scientific/Engineering :: Artificial Intelligence","Topic :: Scientific/Engineering :: Image Processing","Topic :: Software Development :: Libraries",diff --git a/test/augmentation/test_augmentation.py b/test/augmentation/test_augmentation.pyindex 0a9894e56..852b2364b 100644--- a/test/augmentation/test_augmentation.py+++ b/test/augmentation/test_augmentation.py@@ -157,7 +157,7 @@ class CommonTests(BaseTester):self._augmentation_cls, AugmentationBase2D), f"{self._augmentation_cls} is not a subclass of AugmentationBase2D"- # Can be instatiated+ # Can be instantiatedaugmentation = self._create_augmentation_from_params(**params)assert issubclass(type(augmentation), AugmentationBase2Ddiff --git a/test/contrib/models/test_sam.py b/test/contrib/models/test_sam.pyindex 344649bdf..578abf0cf 100644--- a/test/contrib/models/test_sam.py+++ b/test/contrib/models/test_sam.py@@ -66,7 +66,7 @@ class TestSam(BaseTester):assert isinstance(model, Sam)assert next(model.parameters()).device == device- @pytest.mark.skip(reason='Unsupport at moment -- the code is not tested for trainning and had `torch.no_grad`')+ @pytest.mark.skip(reason='Unsupport at moment -- the code is not tested for training and had `torch.no_grad`')def test_gradcheck(self, device):...