Ë
    èÓ^j  ã                   ól   — d dl Z d dlZ e j                  d«       d„ Zd„ Zd„ Zdd„Zd„ Zd„ Zdd	„Z	d
„ Z
y)é    Nz´The 'torchvision.transforms._functional_video' module is deprecated since 0.12 and will be removed in the future. Please use the 'torchvision.transforms.functional' module instead.c                 óº   — t        j                  | «      st        dt        | «      z  «      ‚| j	                  «       dk(  st        d| j                  «       z  «      ‚y)Nzclip should be Tensor. Got %sé   zclip should be 4D. Got %dDT)ÚtorchÚ	is_tensorÚ	TypeErrorÚtypeÚ
ndimensionÚ
ValueErrorÚdim©Úclips    ús/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/torchvision/transforms/_functional_video.pyÚ_is_tensor_video_clipr      sL   € Ü�?‰?˜4Ô ÜÐ7¼$¸t»*ÑDÓEÐEà�?‰?Ó Ò!ÜÐ5¸¿¹»
ÑBÓCÐCàó    c                 ót   — t        | j                  «       «      dk7  rt        d«      ‚| d|||z   …|||z   …f   S )z[
    Args:
        clip (torch.tensor): Video clip to be cropped. Size is (C, T, H, W)
    r   zclip should be a 4D tensor.)ÚlenÚsizer
   )r   ÚiÚjÚhÚws        r   Úcropr      sE   € ô
 ˆ4�9‰9‹;Ó˜1ÒÜÐ5Ó6Ð6Ø��Q˜˜Q™�Y  A¨¡E 	Ð)Ñ*Ð*r   c                 ó”   — t        |«      dk7  rt        d|› �«      ‚t        j                  j                  j                  | ||d¬«      S )Né   z9target size should be tuple (height, width), instead got F)r   ÚmodeÚalign_corners)r   r
   r   ÚnnÚ
functionalÚinterpolate)r   Útarget_sizeÚinterpolation_modes      r   Úresizer"       sJ   € Ü
ˆ;Ó˜1ÒÜÐTÐU`ÐTaÐbÓcÐcÜ�8‰8×Ñ×*Ñ*¨4°kÐHZÐjoÐ*ÓpÐpr   c                 ój   — t        | «      st        d«      ‚t        | ||||«      } t        | ||«      } | S )a  
    Do spatial cropping and resizing to the video clip
    Args:
        clip (torch.tensor): Video clip to be cropped. Size is (C, T, H, W)
        i (int): i in (i,j) i.e coordinates of the upper left corner.
        j (int): j in (i,j) i.e coordinates of the upper left corner.
        h (int): Height of the cropped region.
        w (int): Width of the cropped region.
        size (tuple(int, int)): height and width of resized clip
    Returns:
        clip (torch.tensor): Resized and cropped clip. Size is (C, T, H, W)
    ú clip should be a 4D torch.tensor)r   r
   r   r"   )r   r   r   r   r   r   r!   s          r   Úresized_cropr%   &   s>   € ô ! Ô&ÜÐ;Ó<Ð<Ü��a˜˜A˜qÓ!€DÜ�$˜Ð0Ó1€DØ€Kr   c                 ó,  — t        | «      st        d«      ‚| j                  d«      | j                  d«      }}|\  }}||k  s||k  rt        d«      ‚t        t	        ||z
  dz  «      «      }t        t	        ||z
  dz  «      «      }t        | ||||«      S )Nr$   éþÿÿÿéÿÿÿÿz2height and width must be no smaller than crop_sizeg       @)r   r
   r   ÚintÚroundr   )r   Ú	crop_sizer   r   ÚthÚtwr   r   s           r   Úcenter_cropr.   :   s’   € Ü  Ô&ÜÐ;Ó<Ð<Ø�9‰9�R‹=˜$Ÿ)™) B›-€q€AØ�F€BˆØˆ2‚v��R’ÜÐMÓNÐNäŒE�1�r‘6˜S‘.Ó!Ó"€AÜŒE�1�r‘6˜S‘.Ó!Ó"€AÜ��a˜˜B Ó#Ð#r   c                 óÞ   — t        | «       | j                  t        j                  k(  s!t	        dt        | j                  «      z  «      ‚| j                  «       j                  dddd«      dz  S )a  
    Convert tensor data type from uint8 to float, divide value by 255.0 and
    permute the dimensions of clip tensor
    Args:
        clip (torch.tensor, dtype=torch.uint8): Size is (T, H, W, C)
    Return:
        clip (torch.tensor, dtype=torch.float): Size is (C, T, H, W)
    z/clip tensor should have data type uint8. Got %sé   r   é   r   g     ào@)r   Údtyper   Úuint8r   ÚstrÚfloatÚpermuter   s    r   Ú	to_tensorr7   G   sZ   € ô ˜$ÔØ�:‰:œŸ™Ò$ÜÐIÌCÐPT×PZÑPZËOÑ[Ó\Ð\Ø�:‰:‹<×Ñ  1 a¨Ó+¨eÑ3Ð3r   c                 ój  — t        | «      st        d«      ‚|s| j                  «       } t        j                  || j
                  | j                  ¬«      }t        j                  || j
                  | j                  ¬«      }| j                  |dd…dddf   «      j                  |dd…dddf   «       | S )a  
    Args:
        clip (torch.tensor): Video clip to be normalized. Size is (C, T, H, W)
        mean (tuple): pixel RGB mean. Size is (3)
        std (tuple): pixel standard deviation. Size is (3)
    Returns:
        normalized clip (torch.tensor): Size is (C, T, H, W)
    r$   )r2   ÚdeviceN)	r   r
   Úcloner   Ú	as_tensorr2   r9   Úsub_Údiv_)r   ÚmeanÚstdÚinplaces       r   Ú	normalizerA   V   s’   € ô ! Ô&ÜÐ;Ó<Ð<ÙØ�z‰z‹|ˆÜ�?‰?˜4 t§z¡z¸$¿+¹+ÔF€DÜ
�/‰/˜# T§Z¡Z¸¿¹Ô
D€CØ‡I�Iˆd’1�d˜D $Ð&Ñ'Ó(×-Ñ-¨c²!°T¸4ÀÐ2EÑ.FÔGØ€Kr   c                 óP   — t        | «      st        d«      ‚| j                  d«      S )z¥
    Args:
        clip (torch.tensor): Video clip to be normalized. Size is (C, T, H, W)
    Returns:
        flipped clip (torch.tensor): Size is (C, T, H, W)
    r$   r(   )r   r
   Úflipr   s    r   ÚhfliprD   i   s&   € ô ! Ô&ÜÐ;Ó<Ð<Ø�9‰9�R‹=Ðr   )Úbilinear)F)Úwarningsr   Úwarnr   r   r"   r%   r.   r7   rA   rD   © r   r   ú<module>rI      sJ   ðÛ ã ð €‡�ðIôòò+òqóò(
$ò4óó&	r   