§
    dzni`  ã                   ó~   — d dl Z d dlmZmZ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dS )
é    N)ÚAnyÚCallableÚDictÚListÚOptionalÚTuple)ÚTensoré   )Úfind_classesÚmake_dataset)Ú
VideoClips)ÚVisionDatasetc            !       ó@  ‡ — e Zd ZdZ	 	 	 	 	 	 	 	 	 	 	 	 dde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 (string): 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
    r
   NTr   ÚTHWCÚ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 ¬¦  «        | _	        d„ | j	        D ¦   «         }t          |||||	|
|||||¬¦  «        }|| _        |                      ||||¦  «        | _        |                     | j        ¦  «        | _        || _        d S )Nr
   é   z$fold should be between 1 and 3, got )Úavi)Úis_valid_filec                 ó   — g | ]
}|d          ‘ŒS )r   © ©Ú.0Úxs     ú{/var/www/html/cool-property-finder/image-detection-backend/venv/lib/python3.11/site-packages/torchvision/datasets/ucf101.pyú
<listcomp>z#UCF101.__init__.<locals>.<listcomp>Q   s   € Ð1Ð1Ð1˜q�a˜”dÐ1Ð1Ð1ó    )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Ú
video_listr7   Ú	__class__s                       €r+   r/   zUCF101.__init__5   s!  ø€ õ$ 	‰Œ×Ò˜ÑÔÐØ�Dˆ~ˆ~Š~ˆ~˜AŠ~ˆ~ˆ~ˆ~ÝÐJÀDÐJÐJÑKÔKÐKàˆ
ØˆŒ	ØˆŒ
å%1°$´)Ñ%<Ô%<Ñ"ˆŒ�lÝ# D¤I¨|¸ZÐW[Ð\Ñ\Ô\ˆŒØ1Ð1 D¤LÐ1Ñ1Ô1ˆ
Ý ØØØØØ!Ø#Ø%Ø'Ø!5Ø)Ø'ð
ñ 
ô 
ˆð  !,ˆÔØ×(Ò(¨°_ÀdÈEÑRÔRˆŒØ&×-Ò-¨d¬lÑ;Ô;ˆÔØ"ˆŒˆˆr-   c                 ó   — | j         j        S ©N)r3   Úmetadata©r8   s    r+   r?   zUCF101.metadatag   s   € àÔ$Ô-Ð-r-   r;   c                 ó¬  ‡ ‡‡
— |rdnd}|› d|d›d�}t           j                             ||¦  «        }t          ¦   «         Š
t	          |¦  «        5 }|                     ¦   «         }d„ |D ¦   «         }ˆ fd„|D ¦   «         }‰
                     |¦  «         d d d ¦  «         n# 1 swxY w Y   ˆ
ˆfd„t          t          ‰¦  «        ¦  «        D ¦   «         }	|	S )	Nr   ÚtestÚlistÚ02dz.txtc                 óh   — g | ]/}|                      ¦   «                              d ¦  «        d         ‘Œ0S )ú r   )ÚstripÚsplitr(   s     r+   r,   z'UCF101._select_fold.<locals>.<listcomp>r   s1   € Ð:Ð:Ð:°�A—G’G‘I”I—O’O CÑ(Ô(¨Ô+Ð:Ð:Ð:r-   c                 ón   •— g | ]1}t          j        j        ‰j        g|                     d ¦  «        ¢R Ž ‘Œ2S )ú/)ÚosÚpathÚjoinr   rH   )r)   r*   r8   s     €r+   r,   z'UCF101._select_fold.<locals>.<listcomp>s   s9   ø€ ÐIÐIÐI¸q•B”G”L ¤Ð:¨Q¯WªW°S©\¬\Ð:Ð:Ð:ÐIÐIÐIr-   c                 ó(   •— g | ]}‰|         ‰v ¯|‘ŒS r'   r'   )r)   ÚiÚselected_filesr;   s     €€r+   r,   z'UCF101._select_fold.<locals>.<listcomp>u   s'   ø€ ÐXÐXÐX˜¸
À1¼ÈÐ8WÐ8W�1Ð8WÐ8WÐ8Wr-   )	rK   rL   rM   ÚsetÚopenÚ	readlinesÚupdateÚrangeÚlen)r8   r;   r   r   r   ÚnameÚfÚfidÚdatar5   rP   s   ``        @r+   r4   zUCF101._select_foldk   s'  øøø€ ØÐ+ˆwˆw VˆØÐ*Ð*˜DÐ*Ð*Ð*Ð*ˆÝŒG�LŠL˜¨$Ñ/Ô/ˆÝ™œˆÝ�!‰WŒWð 	(˜Ø—=’=‘?”?ˆDØ:Ð:°TÐ:Ñ:Ô:ˆDØIÐIÐIÐIÀDÐIÑIÔIˆDØ×!Ò! $Ñ'Ô'Ð'ð		(ð 	(ð 	(ñ 	(ô 	(ð 	(ð 	(ð 	(ð 	(ð 	(ð 	(øøøð 	(ð 	(ð 	(ð 	(ð
 YÐXÐXÐXÐX�e¥C¨
¡O¤OÑ4Ô4ÐXÑXÔXˆØˆs   ÁAB Â B$Â'B$c                 ó4   — | j                              ¦   «         S r>   )r7   Ú	num_clipsr@   s    r+   Ú__len__zUCF101.__len__x   s   € ØÔ×)Ò)Ñ+Ô+Ð+r-   Úidxc                 ó¾   — | j                              |¦  «        \  }}}}| j        | j        |                  d         }| j        �|                      |¦  «        }|||fS )Nr
   )r7   Úget_clipr2   r5   r   )r8   r^   ÚvideoÚaudioÚinfoÚ	video_idxÚlabels          r+   Ú__getitem__zUCF101.__getitem__{   s_   € Ø(,Ô(8×(AÒ(AÀ#Ñ(FÔ(FÑ%ˆˆu�d˜IØ”˜Tœ\¨)Ô4Ô5°aÔ8ˆàŒ>Ð%Ø—N’N 5Ñ)Ô)ˆEà�e˜UÐ"Ð"r-   )r
   Nr
   TNNr
   r   r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚstrÚintr   Úboolr   r   r   r/   Úpropertyr?   r   r4   r]   r   r	   rf   Ú__classcell__)r<   s   @r+   r   r      sã  ø€ € € € € ð'ð 'ð\ #$Ø$(ØØØ(,Ø:>ØØØØ$%ØØ#ð!0#ð 0#àð0#ð ð0#ð ð	0#ð
  ð0#ð ˜S”Mð0#ð ð0#ð ð0#ð ˜HÔ%ð0#ð  (¨¨S°#¨X¬Ô7ð0#ð ð0#ð ð0#ð ð0#ð "ð0#ð ð0#ð  ð!0#ð" 
ð#0#ð 0#ð 0#ð 0#ð 0#ð 0#ðd ð.˜$˜s C˜xœ.ð .ð .ð .ñ „Xð.ð t¨C¤yð À3ð Ècð ÐZ^ð ÐcgÐhkÔclð ð ð ð ð,˜ð ,ð ,ð ,ð ,ð#˜sð # u¨V°V¸SÐ-@Ô'Að #ð #ð #ð #ð #ð #ð #ð #r-   r   )rK   Útypingr   r   r   r   r   r   Útorchr	   Úfolderr   r   Úvideo_utilsr   Úvisionr   r   r'   r-   r+   ú<module>ru      sÊ   ðØ 	€	€	€	Ø =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ð =à Ð Ð Ð Ð Ð à .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ø #Ð #Ð #Ð #Ð #Ð #Ø !Ð !Ð !Ð !Ð !Ð !ðw#ð w#ð w#ð w#ð w#ˆ]ñ w#ô w#ð w#ð w#ð w#r-   