+
     °³j‰&  ã                   óÔ   € ^ RI t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIHt ^ RIH	t	 ^ RI
HtHtHtHt ^ RIHt ^RIHtHt ^R	IHtHtHtHt ^R
IHt ^RIHt R R lt ! R R]4      tR# )é    N)Úpartial)ÚPool)Úpath)ÚPath)ÚAnyÚCallableÚOptionalÚUnion)ÚTensor)Úfind_classesÚmake_dataset)Úcheck_integrityÚdownload_and_extract_archiveÚdownload_urlÚverify_str_arg)Ú
VideoClips)ÚVisionDatasetc                ó„   € V ^8„  d   QhR\         \        \        3,          R\         \        \        3,          R\        RR/# )é   ÚtarpathÚ	videopathÚlineÚreturnN)r
   Ústrr   )Úformats   "Ú^/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torchvision/datasets/kinetics.pyÚ__annotate__r      s;   € ÷ ;ñ ;”eœC¤˜IÕ&ð ;´5¼¼d¸Õ3Cð ;Ì3ð ;ÐSWñ ;ó    c                 ó   € \        W V4       R # ©N)r   )r   r   r   s   &&&r   Ú_dl_wrapr!      s   € Ü  °	Ö:r   c                   óÜ   a a€ ] tR t^t oRtRRRRRR/tRRRR	RR
/tRV3R lV 3R llltV3R lR ltV3R lR lt	V3R lR lt
]V3R lR l4       tV3R lR ltV3R lR ltRtVtV ;t# )ÚKineticsuÊ
  `Generic Kinetics <https://www.deepmind.com/open-source/kinetics>`_
dataset.

Kinetics-400/600/700 are action recognition video datasets.
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``.

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.

Args:
    root (str or ``pathlib.Path``): Root directory of the Kinetics Dataset.
        Directory should be structured as follows:
        .. code::

            root/
            â”œâ”€â”€ split
            â”‚   â”œâ”€â”€  class1
            â”‚   â”‚   â”œâ”€â”€  vid1.mp4
            â”‚   â”‚   â”œâ”€â”€  vid2.mp4
            â”‚   â”‚   â”œâ”€â”€  vid3.mp4
            â”‚   â”‚   â”œâ”€â”€  ...
            â”‚   â”œâ”€â”€  class2
            â”‚   â”‚   â”œâ”€â”€   vidx.mp4
            â”‚   â”‚    â””â”€â”€ ...

        Note: split is appended automatically using the split argument.
    frames_per_clip (int): number of frames in a clip
    num_classes (int): select between Kinetics-400 (default), Kinetics-600, and Kinetics-700
    split (str): split of the dataset to consider; supports ``"train"`` (default) ``"val"`` ``"test"``
    frame_rate (float): If omitted, interpolate different frame rate for each clip.
    step_between_clips (int): number of frames between each clip
    transform (callable, optional): A function/transform that takes in a TxHxWxC video
        and returns a transformed version.
    download (bool): Download the official version of the dataset to root folder.
    num_workers (int): Use multiple workers for VideoClips creation
    num_download_workers (int): Use multiprocessing in order to speed up download.
    output_format (str, optional): The format of the output video tensors (before transforms).
        Can be either "THWC" or "TCHW" (default).
        Note that in most other utils and datasets, the default is actually "THWC".

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

        - video (Tensor[T, C, H, W] or Tensor[T, H, W, C]): the `T` video frames in torch.uint8 tensor
        - audio(Tensor[K, L]): the audio frames, where `K` is the number of channels
          and `L` is the number of points in torch.float tensor
        - label (int): class of the video clip

Raises:
    RuntimeError: If ``download is True`` and the video archives are already extracted.
