o
    ϯiB                     @   st   d dl mZmZmZ d dlZd dlmZ d dlmZ ddddddddddd	d	d
d
dZ	dd ddZ
G dd dZdS )    )AnyDictOptionalN)AugmentTransform)	OpSampler)   g?)r      )   r	   )r   r   )r   g333333?)r   g?)AdjustBrightnessAdjustContrastAdjustSaturationAdjustSharpnessAutoContrastEqualizeInvertRotate	PosterizeSolarizeShearXShearY
TranslateX
TranslateYint      ?)sampling_data_typesampling_minsampling_stdc                   @   sr   e Zd ZdZ						ddeded	ed
eeee	f  dedeeee	f  ddfddZ
dejdejfddZdS )RandAugmentz
    This implements RandAugment for video. Assume the input video tensor with shape
    (T, C, H, W).

    RandAugment: Practical automated data augmentation with a reduced search space
    (https://arxiv.org/abs/1909.13719)
    	      r   Ngaussian	magnitude
num_layersprobtransform_hparassampling_typesampling_hparasreturnc                    s\   dv sJ p	t dkrdv sJ  fddtt D }t||d| _dS )aX  
        This implements RandAugment for video.

        Args:
            magnitude (int): Magnitude used for transform function.
            num_layers (int): How many transform functions to apply for each
                augmentation.
            prob (float): The probablity of applying each transform function.
            transform_hparas (Optional[Dict[Any]]): Transform hyper parameters.
                Needs to have key fill. By default, it uses transform_default_hparas.
            sampling_type (str): Sampling method for magnitude of transform. It should
                be either gaussian or uniform.
            sampling_hparas (Optional[Dict[Any]]): Hyper parameters for sampling. If
                gaussian sampling is used, it needs to have key sampling_std. By
                default, it uses SAMPLING_RANDAUG_DEFAULT_HPARAS.
        )r    uniformr    r   c                    s"   g | ]}t | td qS ))r#   transform_max_parasr$   r%   r&   )r   _TRANSFORM_RANDAUG_MAX_PARAMS).0transform_namer!   r#   r&   r%   r$    X/home/ubuntu/.local/lib/python3.10/site-packages/pytorchvideo/transforms/rand_augment.py
<listcomp>P   s    
z(RandAugment.__init__.<locals>.<listcomp>)num_sample_opN)SAMPLING_RANDAUG_DEFAULT_HPARASlistr*   keysr   
randaug_fn)selfr!   r"   r#   r$   r%   r&   r5   r.   r-   r/   __init__2   s   

zRandAugment.__init__videoc                 C   s
   |  |S )z
        Perform RandAugment to the input video tensor.

        Args:
            video (torch.Tensor): Input video tensor with shape (T, C, H, W).
        )r5   )r6   r8   r.   r.   r/   __call__^   s   
zRandAugment.__call__)r   r   r   Nr    N)__name__
__module____qualname____doc__r   floatr   r   strr   r7   torchTensorr9   r.   r.   r.   r/   r   )   s0    

,r   )typingr   r   r   r@   %pytorchvideo.transforms.augmentationsr   "pytorchvideo.transforms.transformsr   r*   r2   r   r.   r.   r.   r/   <module>   s0   