a
    d9%                     @  s   d dl mZ d dlmZmZmZmZmZ d dlZd dl	m
Z
 ddlmZmZ G dd deZeejef ZejZeejef ZejZdS )	    )annotations)AnyListOptionalTupleUnionN)InterpolationMode   )_FillTypeJIT	Datapointc                
   @  s  e Zd ZdZedd dddZdddddd	d
dd dddZed dd dddZdddddddZe	ddddZ
e	ddddZe	ddddZd dd d!Zd dd"d#Zejdd$fd%d&d'd(d d)d*d+Zddddd d,d-d.Zd%d d/d0d1Zejd$fddddd%d&d(d d2d3d4Zdvd%d6dd d7d8d9Zejd:ddfd;d&d<d=d>d d?d@dAZejddfdBdCd;dCd&d>d=d dDdEdFZejddfdGdGd&d>d=d dHdIdJZejdfdd&d>d dKdLdMZdwdd dOdPdQZd;d dRdSdTZd;d dUdVdWZd;d dXdYdZZd;d d[d\d]Zd;d d^d_d`Z dxd;d;d dadbdcZ!dd dddedfZ"d;d dgdhdiZ#d ddjdkZ$d ddldmZ%d ddndoZ&dyd%d=d dpdqdrZ'dzdCdCd<d dsdtduZ(dS ){Videoa  [BETA] :class:`torch.Tensor` subclass for videos.

    Args:
        data (tensor-like): Any data that can be turned into a tensor with :func:`torch.as_tensor`.
        dtype (torch.dtype, optional): Desired data type of the bounding box. If omitted, will be inferred from
            ``data``.
        device (torch.device, optional): Desired device of the bounding box. If omitted and ``data`` is a
            :class:`torch.Tensor`, the device is taken from it. Otherwise, the bounding box is constructed on the CPU.
        requires_grad (bool, optional): Whether autograd should record operations on the bounding box. If omitted and
            ``data`` is a :class:`torch.Tensor`, the value is taken from it. Otherwise, defaults to ``False``.
    ztorch.Tensor)tensorreturnc                 C  s   | | }|S N)as_subclass)clsr   video r   f/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/torchvision/datapoints/_video.py_wrap   s    
zVideo._wrapNdtypedevicerequires_gradr   zOptional[torch.dtype]z'Optional[Union[torch.device, str, int]]zOptional[bool])datar   r   r   r   c                C  s*   | j ||||d}|jdk r t| |S )Nr      )Z
_to_tensorndim
ValueErrorr   )r   r   r   r   r   r   r   r   r   __new__   s    
zVideo.__new__)otherr   r   c                 C  s
   |  |S r   )r   )r   r   r   r   r   r   	wrap_like*   s    zVideo.wrap_like)tensor_contentsstr)r!   r   c                C  s   |   S r   )Z
_make_repr)selfr!   r   r   r   __repr__.   s    zVideo.__repr__zTuple[int, int])r   c                 C  s   t | jdd  S )N)tupleshaper#   r   r   r   spatial_size1   s    zVideo.spatial_sizeintc                 C  s
   | j d S )Nr'   r(   r   r   r   num_channels5   s    zVideo.num_channelsc                 C  s
   | j d S )Nr,   r(   r   r   r   
num_frames9   s    zVideo.num_framesc                 C  s    | j | tj}t| |S r   )_FZhorizontal_flip_videor   torchTensorr   r    r#   outputr   r   r   horizontal_flip=   s    zVideo.horizontal_flipc                 C  s    | j | tj}t| |S r   )r0   Zvertical_flip_videor   r1   r2   r   r    r3   r   r   r   vertical_flipA   s    zVideo.vertical_flipwarnz	List[int]zUnion[InterpolationMode, int]zOptional[int]zOptional[Union[str, bool]])sizeinterpolationmax_size	antialiasr   c                 C  s*   | j j| tj||||d}t| |S )N)r9   r:   r;   )r0   Zresize_videor   r1   r2   r   r    )r#   r8   r9   r:   r;   r4   r   r   r   resizeE   s    
zVideo.resize)topleftheightwidthr   c                 C  s(   | j | tj||||}t| |S r   )r0   Z
crop_videor   r1   r2   r   r    )r#   r=   r>   r?   r@   r4   r   r   r   cropU   s    z
Video.crop)output_sizer   c                 C  s$   | j j| tj|d}t| |S )N)rB   )r0   Zcenter_crop_videor   r1   r2   r   r    )r#   rB   r4   r   r   r   center_cropY   s    zVideo.center_crop)r=   r>   r?   r@   r8   r9   r;   r   c           	   
   C  s4   | j j| tj||||t|||d}t| |S )N)r8   r9   r;   )r0   Zresized_crop_videor   r1   r2   listr   r    )	r#   r=   r>   r?   r@   r8   r9   r;   r4   r   r   r   resized_crop]   s    


