π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
[pre-commit.ci] pre-commit suggestions (#2203)
pre-commit-ci[bot]38b993d085aa
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlindex 8a5d79d61..9f48819bc 100644--- a/.pre-commit-config.yaml+++ b/.pre-commit-config.yaml@@ -20,7 +20,7 @@ repos:- repo: https://github.com/psf/black- rev: 22.12.0+ rev: 23.1.0hooks:- id: blackdiff --git a/kornia/augmentation/_2d/intensity/color_jiggle.py b/kornia/augmentation/_2d/intensity/color_jiggle.pyindex 7f770ea91..944d27537 100644--- a/kornia/augmentation/_2d/intensity/color_jiggle.py+++ b/kornia/augmentation/_2d/intensity/color_jiggle.py@@ -74,7 +74,6 @@ class ColorJiggle(IntensityAugmentationBase2D):def apply_transform(self, input: Tensor, params: Dict[str, Tensor], flags: Dict[str, Any], transform: Optional[Tensor] = None) -> Tensor:-transforms = [lambda img: adjust_brightness(img, params["brightness_factor"] - 1),lambda img: adjust_contrast(img, params["contrast_factor"]),diff --git a/kornia/augmentation/_2d/intensity/color_jitter.py b/kornia/augmentation/_2d/intensity/color_jitter.pyindex b1c816df1..65db03aef 100644--- a/kornia/augmentation/_2d/intensity/color_jitter.py+++ b/kornia/augmentation/_2d/intensity/color_jitter.py@@ -87,7 +87,6 @@ class ColorJitter(IntensityAugmentationBase2D):def apply_transform(self, input: Tensor, params: Dict[str, Tensor], flags: Dict[str, Any], transform: Optional[Tensor] = None) -> Tensor:-transforms = [lambda img: adjust_brightness_accumulative(img, params["brightness_factor"]),lambda img: adjust_contrast_with_mean_subtraction(img, params["contrast_factor"]),diff --git a/kornia/augmentation/_2d/intensity/planckian_jitter.py b/kornia/augmentation/_2d/intensity/planckian_jitter.pyindex 213c91546..46e7026d7 100644--- a/kornia/augmentation/_2d/intensity/planckian_jitter.py+++ b/kornia/augmentation/_2d/intensity/planckian_jitter.py@@ -172,7 +172,6 @@ class RandomPlanckianJitter(IntensityAugmentationBase2D):def apply_transform(self, input: Tensor, params: Dict[str, Tensor], flags: Dict[str, Any], transform: Optional[Tensor] = None) -> Tensor:-list_idx = params['idx'].tolist()self.pl = self.pl.to(device=input.device)diff --git a/kornia/augmentation/base.py b/kornia/augmentation/base.pyindex 75ad9bf00..8c473d719 100644--- a/kornia/augmentation/base.py+++ b/kornia/augmentation/base.py@@ -135,7 +135,6 @@ class _BasicAugmentationBase(Module):def _process_kwargs_to_params_and_flags(self, params: Optional[Dict[str, Tensor]] = None, flags: Optional[Dict[str, Any]] = None, **kwargs) -> Tuple[Dict[str, Tensor], Dict[str, Any]]:-# NOTE: determine how to save self._paramssave_kwargs = kwargs["save_kwargs"] if "save_kwargs" in kwargs else False@@ -300,7 +299,6 @@ class _AugmentationBase(_BasicAugmentationBase):transform: Optional[Tensor] = None,**kwargs,) -> Boxes:-if not isinstance(input, Boxes):raise RuntimeError(f"Only `Boxes` is supported. Got {type(input)}.")@@ -334,7 +332,6 @@ class _AugmentationBase(_BasicAugmentationBase):transform: Optional[Tensor] = None,**kwargs,) -> Keypoints:-if not isinstance(input, Keypoints):raise RuntimeError(f"Only `Keypoints` is supported. Got {type(input)}.")@@ -366,7 +363,6 @@ class _AugmentationBase(_BasicAugmentationBase):transform: Optional[Tensor] = None,**kwargs,) -> Tensor:-params, flags = self._process_kwargs_to_params_and_flags(self._params if params is None else params, flags, **kwargs)diff --git a/kornia/augmentation/container/base.py b/kornia/augmentation/container/base.pyindex e5c91b4b0..3514eb60e 100644--- a/kornia/augmentation/container/base.py+++ b/kornia/augmentation/container/base.py@@ -86,7 +86,6 @@ class SequentialBase(nn.Sequential):mod: Module = selffor item in atoms:-if not hasattr(mod, item):raise AttributeError(mod._get_name() + " has no " "attribute `" + item + "`")diff --git a/kornia/augmentation/container/image.py b/kornia/augmentation/container/image.pyindex f689c4672..ed0fd1ada 100644--- a/kornia/augmentation/container/image.py+++ b/kornia/augmentation/container/image.py@@ -364,7 +364,6 @@ class ImageSequential(SequentialBase):def forward(self, input: Tensor, params: Optional[List[ParamItem]] = None, extra_args: Dict[str, Any] = {}) -> Tensor:-self.clear_state()if params is None:diff --git a/kornia/enhance/zca.py b/kornia/enhance/zca.pyindex 2a2860743..a4ad4e188 100644--- a/kornia/enhance/zca.py+++ b/kornia/enhance/zca.py@@ -70,7 +70,6 @@ class ZCAWhitening(Module):detach_transforms: bool = True,compute_inv: bool = False,) -> None:-super().__init__()self.dim = dimdiff --git a/kornia/feature/hynet.py b/kornia/feature/hynet.pyindex 162c7a334..ba38cc9f9 100644--- a/kornia/feature/hynet.py+++ b/kornia/feature/hynet.py@@ -50,7 +50,6 @@ class FilterResponseNorm2d(Module):is_scale: bool = True,is_eps_leanable: bool = False,):-super().__init__()self.num_features = num_featuresdiff --git a/kornia/geometry/boxes.py b/kornia/geometry/boxes.pyindex 31da4e1e6..60facfdef 100644--- a/kornia/geometry/boxes.py+++ b/kornia/geometry/boxes.py@@ -190,7 +190,6 @@ class Boxes:raise_if_not_floating_point: bool = True,mode: str = "vertices_plus",) -> None:-self._N: Optional[List[int]] = Noneif isinstance(boxes, list):diff --git a/kornia/geometry/epipolar/fundamental.py b/kornia/geometry/epipolar/fundamental.pyindex 67e2e0dee..19c6cfe31 100644--- a/kornia/geometry/epipolar/fundamental.py+++ b/kornia/geometry/epipolar/fundamental.py@@ -73,7 +73,6 @@ def normalize_transformation(M: Tensor, eps: float = 1e-8) -> Tensor:def find_fundamental(points1: torch.Tensor, points2: torch.Tensor, weights: Optional[torch.Tensor] = None) -> torch.Tensor:-r"""Compute the fundamental matrix using the DLT formulation.The linear system is solved by using the Weighted Least Squares Solution for the 8 Points algorithm.diff --git a/kornia/nerf/rays.py b/kornia/nerf/rays.pyindex 94caa5035..62dcc8e01 100755--- a/kornia/nerf/rays.py+++ b/kornia/nerf/rays.py@@ -104,7 +104,6 @@ class RaySampler:camera_ids = []points_2d = []for obj in points_2d_camera.values():-# FIXME: Below both world and camera ray directions are calculated. It could be that world ray directions# will not be necessary and can be removed herenum_cams_group, num_points_per_cam_group = obj._points_2d.shape[:2]diff --git a/test/augmentation/test_base.py b/test/augmentation/test_base.pyindex 0c8023d3b..7a1082938 100644--- a/test/augmentation/test_base.py+++ b/test/augmentation/test_base.py@@ -67,7 +67,6 @@ class TestBasicAugmentationBase:) as transform_tensor, patch.object(augmentation, "transform_output_tensor", autospec=True) as transform_output_tensor:-generate_parameters.side_effect = lambda shape: {'degrees': torch.arange(0, shape[0], device=device, dtype=dtype)}@@ -91,7 +90,6 @@ class TestAugmentationBase2D:with patch.object(augmentation, "apply_transform", autospec=True) as apply_transform, patch.object(augmentation, "generate_parameters", autospec=True) as generate_parameters:-# Calling the augmentation with a single tensor shall return the expected tensor using the generated params.params = {'params': {}, 'flags': {'foo': 0}}generate_parameters.return_value = paramsdiff --git a/test/geometry/epipolar/test_common.py b/test/geometry/epipolar/test_common.pyindex f16b0c769..399eb0785 100644--- a/test/geometry/epipolar/test_common.py+++ b/test/geometry/epipolar/test_common.py@@ -8,7 +8,6 @@ import kornia.geometry.epipolar as epidef generate_two_view_random_scene(device: torch.device = torch.device("cpu"), dtype: torch.dtype = torch.float32) -> Dict[str, torch.Tensor]:-num_views: int = 2num_points: int = 30diff --git a/test/geometry/test_quaternion.py b/test/geometry/test_quaternion.pyindex 22dbac1f0..8f435e2ab 100644--- a/test/geometry/test_quaternion.py+++ b/test/geometry/test_quaternion.py@@ -184,7 +184,7 @@ class TestQuaternion:q1 = Quaternion.random(batch_size, device, dtype)m1 = q1.matrix()q2 = Quaternion.from_matrix(m1)- for (qq1, qq2) in zip(q1.data, q2.data):+ for qq1, qq2 in zip(q1.data, q2.data):try:self.assert_close(qq1, qq2)except Exception:diff --git a/test/io/test_load_image.py b/test/io/test_load_image.pyindex 8add14213..78ed74884 100644--- a/test/io/test_load_image.py+++ b/test/io/test_load_image.py@@ -31,7 +31,6 @@ class TestLoadImage:height, width = 4, 5img_np: np.ndarray = create_random_img8(height, width, 3)with tempfile.NamedTemporaryFile() as tmp:-file_path: str = tmp.name + ".png"cv2.imwrite(file_path, img_np)assert os.path.isfile(file_path)@@ -47,7 +46,6 @@ class TestLoadImage:height, width = 4, 5img_np: np.ndarray = create_random_img8(height, width, 3)with tempfile.NamedTemporaryFile() as tmp:-file_path: str = tmp.name + ".png"cv2.imwrite(file_path, img_np)assert os.path.isfile(file_path)@@ -60,7 +58,6 @@ class TestLoadImage:height, width = 4, 5img_np: np.ndarray = create_random_img8(height, width, 3)with tempfile.NamedTemporaryFile() as tmp:-file_path: str = tmp.name + f".{ext}"cv2.imwrite(file_path, img_np)assert os.path.isfile(file_path)@@ -85,7 +82,6 @@ class TestLoadImage:height, width = 4, 5img_np: np.ndarray = create_random_img8(height, width, 1)with tempfile.NamedTemporaryFile() as tmp:-file_path: str = tmp.name + f".{ext}"cv2.imwrite(file_path, img_np)assert os.path.isfile(file_path)diff --git a/test/losses/test_hd.py b/test/losses/test_hd.pyindex 5d2d678c1..e1b300389 100644--- a/test/losses/test_hd.py+++ b/test/losses/test_hd.py@@ -44,9 +44,7 @@ class HausdorffERLossNumpy(nn.Module):eroted = np.zeros_like(bound)for batch in range(len(bound)):-for k in range(self.erosions):-# compute convolution with kerneldilation = convolve(bound[batch], kernel, mode="constant", cval=0.0)