Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

Fix mypy check

Jian Sbd30f1def4b4
diff --git a/docs/source/augmentation.rst b/docs/source/augmentation.rst
index 6678dba09..4b1d222e2 100644
--- a/docs/source/augmentation.rst
+++ b/docs/source/augmentation.rst
@@ -14,6 +14,8 @@ The classes in this section perform various data augmentation operations
.. autoclass:: RandomRotation
.. autoclass:: ColorJitter
.. autoclass:: CenterCrop
+.. autoclass:: RandomCrop
+.. autoclass:: RandomResizedCrop
.. automodule:: kornia.augmentation.functional
:members:
diff --git a/kornia/augmentation/augmentation.py b/kornia/augmentation/augmentation.py
index 61cf99b76..694bd5104 100644
--- a/kornia/augmentation/augmentation.py
+++ b/kornia/augmentation/augmentation.py
@@ -470,7 +470,7 @@ class RandomCrop(AugmentationBase):
def get_params(batch_size: int, input_size: Tuple[int, int], size: Tuple[int, int]) -> Dict[str, torch.Tensor]:
return pg._random_crop_gen(batch_size, input_size, size)
- def precrop_padding(self, input: torch.Tensor):
+ def precrop_padding(self, input: torch.Tensor) -> torch.Tensor:
if self.padding is not None:
if isinstance(self.padding, int):
@@ -535,9 +535,9 @@ class RandomResizedCrop(AugmentationBase):
@staticmethod
def get_params(batch_size: int, input_size: Tuple[int, int], size: Tuple[int, int],
- scale=(0.08, 1.0), ratio=(3. / 4., 4. / 3.)) -> Dict[str, torch.Tensor]:
+ scale: Tuple[float, float] = (0.08, 1.0), ratio: Tuple[float, float] = (3. / 4., 4. / 3.)
+ ) -> Dict[str, torch.Tensor]: # type: ignore
target_size = pg._random_crop_size_gen(size, scale, ratio)
- print(target_size)
# TODO: scale and aspect ratio were fixed for one batch for now. Need to be separated.
return pg._random_crop_gen(batch_size, input_size, target_size, resize_to=size)
@@ -549,5 +549,5 @@ class RandomResizedCrop(AugmentationBase):
else:
batch_shape = input.shape
params = RandomResizedCrop.get_params(
- batch_size, batch_shape[-2:], self.size, self.scale, self.ratio) # type: ignore
+ batch_size, batch_shape[-2:], self.size, self.scale, self.ratio)
return super().forward(input, params)
diff --git a/mypy_files.txt b/mypy_files.txt
index 0978b978a..f0872569f 100644
--- a/mypy_files.txt
+++ b/mypy_files.txt
@@ -10,6 +10,11 @@ kornia/filters/gaussian.py
kornia/filters/laplacian.py
kornia/filters/median.py
kornia/filters/sobel.py
+kornia/augmentation/augmentation.py
+kornia/augmentation/erasing.py
+kornia/augmentation/functional.py
+kornia/augmentation/param_gen.py
+kornia/augmentation/utils.py
kornia/geometry/conversions.py
kornia/geometry/linalg.py
kornia/geometry/camera/pinhole.py