KORNIA UTILS#
Classes#
- class utils.kornia_utils.CustomKorniaRandAugment(n, policy)[source]#
- Bases: - PolicyAugmentBase- A custom augmentation class that applies randaug as a Kornia augmentation. - Inherits from kornia.augmentation.auto.PolicyAugmentBase. - Parameters:
- n (int) – The number of augmentations to apply. 
- policy – The policy of augmentations to apply. 
 
 - rand_selector#
- A categorical distribution for selecting augmentations randomly. - Type:
- torch.distributions.Categorical 
 
 - _getpolicy()[source]#
- Returns the Kornia augmentation operation based on the name, probability, and magnitude. 
 - get_forward_sequence()[source]#
- Returns the forward sequence of augmentations based on the selected indices or parameters. 
 - compose_subpolicy_sequential(subpolicy)[source]#
- Composes a subpolicy of augmentations sequentially. 
 - forward_parameters(batch_shape)[source]#
- Computes the forward parameters for the augmentations. - Parameters:
- batch_shape (torch.Size) – The shape of the input batch. 
- Returns:
- The forward parameters for the augmentations. 
- Return type:
- List[ParamItem] 
 
 - get_forward_sequence(params=None)[source]#
- Returns the forward sequence of augmentations based on the selected indices or parameters. - Parameters:
- params (List[ParamItem], optional) – The parameters of the augmentations. Defaults to None. 
- Returns:
- The forward sequence of augmentations. 
- Return type:
- List[Tuple[str, kornia.augmentation.auto.operations.ops]] 
 
 
- class utils.kornia_utils.KorniaAugNoGrad(*args, **kwargs)[source]#
- Bases: - AugmentationSequential- A custom augmentation class that applies Kornia augmentations without gradient computation. - Inherits from kornia.augmentation.AugmentationSequential. - Parameters:
- *args – Variable length argument list. 
- **kwargs – Arbitrary keyword arguments. 
 
 
- class utils.kornia_utils.KorniaMultiAug(n_augs, aug_list)[source]#
- Bases: - AugmentationSequential- A custom augmentation class that performs multiple Kornia augmentations. - Parameters:
- n_augs (int) – The number of augmentations to apply. 
- aug_list (List[kornia.augmentation.AugmentationBase2D]) – The list of augmentations to apply. 
 
 
Functions#
- utils.kornia_utils.to_kornia_transform(transform, apply=True, override_p=None)[source]#
- Converts PIL transforms to Kornia transforms. - Parameters:
- transform (transforms.Compose) – The torchvision transform to be converted. 
- apply (bool, optional) – Whether to convert the processed kornia transforms list into a KorniaAugNoGrad object. Defaults to True. 
- override_p (float, optional) – Override the probability of applying the augmentations. Defaults to None (will use the default transform probability). 
 
- Returns:
- The converted Kornia transforms. 
- Return type:
- Union[List[kornia.augmentation.AugmentationBase2D], KorniaAugNoGrad] 
 
- utils.kornia_utils.to_kornia_transform(transform, apply=True, override_p=None)[source]#
- Converts PIL transforms to Kornia transforms. - Parameters:
- transform (transforms.Compose) – The torchvision transform to be converted. 
- apply (bool, optional) – Whether to convert the processed kornia transforms list into a KorniaAugNoGrad object. Defaults to True. 
- override_p (float, optional) – Override the probability of applying the augmentations. Defaults to None (will use the default transform probability). 
 
- Returns:
- The converted Kornia transforms. 
- Return type:
- Union[List[kornia.augmentation.AugmentationBase2D], KorniaAugNoGrad]