Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

[pre-commit.ci] pre-commit suggestions (#1833)

pre-commit-ci[bot]09ac8f086346
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 12cf1c0ba..a9c8d3404 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -17,12 +17,12 @@ repos:
exclude: ^$|.devcontainer
- repo: https://github.com/psf/black
- rev: 22.6.0
+ rev: 22.8.0
hooks:
- id: black
- repo: https://github.com/codespell-project/codespell
- rev: v2.1.0
+ rev: v2.2.1
hooks:
- id: codespell
args:
@@ -63,7 +63,7 @@ repos:
- "B101,B311"
- repo: https://github.com/myint/docformatter
- rev: v1.5.0-rc1
+ rev: v1.5.0
hooks:
- id: docformatter
args: [--in-place, --wrap-summaries=115, --wrap-descriptions=120]
diff --git a/kornia/augmentation/container/image.py b/kornia/augmentation/container/image.py
index c8aa8ecd5..9fc5f1a8f 100644
--- a/kornia/augmentation/container/image.py
+++ b/kornia/augmentation/container/image.py
@@ -31,7 +31,7 @@ class ImageSequential(SequentialBase):
keepdim: whether to keep the output shape the same as input (True) or broadcast it
to the batch form (False). If None, it will not overwrite the function-wise settings.
random_apply: randomly select a sublist (order agnostic) of args to
- apply transformation. The selection probablity aligns to the ``random_apply_weights``.
+ apply transformation. The selection probability aligns to the ``random_apply_weights``.
If int, a fixed number of transformations will be selected.
If (a,), x number of transformations (a <= x <= len(args)) will be selected.
If (a, b), x number of transformations (a <= x <= b) will be selected.
diff --git a/kornia/color/raw.py b/kornia/color/raw.py
index 977eb93c7..ae610b307 100644
--- a/kornia/color/raw.py
+++ b/kornia/color/raw.py
@@ -123,16 +123,16 @@ def raw_to_rgb(image: torch.Tensor, cfa: CFA) -> torch.Tensor:
# for a 2x2 bayer filter
gpadded = torch.nn.functional.pad(image, [1, 1, 1, 1], 'reflect')
- ru = torch.nn.functional.interpolate(
+ r_up = torch.nn.functional.interpolate(
rpadded, size=(image.shape[-2] + 1, image.shape[-1] + 1), mode='bilinear', align_corners=True
)
- bu = torch.nn.functional.interpolate(
+ b_up = torch.nn.functional.interpolate(
bpadded, size=(image.shape[-2] + 1, image.shape[-1] + 1), mode='bilinear', align_corners=True
)
# remove the extra padding
- ru = torch.nn.functional.pad(ru, [-x for x in rpad])
- bu = torch.nn.functional.pad(bu, [-x for x in bpad])
+ r_up = torch.nn.functional.pad(r_up, [-x for x in rpad])
+ b_up = torch.nn.functional.pad(b_up, [-x for x in bpad])
# all unknown pixels are the average of the nearby green samples
kernel = torch.tensor(
@@ -140,30 +140,30 @@ def raw_to_rgb(image: torch.Tensor, cfa: CFA) -> torch.Tensor:
)
# This is done on all samples but result for the known green samples is then overwritten by the input
- gu = torch.nn.functional.conv2d(gpadded, kernel)
+ g_up = torch.nn.functional.conv2d(gpadded, kernel)
# overwrite the already known samples which otherwise have values from r/b
# this depends on the CFA configuration
if cfa == CFA.BG:
- gu[:, :, ::2, 1::2] = image[:, :, ::2, 1::2]
- gu[:, :, 1::2, ::2] = image[:, :, 1::2, ::2]
+ g_up[:, :, ::2, 1::2] = image[:, :, ::2, 1::2]
+ g_up[:, :, 1::2, ::2] = image[:, :, 1::2, ::2]
elif cfa == CFA.GB:
- gu[:, :, ::2, ::2] = image[:, :, ::2, ::2]
- gu[:, :, 1::2, 1::2] = image[:, :, 1::2, 1::2]
+ g_up[:, :, ::2, ::2] = image[:, :, ::2, ::2]
+ g_up[:, :, 1::2, 1::2] = image[:, :, 1::2, 1::2]
elif cfa == CFA.RG:
- gu[:, :, 1::2, ::2] = image[:, :, 1::2, ::2]
- gu[:, :, ::2, 1::2] = image[:, :, ::2, 1::2]
+ g_up[:, :, 1::2, ::2] = image[:, :, 1::2, ::2]
+ g_up[:, :, ::2, 1::2] = image[:, :, ::2, 1::2]
elif cfa == CFA.GR:
- gu[:, :, 1::2, 1::2] = image[:, :, 1::2, 1::2]
- gu[:, :, ::2, ::2] = image[:, :, ::2, ::2]
+ g_up[:, :, 1::2, 1::2] = image[:, :, 1::2, 1::2]
+ g_up[:, :, ::2, ::2] = image[:, :, ::2, ::2]
else:
raise ValueError(f"Unsupported CFA " f"Got {cfa}.")
- ru = ru.view(imagesize)
- gu = gu.view(imagesize)
- bu = bu.view(imagesize)
+ r_up = r_up.view(imagesize)
+ g_up = g_up.view(imagesize)
+ b_up = b_up.view(imagesize)
- rgb: torch.Tensor = torch.cat([ru, gu, bu], dim=-3)
+ rgb: torch.Tensor = torch.cat([r_up, g_up, b_up], dim=-3)
return rgb
diff --git a/kornia/contrib/vit.py b/kornia/contrib/vit.py
index c39602c32..5fa38be2d 100644
--- a/kornia/contrib/vit.py
+++ b/kornia/contrib/vit.py
@@ -41,7 +41,7 @@ class MultiHeadAttention(nn.Module):
super().__init__()
self.emb_size = emb_size
self.num_heads = num_heads
- head_size = emb_size // num_heads # fom timm
+ head_size = emb_size // num_heads # from timm
self.scale = head_size**-0.5 # from timm
# fuse the queries, keys and values in one matrix
diff --git a/kornia/feature/loftr/utils/coarse_matching.py b/kornia/feature/loftr/utils/coarse_matching.py
index 1881eaedb..ca152c835 100644
--- a/kornia/feature/loftr/utils/coarse_matching.py
+++ b/kornia/feature/loftr/utils/coarse_matching.py
@@ -62,7 +62,7 @@ class CoarseMatching(nn.Module):
# general config
self.thr = config['thr']
self.border_rm = config['border_rm']
- # -- # for trainig fine-level LoFTR
+ # -- # for training fine-level LoFTR
self.train_coarse_percent = config['train_coarse_percent']
self.train_pad_num_gt_min = config['train_pad_num_gt_min']
diff --git a/kornia/filters/canny.py b/kornia/filters/canny.py
index dacaf7b2c..f5a2af3eb 100644
--- a/kornia/filters/canny.py
+++ b/kornia/filters/canny.py
@@ -108,7 +108,7 @@ def canny(
negative_idx: torch.Tensor = ((angle / 45) + 4) % 8
negative_idx = negative_idx.long()
- # Apply the non-maximum suppresion to the different directions
+ # Apply the non-maximum suppression to the different directions
channel_select_filtered_positive: torch.Tensor = torch.gather(nms_magnitude, 1, positive_idx)
channel_select_filtered_negative: torch.Tensor = torch.gather(nms_magnitude, 1, negative_idx)