Ë
    DêñiŠ  ã                   óz   — d dl Z d dlmZ d dlmZmZmZmZ d dlm	Z	 ddl
mZmZ ddlmZ ddlmZ  G d	„ d
e«      Zy)é    N)ÚPath)ÚAnyÚCallableÚOptionalÚUnion)ÚTensoré   )Úfind_classesÚmake_dataset)Ú
VideoClips)ÚVisionDatasetc            !       ó  ‡ — e Zd ZdZ	 	 	 	 	 	 	 	 	 	 	 	 ddeeef   dedededee   ded	e	d
ee
   deeeef      dededededededdf ˆ fd„Zedeeef   fd„«       Zdee   deded	e	dee   f
d„Zdefd„Zdedeeeef   fd„Zˆ xZS )ÚUCF101aÙ  
    `UCF101 <https://www.crcv.ucf.edu/data/UCF101.php>`_ dataset.

    UCF101 is an action recognition video dataset.
    This dataset consider every video as a collection of video clips of fixed size, specified
    by ``frames_per_clip``, where the step in frames between each clip is given by
    ``step_between_clips``. The dataset itself can be downloaded from the dataset website;
    annotations that ``annotation_path`` should be pointing to can be downloaded from `here
    <https://www.crcv.ucf.edu/data/UCF101/UCF101TrainTestSplits-RecognitionTask.zip>`_.

    To give an example, for 2 videos with 10 and 15 frames respectively, if ``frames_per_clip=5``
    and ``step_between_clips=5``, the dataset size will be (2 + 3) = 5, where the first two
    elements will come from video 1, and the next three elements from video 2.
    Note that we drop clips which do not have exactly ``frames_per_clip`` elements, so not all
    frames in a video might be present.

    Internally, it uses a VideoClips object to handle clip creation.

    Args:
        root (str or ``pathlib.Path``): Root directory of the UCF101 Dataset.
        annotation_path (str): path to the folder containing the split files;
            see docstring above for download instructions of these files
        frames_per_clip (int): number of frames in a clip.
        step_between_clips (int, optional): number of frames between each clip.
        fold (int, optional): which fold to use. Should be between 1 and 3.
        train (bool, optional): if ``True``, creates a dataset from the train split,
            otherwise from the ``test`` split.
        transform (callable, optional): A function/transform that takes in a TxHxWxC video
            and returns a transformed version.
        output_format (str, optional): The format of the output video tensors (before transforms).
            Can be either "THWC" (default) or "TCHW".

    Returns:
        tuple: A 3-tuple with the following entries:

            - video (Tensor[T, H, W, C] or Tensor[T, C, H, W]): The `T` video frames
            -  audio(Tensor[K, L]): the audio frames, where `K` is the number of channels
               and `L` is the number of points
            - label (int): class of the video clip
    NÚrootÚannotation_pathÚframes_per_clipÚstep_between_clipsÚ
frame_rateÚfoldÚtrainÚ	transformÚ_precomputed_metadataÚnum_workersÚ_video_widthÚ_video_heightÚ_video_min_dimensionÚ_audio_samplesÚoutput_formatÚreturnc                 óì  •— t         ‰| �  |«       d|cxk  rdk  sn t        d|› �«      ‚d}|| _        || _        t        | j                  «      \  | _        }t        | j                  ||d ¬«      | _	        | j                  D �cg c]  }|d   ‘Œ	 }}t        |||||	|
|||||¬«      }|| _        | j                  ||||«      | _        |j                  | j                  «      | _        || _        y c c}w )Nr	   é   z$fold should be between 1 and 3, got )Úavi)Úis_valid_filer   )r   r   r   r   r   r   )ÚsuperÚ__init__Ú
ValueErrorr   r   r
   r   Úclassesr   Úsamplesr   Úfull_video_clipsÚ_select_foldÚindicesÚsubsetÚvideo_clipsr   )Úselfr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Ú
extensionsÚclass_to_idxÚxÚ
video_listr-   Ú	__class__s                        €ú]/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/torchvision/datasets/ucf101.pyr%   zUCF101.__init__6   sú   ø€ ô$ 	‰Ñ˜ÔØ�DŒ~˜AŒ~ÜÐCÀDÀ6ÐJÓKÐKàˆ
ØˆŒ	ØˆŒ
ä%1°$·)±)Ó%<Ñ"ˆŒ�lÜ# D§I¡I¨|¸ZÐW[Ô\ˆŒØ$(§L¡LÖ1˜q�a˜“dÐ1ˆ
Ð1Ü ØØØØØ!Ø#Ø%Ø'Ø!5Ø)Ø'ô
ˆð  !,ˆÔØ×(Ñ(¨°_ÀdÈEÓRˆŒØ&×-Ñ-¨d¯l©lÓ;ˆÔØ"ˆ�ùò) 2s   ÂC1c                 ó.   — | j                   j                  S ©N)r)   Úmetadata©r.   s    r4   r7   zUCF101.metadatah   s   € à×$Ñ$×-Ñ-Ð-ó    r2   c           
      óT  — |rdnd}|› d|d›d�}t         j                  j                  ||«      }t        «       }t	        |«      5 }|j                  «       }	|	D �
