π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-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.pyindex 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, Unionfrom torch.distributions import Categorical-from kornia.augmentation.auto.base import SUBPLOLICY_CONFIG, PolicyAugmentBase+from kornia.augmentation.auto.base import SUBPOLICY_CONFIG, PolicyAugmentBasefrom kornia.augmentation.auto.operations.policy import PolicySequentialfrom kornia.augmentation.container.params import ParamItemfrom kornia.core import Module, tensorfrom . 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.pyindex b9f74a2dd..175d5880b 100644--- a/kornia/augmentation/auto/base.py+++ b/kornia/augmentation/auto/base.py@@ -12,13 +12,13 @@ from kornia.utils import eye_likeNUMBER = 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 NotImplementedErrordef 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.pyindex 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, castimport torchfrom torch.distributions import Categorical-from kornia.augmentation.auto.base import SUBPLOLICY_CONFIG, PolicyAugmentBase+from kornia.augmentation.auto.base import SUBPOLICY_CONFIG, PolicyAugmentBasefrom kornia.augmentation.auto.operations import OperationBasefrom kornia.augmentation.auto.operations.policy import PolicySequentialfrom kornia.augmentation.container.params import ParamItem@@ -11,7 +11,7 @@ from kornia.core import Module, Tensorfrom . 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 = nself.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.pyindex 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, Tupleimport torchfrom torch.distributions import Categorical-from kornia.augmentation.auto.base import SUBPLOLICY_CONFIG, PolicyAugmentBase+from kornia.augmentation.auto.base import SUBPOLICY_CONFIG, PolicyAugmentBasefrom kornia.augmentation.auto.operations.policy import PolicySequentialfrom kornia.augmentation.auto.rand_augment import opsfrom kornia.augmentation.container.params import ParamItemfrom 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]