Ú400zChttps://s3.amazonaws.com/kinetics/400/{split}/k400_{split}_path.txtÚ600zChttps://s3.amazonaws.com/kinetics/600/{split}/k600_{split}_path.txtÚ700zMhttps://s3.amazonaws.com/kinetics/700_2020/{split}/k700_2020_{split}_path.txtz=https://s3.amazonaws.com/kinetics/400/annotations/{split}.csvz=https://s3.amazonaws.com/kinetics/600/annotations/{split}.csvzBhttps://s3.amazonaws.com/kinetics/700_2020/annotations/{split}.csvc          (      ó   <€ V ^8„  d   QhRS[ S[S[3,          RS[RS[RS[RS[S[,          RS[RS[S[,          RS[S[R	3,          R
S[RS[RS[RS[S[S[S[	3,          ,          RS[RS[RS[RS[RS[RS[RS[RR/# )r   ÚrootÚframes_per_clipÚnum_classesÚsplitÚ
frame_rateÚstep_between_clipsÚ	transformÚ
extensions.ÚdownloadÚnum_download_workersÚnum_workersÚ_precomputed_metadataÚ_video_widthÚ_video_heightÚ_video_min_dimensionÚ_audio_samplesÚ_audio_channelsÚ_legacyÚoutput_formatr   N)
r
   r   r   Úintr	   r   ÚtupleÚboolÚdictr   )r   Ú__classdict__s   "€r   r   ÚKinetics.__annotate__[   sú   ø€ ÷ ?#ñ ?#á‘C™�IÕð?#ñ ð?#ñ ð	?#ñ
 ð?#ñ ™S•Mð?#ñ  ð?#ñ ™HÕ%ð?#ñ ™#˜s˜(•Oð?#ñ ð?#ñ "ð?#ñ ð?#ñ  (©©S±#¨X­Õ7ð?#ñ ð?#ñ ð?#ñ  "ð!?#ñ" ð#?#ñ$ ð%?#ñ& ð'?#ñ( ð)?#ð* 
ñ+?#r   c                ó„  <€ \        VR . R	OR7      V n        W€n        W n        Wn        VV n        V'       d$   Wn        RV n        RpV	'       d   \        R4      hM0\        P                  ! W4      V n        \        VR. R
OR7      V n        V	'       d   V P                  4        \        SV `5  V P                  4       \        V P                  4      w  V n        p\!        V P                  VVRR7      V n        V P"                   Uu. uF  pV^ ,          NK  	  pp\%        VVVVVVVVVVVVR7      V n        Wpn        R# u upi )r*   )ÚargÚvalid_valuesÚunknownÚTHWCz2Cannot download the videos using legacy_structure.r+   N)Úis_valid_file)r2   r4   r5   r6   r7   r8   r:   )r$   r%   r&   )ÚtrainÚvalÚtest)r   r*   r/   r1   r(   r9   Úsplit_folderr+   Ú
ValueErrorr   ÚjoinÚdownload_and_process_videosÚsuperÚ__init__r   Úclassesr   Úsamplesr   Úvideo_clipsr.   )Úselfr(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   Úclass_to_idxÚxÚ
video_listÚ	__class__s   &&&&&&&&&&&&&&&&&&&&   €r   rO   ÚKinetics.__init__[   s&  ø€ ô0 *¨+¸=ÒWlÔmˆÔØ$ŒØ$8Ô!àŒ	ØˆŒçØ $ÔØ"ˆDŒJØ"ˆMßÜ Ð!UÓVÐVð ô !%§	¢	¨$Ó 6ˆDÔÜ'¨°7ÒIaÔbˆDŒJçØ×,Ñ,Ô.ä‰Ñ˜Ÿ™Ô#ä%1°$×2CÑ2CÓ%DÑ"ˆŒ�lÜ# D×$5Ñ$5°|ÀZÐ_cÔdˆŒØ$(§L¢LÓ1¡L˜q�a˜—d�d¡Lˆ
Ð1Ü%ØØØØØ!Ø#Ø%Ø'Ø!5Ø)Ø+Ø'ô
ˆÔð #Žùò 2s   ÄD=c                ó   <€ V ^8„  d   QhRR/# ©r   r   N© )r   r?   s   "€r   r   r@   œ   s   ø€ ÷ "ñ "¨Tñ "r   c                óF   € V P                  4        V P                  4        R# )zEDownloads all the videos to the _root_ folder in the expected format.N)Ú_download_videosÚ_make_ds_structure©rS   s   &r   rM   Ú$Kinetics.download_and_process_videosœ   s   € à×ÑÔØ×ÑÖ!r   c                ó   <€ V ^8„  d   QhRR/# rZ   r[   )r   r?   s   "€r   r   r@   ¡   s   ø€ ÷ 0ñ 0 $ñ 0r   c           
     ó¼  € \         P                  ! V P                  4      '       d   R# \         P                  ! V P                  R4      p\         P                  ! V P                  R4      pV P
                  V P                  ,          P                  V P                  R7      p\         P                  ! V\         P                  ! V4      4      p\        V4      '       g   \        W24       \        V4      ;_uu_ 4       pVP                  4       P                  4        Uu. uF$  p\        P                   P#                  VRR7      NK&  	  ppRRR4       V P$                  ^8X  d"   X F  p\'        WaV P                  4       K  	  R# \)        \*        WP                  4      p\-        V P$                  4      p	V	P/                  VX4       R# u upi   + '       g   i     LŠ; i)zýdownload tarballs containing the video to "tars" folder and extract them into the _split_ folder where
split is one of the official dataset splits.

Raises:
    RuntimeError: if download folder exists, break to prevent downloading entire dataset again.
NÚtarsÚfiles©r+   z/,:)Úsafe)r   ÚexistsrJ   rL   r(   Ú	_TAR_URLSr*   r   r+   Úbasenamer   r   ÚopenÚreadÚ
splitlinesÚurllibÚparseÚquoter1   r   r   r!   r   Úmap)
rS   Útar_pathÚfile_list_pathÚ	split_urlÚsplit_url_filepathÚfiler   Úlist_video_urlsÚpartÚpoolprocs
   &         r   r]   ÚKinetics._download_videos¡   sR  € ô �;Š;�t×(Ñ(×)Ò)ÙÜ—9’9˜TŸY™Y¨Ó/ˆÜŸš 4§9¡9¨gÓ6ˆà—N‘N 4×#3Ñ#3Õ4×;Ñ;À$Ç*Á*Ð;ÓMˆ	Ü!ŸYšY ~´t·}²}ÀYÓ7OÓPÐÜÐ1×2Ò2Ü˜Ô3ÜÐ$×%Ô%¨ØPT×PYÑPYÓP[×PfÑPfÔPhÓiÑPhÈœvŸ|™|×1Ñ1°$¸UÐ1ÖCÑPhˆOÐi÷ &ð ×$Ñ$¨Ô)Û'�Ü,¨T¸T×=NÑ=NÖOó (ô œ8 X×/@Ñ/@ÓAˆDÜ˜D×5Ñ5Ó6ˆHØ�L‰L˜˜Ö/ùò j÷ &×%ús   Ã<!GÄ*GÅGÇGÇG	c                ó   <€ V ^8„  d   QhRR/# rZ   r[   )r   r?   s   "€r   r   r@   ¼   s   ø€ ÷ !ñ ! Dñ !r   c                óz  € \         P                  ! V P                  R4      p\        \         P                  ! WP                   R24      4      '       gB   \        V P                  V P                  ,          P                  V P                  R7      V4       \         P                  ! WP                   R24      pRp\        V4      ;_uu_ 4       p\        P                  ! V4      pV EF4  pVP                  VR,          \        VR,          4      \        VR,          4      R7      pVR	,          P                  R
R4      P                  RR4      P                  RR4      P                  RR4      p\        P                  ! \         P                  ! V P                   V4      RR7       \         P                  ! V P                   V4      p	\         P"                  ! V	4      '       g   Kþ  \        P                  ! V	\         P                  ! V P                   W‡4      4       EK7  	  RRR4       R#   + '       g   i     R# ; i)u¼   move videos from
split_folder/
    â”œâ”€â”€ clip1.avi
    â”œâ”€â”€ clip2.avi

to the correct format as described below:
split_folder/
    â”œâ”€â”€ class1
    â”‚   â”œâ”€â”€ clip1.avi

Úannotationsz.csvre   z{ytid}_{start:06}_{end:06}.mp4Ú
youtube_idÚ
time_startÚtime_end)ÚytidÚstartÚendÚlabelÚ Ú_Ú'Ú Ú(Ú)T)Úexist_okN)r   rL   r(   r   r+   r   Ú_ANNOTATION_URLSr*   r   rj   ÚcsvÚ
DictReaderr;   ÚreplaceÚosÚmakedirsrJ   Úisfile)
rS   Úannotation_pathr|   Úfile_fmtstrÚcsvfileÚreaderÚrowÚfrƒ   Údownloaded_files
   &         r   r^   ÚKinetics._make_ds_structure¼   s—  € ô Ÿ)š) D§I¡I¨}Ó=ˆÜœtŸyšy¨¿Z¹Z¸LÈÐ:MÓN×OÒOÜ˜×.Ñ.¨t×/?Ñ/?Õ@×GÑGÈdÏjÉjÐGÓYÐ[jÔkÜ—i’i ·J±J°<¸tÐ1DÓEˆà6ˆÜ�+×Ô 'Ü—^’^ GÓ,ˆFÜ�Ø×&Ñ&Ø˜\Õ*Ü˜c ,Õ/Ó0Ü˜C 
�OÓ,ð 'ó �ð
 ˜G�×,Ñ,¨S°#Ó6×>Ñ>¸sÀBÓG×OÑOÐPSÐUWÓX×`Ñ`ÐadÐfhÓi�Ü—’œDŸIšI d×&7Ñ&7¸Ó?È$ÕOÜ"&§)¢)¨D×,=Ñ,=¸qÓ"A�Ü—;’;˜×/Ô/Ü—J’JØ'ÜŸ	š	 $×"3Ñ"3°UÓ>÷ñ ÷ ××Òús   ÃDH)Ç$;H)È)H:	c                ó6   <€ V ^8„  d   QhRS[ S[S[3,          /# ©r   r   )r>   r   r   )r   r?   s   "€r   r   r@   à   s   ø€ ÷ )ñ )™$™s¡C˜x�.ñ )r   c                ó.   € V P                   P                  # r    )rR   Úmetadatar_   s   &r   r�   ÚKinetics.metadataß   s   € à×Ñ×(Ñ(Ð(r   c                ó    <€ V ^8„  d   QhRS[ /# r›   )r;   )r   r?   s   "€r   r   r@   ã   s   ø€ ÷ ,ñ ,™ñ ,r   c                ó6   € V P                   P                  4       # r    )rR   Ú	num_clipsr_   s   &r   Ú__len__ÚKinetics.__len__ã   s   € Ø×Ñ×)Ñ)Ó+Ð+r   c                ó@   <€ V ^8„  d   QhRS[ RS[S[S[S[ 3,          /# )r   Úidxr   )r;   r<   r   )r   r?   s   "€r   r   r@   æ   s'   ø€ ÷ #ñ #™sð #¡u©V±V¹SÐ-@Õ'Añ #r   c                ó¸   € V P                   P                  V4      w  r#rEV P                  V,          ^,          pV P                  e   V P                  V4      pW#V3# )é   )rR   Úget_cliprQ   r.   )rS   r¥   ÚvideoÚaudioÚinfoÚ	video_idxrƒ   s   &&     r   Ú__getitem__ÚKinetics.__getitem__æ   sS   € Ø(,×(8Ñ(8×(AÑ(AÀ#Ó(FÑ%ˆ�dØ—‘˜YÕ'¨Õ*ˆà�>‰>Ò%Ø—N‘N 5Ó)ˆEà˜UÐ"Ð"r   )r9   rP   r/   r*   r1   r(   rQ   r+   rJ   r.   rR   )r$   rG   Nr§   N)ÚaviÚmp4Fr§   r§   Nr   r   r   r   r   FÚTCHW)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rh   r‹   rO   rM   r]   r^   Úpropertyr�   r¢   r­   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)rW   r?   s   @@r   r#   r#      s™   ù‡ € ñ7ðt 	ÐTØÐTØÐ^ð€Ið 	ÐNØÐNØÐSðÐ÷?#õ ?#÷B"ð "÷
0ð 0÷6!ð !ðF ÷)ó ð)÷,ð ,÷#÷ #ð #r   r#   )rŒ   r�   rm   Ú	functoolsr   Úmultiprocessingr   r   Úpathlibr   Útypingr   r   r	   r
   Útorchr   Úfolderr   r   Úutilsr   r   r   r   Úvideo_utilsr   Úvisionr   r!   r#   r[   r   r   Ú<module>rÄ      sE   ðÛ 
Û 	Û Ý Ý  Ý Ý ß 1Ó 1å ç .ß ^Ó ^Ý #Ý !õ;ôW#ˆ}ö W#r   