
    h                     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        Xl        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                        S/var/www/auris/envauris/lib/python3.13/site-packages/torchvision/datasets/ucf101.pyr&   UCF101.__init__6   s    $ 	D~A~CD6JKK
	
%1$))%<"l#DII|ZW[\$(LL1LqadL
1 !#%'!5)'
  !,((_ER&--dll;") 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$  oR                  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  oU   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    wVtD:T*GGLL/!W==?D59:TGGIOOC(+TD:DHIDqBGGLL:QWWS\:DDI!!$'	 
 $C
O4X418W1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5a8>>%NN5)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# SM0# 0# 0# H%0#  (S#X70# 0# 0# 0# "0# 0#  !0#" 
#0# 0#d .$sCx. . .tCy 3 c Z^ cghkcl , ,#s #uVVS-@'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<   