zVideo.resized_cropconstantz(Optional[Union[int, float, List[float]]])paddingfillpadding_moder   c                 C  s(   | j j| tj|||d}t| |S )N)rH   rI   )r0   Z	pad_videor   r1   r2   r   r    )r#   rG   rH   rI   r4   r   r   r   pads   s    z	Video.padFfloatboolzOptional[List[float]]r
   )angler9   expandcenterrH   r   c                 C  s,   | j j| tj|||||d}t| |S )N)r9   rN   rH   rO   )r0   Zrotate_videor   r1   r2   r   r    )r#   rM   r9   rN   rO   rH   r4   r   r   r   rotate|   s    zVideo.rotatezUnion[int, float]zList[float])rM   	translatescaleshearr9   rH   rO   r   c           	   
   C  s0   | j j| tj|||||||d}t| |S )N)rQ   rR   rS   r9   rH   rO   )r0   Zaffine_videor   r1   r2   r   r    )	r#   rM   rQ   rR   rS   r9   rH   rO   r4   r   r   r   affine   s    


zVideo.affinezOptional[List[List[int]]])startpoints	endpointsr9   rH   coefficientsr   c                 C  s,   | j j| tj|||||d}t| |S )N)r9   rH   rW   )r0   Zperspective_videor   r1   r2   r   r    )r#   rU   rV   r9   rH   rW   r4   r   r   r   perspective   s    
zVideo.perspective)displacementr9   rH   r   c                 C  s(   | j j| tj|||d}t| |S )N)r9   rH   )r0   Zelastic_videor   r1   r2   r   r    )r#   rY   r9   rH   r4   r   r   r   elastic   s    zVideo.elasticr	   )num_output_channelsr   c                 C  s$   | j j| tj|d}t| |S )N)r[   )r0   Zrgb_to_grayscale_image_tensorr   r1   r2   r   r    )r#   r[   r4   r   r   r   rgb_to_grayscale   s    zVideo.rgb_to_grayscale)brightness_factorr   c                 C  s$   | j j| tj|d}t| |S )N)r]   )r0   Zadjust_brightness_videor   r1   r2   r   r    )r#   r]   r4   r   r   r   adjust_brightness   s    zVideo.adjust_brightness)saturation_factorr   c                 C  s$   | j j| tj|d}t| |S )N)r_   )r0   Zadjust_saturation_videor   r1   r2   r   r    )r#   r_   r4   r   r   r   adjust_saturation   s    zVideo.adjust_saturation)contrast_factorr   c                 C  s$   | j j| tj|d}t| |S )N)ra   )r0   Zadjust_contrast_videor   r1   r2   r   r    )r#   ra   r4   r   r   r   adjust_contrast   s    zVideo.adjust_contrast)sharpness_factorr   c                 C  s$   | j j| tj|d}t| |S )N)rc   )r0   Zadjust_sharpness_videor   r1   r2   r   r    )r#   rc   r4   r   r   r   adjust_sharpness   s    zVideo.adjust_sharpness)
hue_factorr   c                 C  s$   | j j| tj|d}t| |S )N)re   )r0   Zadjust_hue_videor   r1   r2   r   r    )r#   re   r4   r   r   r   
adjust_hue   s    zVideo.adjust_hue)gammagainr   c                 C  s&   | j j| tj||d}t| |S )N)rg   rh   )r0   Zadjust_gamma_videor   r1   r2   r   r    )r#   rg   rh   r4   r   r   r   adjust_gamma   s    zVideo.adjust_gamma)bitsr   c                 C  s$   | j j| tj|d}t| |S )N)rj   )r0   Zposterize_videor   r1   r2   r   r    )r#   rj   r4   r   r   r   	posterize   s    zVideo.posterize)	thresholdr   c                 C  s$   | j j| tj|d}t| |S )N)rl   )r0   Zsolarize_videor   r1   r2   r   r    )r#   rl   r4   r   r   r   solarize   s    zVideo.solarizec                 C  s    | j | tj}t| |S r   )r0   Zautocontrast_videor   r1   r2   r   r    r3   r   r   r   autocontrast   s    zVideo.autocontrastc                 C  s    | j | tj}t| |S r   )r0   Zequalize_videor   r1   r2   r   r    r3   r   r   r   equalize   s    zVideo.equalizec                 C  s    | j | tj}t| |S r   )r0   Zinvert_videor   r1   r2   r   r    r3   r   r   r   invert   s    zVideo.invert)kernel_sizesigmar   c                 C  s&   | j j| tj||d}t| |S )N)rq   rr   )r0   Zgaussian_blur_videor   r1   r2   r   r    )r#   rq   rr   r4   r   r   r   gaussian_blur   s    zVideo.gaussian_blur)meanstdinplacer   c                 C  s(   | j j| tj|||d}t| |S )N)rt   ru   rv   )r0   Znormalize_videor   r1   r2   r   r    )r#   rt   ru   rv   r4   r   r   r   	normalize   s    zVideo.normalize)NrF   )r	   )r	   )N)F))__name__
__module____qualname____doc__classmethodr   r   r    r$   propertyr)   r-   r/   r5   r6   r   ZBILINEARr<   rA   rC   rE   rJ   ZNEARESTrP   rT   rX   rZ   r\   r^   r`   rb   rd   rf   ri   rk   rm   rn   ro   rp   rs   rw   r   r   r   r   r      sx     r   )
__future__r   typingr   r   r   r   r   r1   Z!torchvision.transforms.functionalr   Z
_datapointr
   r   r   r2   Z
_VideoTypeZ_VideoTypeJITZ_TensorVideoTypeZ_TensorVideoTypeJITr   r   r   r   <module>   s    m