cg c]$  }
|
j                  «       j                  d«      d   ‘Œ& }	}
|	D �
cg c];  }
t        j                  j                  | j                  g|
j                  d«      ¢­Ž ‘Œ= }	}
|j                  |	«       d d d «       t        t        |«      «      D �cg c]  }||   |v sŒ|‘Œ }}|S c c}
w c c}
w # 1 sw Y   Œ>xY wc c}w )	Nr   ÚtestÚlistÚ02dz.txtú r   ú/)ÚosÚpathÚjoinÚsetÚopenÚ	readlinesÚstripÚsplitr   ÚupdateÚrangeÚlen)r.   r2   r   r   r   ÚnameÚfÚselected_filesÚfidÚdatar1   Úir+   s                r4   r*   zUCF101._select_foldl   s  € Ù‰w VˆØ��t˜D ˜: TÐ*ˆÜ�G‰G�L‰L˜¨$Ó/ˆÜ›ˆÜ�!‹Wð 	(˜Ø—=‘=“?ˆDØ59Ö:°�A—G‘G“I—O‘O CÓ(¨Ó+Ð:ˆDÐ:ØDHÖI¸q”B—G‘G—L‘L §¡Ð:¨Q¯W©W°S«\Ô:ÐIˆDÐIØ×!Ñ! $Ô'÷		(ô
 $¤C¨
£OÓ4ÖX˜¸
À1¹ÈÒ8W’1ÐXˆÐXØˆùò	 ;ùÚI÷	(ð 	(üò
 Ys7   ÁDÁ)DÂDÂ	A DÃ	DÃ:D%ÄD%Ä
DÄD"c                 ó6   — | j                   j                  «       S r6   )r-   Ú	num_clipsr8   s    r4   Ú__len__zUCF101.__len__y   s   € Ø×Ñ×)Ñ)Ó+Ð+r9   Úidxc                 óÄ   — | j                   j                  |«      \  }}}}| j                  | j                  |      d   }| j                  �| j	                  |«      }|||fS )Nr	   )r-   Úget_clipr(   r+   r   )r.   rT   ÚvideoÚaudioÚinfoÚ	video_idxÚlabels          r4   Ú__getitem__zUCF101.__getitem__|   sb   € Ø(,×(8Ñ(8×(AÑ(AÀ#Ó(FÑ%ˆˆu�d˜IØ—‘˜TŸ\™\¨)Ñ4Ñ5°aÑ8ˆà�>‰>Ð%Ø—N‘N 5Ó)ˆEà�e˜UÐ"Ð"r9   )r	   Nr	   TNNr	   r   r   r   r   ÚTHWC)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ústrr   Úintr   Úboolr   Údictr   r%   Úpropertyr7   r<   r*   rS   Útupler   r\   Ú__classcell__)r3   s   @r4   r   r      st  ø„ ñ'ð\ #$Ø$(ØØØ(,Ø:>ØØØØ$%ØØ#ñ!0#à�C˜�IÑð0#ð ð0#ð ð	0#ð
  ð0#ð ˜S‘Mð0#ð ð0#ð ð0#ð ˜HÑ%ð0#ð  (¨¨S°#¨X©Ñ7ð0#ð ð0#ð ð0#ð ð0#ð "ð0#ð ð0#ð  ð!0#ð" 
õ#0#ðd ð.˜$˜s C˜x™.ò .ó ð.ð t¨C¡yð À3ð Ècð ÐZ^ð ÐcgÐhkÑcló ð,˜ó ,ð#˜sð # u¨V°V¸SÐ-@Ñ'A÷ #r9   r   )r@   Úpathlibr   Útypingr   r   r   r   Útorchr   Úfolderr
   r   Úvideo_utilsr   Úvisionr   r   © r9   r4   ú<module>rp      s+   ðÛ 	Ý ß 1Ó 1å ç .Ý #Ý !ôw#ˆ]õ w#r9   