
    h@                         S SK r 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rSS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$ )$HMDB51   a>  
`HMDB51 <https://serre-lab.clps.brown.edu/resource/hmdb-a-large-human-motion-database/>`_
dataset.

HMDB51 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``.

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 HMDB51 Dataset.
    annotation_path (str): Path to the folder containing the split files.
    frames_per_clip (int): Number of frames in a clip.
    step_between_clips (int): 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
zJhttps://serre-lab.clps.brown.edu/wp-content/uploads/2013/10/hmdb51_org.rarzQhttps://serre-lab.clps.brown.edu/wp-content/uploads/2013/10/test_train_splits.rar 15e67781e70dcfbdce2d7dbb9b3344b5)urlmd5r	      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        US;  a  [        SU 35      eSn[        U R                  5      u  U l        n[        U R                  UU5      U l        U R                   VVs/ s H  u  nnUPM
     nnn[        UUUUU	U
UUUUUS9nUU l	        X`l
        Xpl        U R                  UX&U5      U l        UR                  U R                  5      U l        Xl        g s  snnf )N)r	   r      z$fold should be between 1 and 3, got )avi)r   r   r    r!   r"   r#   )super__init__
ValueErrorr
   r   classesr   samplesr   full_video_clipsr   r   _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path_video_pathsr1   	__class__s                         S/var/www/auris/envauris/lib/python3.13/site-packages/torchvision/datasets/hmdb51.pyr)   HMDB51.__init__=   s    $ 	y CD6JKK
%1$))%<"l#II
 .2\\:\	qt\: !#%'!5)'
  !,	
((oUS&--dll;"- ;s   /C&c                 .    U R                   R                  $ N)r-   metadatar2   s    r9   r=   HMDB51.metadatas   s    $$---    
video_listannotations_dirc                 b   U(       a  U R                   OU R                  nSU S3n[        R                  R	                  X&5      n[
        R
                  " U5      n[        5       n	U Hf  n
[        U
5       nUR                  5       nS S S 5        W H9  nUR                  5       u  p[        U5      nUU:X  d  M(  U	R                  U5        M;     Mh     / n[        U5       H<  u  nn[        R                  R                  U5      U	;   d  M+  UR                  U5        M>     U$ ! , (       d  f       N= f)Nz*test_splitz.txt)	TRAIN_TAGTEST_TAGosr5   joinglobsetopen	readlinessplitintadd	enumeratebasenameappend)r2   rA   rB   r   r   
target_tagsplit_pattern_namesplit_pattern_pathannotation_pathsselected_filesfilepathfidlineslinevideo_filename
tag_stringtagr/   video_index
video_paths                       r9   r.   HMDB51._select_foldw   s    ',T^^$--
*4&5WW\\/N99%78(Hh3  -1ZZ\**o*$"&&~6	  ) '0'<#Kww
+~={+ (=   s   5D  
D.	c                 6    U R                   R                  5       $ r<   )r1   	num_clipsr>   s    r9   __len__HMDB51.__len__   s    ))++r@   idxc                     U R                   R                  U5      u  p#pEU R                  U   nU R                  U   u  pGU R                  b  U R	                  U5      nX#U4$ r<   )r1   get_clipr/   r,   r   )r2   re   videoaudior6   	video_idxsample_indexclass_indexs           r9   __getitem__HMDB51.__getitem__   s^    %)%5%5%>%>s%C"a||I.l3>>%NN5)E[((r@   )r+   r   r-   r/   r,   r   r   r1   )r	   Nr	   TNNr	   r   r   r   r   THWC)__name__
__module____qualname____firstlineno____doc__data_urlsplitsrD   rE   r   strr   rM   r   boolr   dictr   r)   propertyr=   listr.   rc   tupler   rm   __static_attributes____classcell__)r8   s   @r9   r   r      s   %N \Hb1F IH #$$((,:>$%#!4#CI4# 4# 	4#
  4# SM4# 4# 4# H%4#  (S#X74# 4# 4# 4# "4# 4#  !4#" 
#4# 4#l .$sCx. . .tCy 3 c Z^ cghkcl ,, ,)s )uVVS-@'A ) )r@   r   )rH   rF   pathlibr   typingr   r   r   r   torchr   folderr
   r   video_utilsr   visionr   r    r@   r9   <module>r      s.     	  1 1  . # !K)] K)r@   