ó
    EñiŠ  ã                   óz   • S SK r S SKJr  S SKJrJrJrJr  S SKJ	r	  SSK
JrJr  SSKJr  SSKJr   " S	 S
\5      rg)é    N)ÚPath)ÚAnyÚCallableÚOptionalÚUnion)ÚTensoré   )Úfind_classesÚmake_dataset)Ú
VideoClips)ÚVisionDatasetc            !       ó*  ^ • \ rS rSrSr            SS\\\4   S\S\S\S\	\   S	\S
\
S\	\   S\	\\\4      S\S\S\S\S\S\SS4 U 4S jjjr\S\\\4   4S j5       rS\\   S\S	\S
\
S\\   4
S jrS\4S jrS\S\\\\4   4S jrSrU =r$ )ÚUCF101é   aU  
`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U ]  U5        SUs=::  a  S::  d  O  [        SU 35      eSnX`l        Xpl        [        U R                  5      u  U l        n[        U R                  UUS S9U l	        U R                   Vs/ s H  nUS   PM
     nn[        UUUUU	U
UUUUUS9nUU l        U R                  UX&U5      U l        UR                  U R                  5      U l        X€l        g s  snf )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                        €ÚX/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torchvision/datasets/ucf101.pyr&   ÚUCF101.__init__6   só   ø€ ô$ 	‰Ñ˜ÔØ�D�~˜A�~ÜÐCÀDÀ6ÐJÓKÐKàˆ
ØŒ	ØŒ
ä%1°$·)±)Ó%<Ñ"ˆŒ�lÜ# D§I¡I¨|¸ZÐW[Ñ\ˆŒØ$(§L¢LÓ1¢L˜q�a˜”d¡Lˆ
Ð1Ü ØØØØØ!Ø#Ø%Ø'Ø!5Ø)Ø'ñ
ˆð  !,ˆÔØ×(Ñ(¨°_ÈEÓRˆŒØ&×-Ñ-¨d¯l©lÓ;ˆÔØ"�ùò) 2s   ÂC,c                 ó.   • U R                   R                  $ ©N)r*   Úmetadata©r/   s    r5   r9   ÚUCF101.metadatah   s   € à×$Ñ$×-Ñ-Ð-ó    r3   c           
      ó|  • U(       a  SOSnU SUS S3n[         R                  R                  X%5      n[        5       n[	        U5       nUR                  5       n	U	 V
s/ s H$  oªR                  5       R                  S5      S   PM&     n	n
U	 V
s/ s H=  n
[         R                  R                  " U R                  /U
R                  S5      Q76 PM?     n	n
UR                  U	5        S S S 5        [        [        U5      5       Vs/ s H  o±U   U;   d  M  UPM     nnU$ s  sn
f s  sn
f ! , (       d  f       NH= fs  snf )	Nr   ÚtestÚlistÚ02dz.txtÚ r   Ú/)ÚosÚpathÚjoinÚsetÚopenÚ	readlinesÚstripÚsplitr   ÚupdateÚrangeÚlen)r/   r3   r   r   r   ÚnameÚfÚselected_filesÚfidÚdatar2   Úir,   s                r5   r+   ÚUCF101._select_foldl   sû   € Þ‰w VˆØ��t˜D ˜: TÐ*ˆÜ�G‰G�L‰L˜Ó/ˆÜ›ˆÜ�!ŒW˜Ø—=‘=“?ˆDÙ59Ó:²T°—G‘G“I—O‘O CÓ(¨Ô+±TˆDÐ:ÙDHÓIÂD¸q”B—G‘G—L’L §¡Ð:¨Q¯W©W°S«\Õ:ÁDˆDÐIØ×!Ñ! $Ô'÷	 ô
 $¤C¨
£OÔ4ÓXÒ4˜À1¹ÈÑ8W—1Ñ4ˆÐXØˆùò	 ;ùÚI÷ �Wüò
 Ys7   Á	D(Á+DÂ	D(ÂAD#ÃD(ÄD9ÄD9Ä
D(Ä(
D6c                 ó6   • U R                   R                  5       $ r8   )r.   Ú	num_clipsr:   s    r5   Ú__len__ÚUCF101.__len__y   s   € Ø×Ñ×)Ñ)Ó+Ð+r<   Úidxc                 óÀ   • U R                   R                  U5      u  p#pEU R                  U R                  U      S   nU R                  b  U R	                  U5      nX#U4$ )Nr	   )r.   Úget_clipr)   r,   r   )r/   rY   ÚvideoÚaudioÚinfoÚ	video_idxÚlabels          r5   Ú__getitem__ÚUCF101.__getitem__|   s\   € Ø(,×(8Ñ(8×(AÑ(AÀ#Ó(FÑ%ˆ�dØ—‘˜TŸ\™\¨)Ñ4Ñ5°aÑ8ˆà�>‰>Ñ%Ø—N‘N 5Ó)ˆEà˜UÐ"Ð"r<   )r(   r   r*   r,   r)   r   r   r.   )r	   Nr	   TNNr	   r   r   r   r   ÚTHWC)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Ústrr   Úintr   Úboolr   Údictr   r&   Úpropertyr9   r?   r+   rW   Útupler   ra   Ú__static_attributes__Ú__classcell__)r4   s   @r5   r   r      s~  ø† ñ'ð\ #$Ø$(ØØØ(,Ø:>ØØØØ$%ØØ#ñ!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#ð 0#ðd ð.˜$˜s C˜x™.ó .ó ð.ð t¨C¡yð À3ð Ècð ÐZ^ð ÐcgÐhkÑclô ð,˜ô ,ð#˜sð # u¨V°V¸SÐ-@Ñ'A÷ #ò #r<   r   )rC   Úpathlibr   Útypingr   r   r   r   Útorchr   Úfolderr
   r   Úvideo_utilsr   Úvisionr   r   © r<   r5   Ú<module>rx      s+   ðÛ 	Ý ß 1Ó 1å ç .Ý #Ý !ôw#ˆ]õ w#r<   