Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

Fix Typo: Corrected SUBPLOLICY_CONFIG to SUBPOLICY_CONFIG (#2819)

Harsh Joshic0814d210400
diff --git a/kornia/augmentation/auto/autoaugment/autoaugment.py b/kornia/augmentation/auto/autoaugment/autoaugment.py
index ce302156c..8f5543e34 100644
--- a/kornia/augmentation/auto/autoaugment/autoaugment.py
+++ b/kornia/augmentation/auto/autoaugment/autoaugment.py
@@ -2,14 +2,14 @@ from typing import Iterator, List, Optional, Tuple, Union
from torch.distributions import Categorical
-from kornia.augmentation.auto.base import SUBPLOLICY_CONFIG, PolicyAugmentBase
+from kornia.augmentation.auto.base import SUBPOLICY_CONFIG, PolicyAugmentBase
from kornia.augmentation.auto.operations.policy import PolicySequential
from kornia.augmentation.container.params import ParamItem
from kornia.core import Module, tensor
from . import ops
-imagenet_policy: List[SUBPLOLICY_CONFIG] = [
+imagenet_policy: List[SUBPOLICY_CONFIG] = [
[("posterize", 0.4, 8), ("rotate", 0.6, 9)],
[("solarize", 0.6, 5), ("auto_contrast", 0.6, None)],
[("equalize", 0.8, None), ("equalize", 0.6, None)],
@@ -38,7 +38,7 @@ imagenet_policy: List[SUBPLOLICY_CONFIG] = [
]
-cifar10_policy: List[SUBPLOLICY_CONFIG] = [
+cifar10_policy: List[SUBPOLICY_CONFIG] = [
[("invert", 0.1, None), ("contrast", 0.2, 6)],
[("rotate", 0.7, 2), ("translate_x", 0.3, 9)],
[("sharpness", 0.8, 1), ("sharpness", 0.9, 3)],
@@ -67,7 +67,7 @@ cifar10_policy: List[SUBPLOLICY_CONFIG] = [
]
-svhn_policy: List[SUBPLOLICY_CONFIG] = [
+svhn_policy: List[SUBPOLICY_CONFIG] = [
[("shear_x", 0.9, 4), ("invert", 0.2, None)],
[("shear_y", 0.9, 8), ("invert", 0.7, None)],
[("equalize", 0.6, None), ("solarize", 0.6, 6)],
@@ -119,7 +119,7 @@ class AutoAugment(PolicyAugmentBase):
"""
def __init__(
- self, policy: Union[str, List[SUBPLOLICY_CONFIG]] = "imagenet", transformation_matrix_mode: str = "silent"
+ self, policy: Union[str, List[SUBPOLICY_CONFIG]] = "imagenet", transformation_matrix_mode: str = "silent"
) -> None:
if policy == "imagenet":
_policy = imagenet_policy
@@ -136,7 +136,7 @@ class AutoAugment(PolicyAugmentBase):
selection_weights = tensor([1.0 / len(self)] * len(self))
self.rand_selector = Categorical(selection_weights)
- def compose_subpolicy_sequential(self, subpolicy: SUBPLOLICY_CONFIG) -> PolicySequential:
+ def compose_subpolicy_sequential(self, subpolicy: SUBPOLICY_CONFIG) -> PolicySequential:
return PolicySequential(*[getattr(ops, name)(prob, mag) for name, prob, mag in subpolicy])
def get_forward_sequence(self, params: Optional[List[ParamItem]] = None) -> Iterator[Tuple[str, Module]]:
diff --git a/kornia/augmentation/auto/base.py b/kornia/augmentation/auto/base.py
index b9f74a2dd..175d5880b 100644
--- a/kornia/augmentation/auto/base.py
+++ b/kornia/augmentation/auto/base.py
@@ -12,13 +12,13 @@ from kornia.utils import eye_like
NUMBER = Union[float, int]
OP_CONFIG = Tuple[str, NUMBER, Optional[NUMBER]]
-SUBPLOLICY_CONFIG = List[OP_CONFIG]
+SUBPOLICY_CONFIG = List[OP_CONFIG]
class PolicyAugmentBase(TransformMatrixMinIn, ImageSequentialBase):
"""Policy-based image augmentation."""
- def __init__(self, policy: List[SUBPLOLICY_CONFIG], transformation_matrix_mode: str = "silence") -> None:
+ def __init__(self, policy: List[SUBPOLICY_CONFIG], transformation_matrix_mode: str = "silence") -> None:
policies = self.compose_policy(policy)
super().__init__(*policies)
self._parse_transformation_matrix_mode(transformation_matrix_mode)
@@ -31,11 +31,11 @@ class PolicyAugmentBase(TransformMatrixMinIn, ImageSequentialBase):
self._reset_transform_matrix_state()
return super().clear_state()
- def compose_policy(self, policy: List[SUBPLOLICY_CONFIG]) -> List[PolicySequential]:
+ def compose_policy(self, policy: List[SUBPOLICY_CONFIG]) -> List[PolicySequential]:
"""Compose policy by the provided policy config."""
return [self.compose_subpolicy_sequential(subpolicy) for subpolicy in policy]
- def compose_subpolicy_sequential(self, subpolicy: SUBPLOLICY_CONFIG) -> PolicySequential:
+ def compose_subpolicy_sequential(self, subpolicy: SUBPOLICY_CONFIG) -> PolicySequential:
raise NotImplementedError
def identity_matrix(self, input: Tensor) -> Tensor:
diff --git a/kornia/augmentation/auto/rand_augment/rand_augment.py b/kornia/augmentation/auto/rand_augment/rand_augment.py
index 88c86098e..27236adf0 100644
--- a/kornia/augmentation/auto/rand_augment/rand_augment.py
+++ b/kornia/augmentation/auto/rand_augment/rand_augment.py
@@ -3,7 +3,7 @@ from typing import Dict, Iterator, List, Optional, Tuple, Union, cast
import torch
from torch.distributions import Categorical
-from kornia.augmentation.auto.base import SUBPLOLICY_CONFIG, PolicyAugmentBase
+from kornia.augmentation.auto.base import SUBPOLICY_CONFIG, PolicyAugmentBase
from kornia.augmentation.auto.operations import OperationBase
from kornia.augmentation.auto.operations.policy import PolicySequential
from kornia.augmentation.container.params import ParamItem
@@ -11,7 +11,7 @@ from kornia.core import Module, Tensor
from . import ops
-default_policy: List[SUBPLOLICY_CONFIG] = [
+default_policy: List[SUBPOLICY_CONFIG] = [
[("auto_contrast", 0, 1)],
[("equalize", 0, 1)],
[("invert", 0, 1)],
@@ -58,7 +58,7 @@ class RandAugment(PolicyAugmentBase):
self,
n: int,
m: int,
- policy: Optional[List[SUBPLOLICY_CONFIG]] = None,
+ policy: Optional[List[SUBPOLICY_CONFIG]] = None,
transformation_matrix_mode: str = "silent",
) -> None:
if m <= 0 or m >= 30:
@@ -75,7 +75,7 @@ class RandAugment(PolicyAugmentBase):
self.n = n
self.m = m
- def compose_subpolicy_sequential(self, subpolicy: SUBPLOLICY_CONFIG) -> PolicySequential:
+ def compose_subpolicy_sequential(self, subpolicy: SUBPOLICY_CONFIG) -> PolicySequential:
if len(subpolicy) != 1:
raise RuntimeError(f"Each policy must have only one operation for RandAugment. Got {len(subpolicy)}.")
name, low, high = subpolicy[0]
diff --git a/kornia/augmentation/auto/trivial_augment/trivial_augment.py b/kornia/augmentation/auto/trivial_augment/trivial_augment.py
index 06dd5450f..4a444a262 100644
--- a/kornia/augmentation/auto/trivial_augment/trivial_augment.py
+++ b/kornia/augmentation/auto/trivial_augment/trivial_augment.py
@@ -3,13 +3,13 @@ from typing import Iterator, List, Optional, Tuple
import torch
from torch.distributions import Categorical
-from kornia.augmentation.auto.base import SUBPLOLICY_CONFIG, PolicyAugmentBase
+from kornia.augmentation.auto.base import SUBPOLICY_CONFIG, PolicyAugmentBase
from kornia.augmentation.auto.operations.policy import PolicySequential
from kornia.augmentation.auto.rand_augment import ops
from kornia.augmentation.container.params import ParamItem
from kornia.core import Module
-default_policy: List[SUBPLOLICY_CONFIG] = [
+default_policy: List[SUBPOLICY_CONFIG] = [
# [("identity", 0, 1)],
[("auto_contrast", 0, 1)],
[("equalize", 0, 1)],
@@ -49,7 +49,7 @@ class TrivialAugment(PolicyAugmentBase):
"""
def __init__(
- self, policy: Optional[List[SUBPLOLICY_CONFIG]] = None, transformation_matrix_mode: str = "silent"
+ self, policy: Optional[List[SUBPOLICY_CONFIG]] = None, transformation_matrix_mode: str = "silent"
) -> None:
if policy is None:
_policy = default_policy
@@ -60,7 +60,7 @@ class TrivialAugment(PolicyAugmentBase):
selection_weights = torch.tensor([1.0 / len(self)] * len(self))
self.rand_selector = Categorical(selection_weights)
- def compose_subpolicy_sequential(self, subpolicy: SUBPLOLICY_CONFIG) -> PolicySequential:
+ def compose_subpolicy_sequential(self, subpolicy: SUBPOLICY_CONFIG) -> PolicySequential:
if len(subpolicy) != 1:
raise RuntimeError(f"Each policy must have only one operation for TrivialAugment. Got {len(subpolicy)}.")
name, low, high = subpolicy[0]