
    h                     v    S SK r S SKrS SKJrJrJrJr  S SKJr  SSK	J
r
  SSKJrJr  SSKJr   " S S	\5      rg)
    N)AnyCallableOptionalUnion)urlparse   )default_loader)download_and_extract_archiveverify_str_arg)VisionDatasetc                     ^  \ rS rSrSrSrSrSSSS\4S\\	\
R                  4   S	\	S
\\   S\\   S\S\\\	\
R                  4   /\4   SS4U 4S jjjrS\4S jrS\S\\\4   4S jrS\4S jrSS jrS\	4S jrSrU =r$ )CLEVRClassification   ax  `CLEVR <https://cs.stanford.edu/people/jcjohns/clevr/>`_  classification dataset.

The number of objects in a scene are used as label.

Args:
    root (str or ``pathlib.Path``): Root directory of dataset where directory ``root/clevr`` exists or will be saved to if download is
        set to True.
    split (string, optional): The dataset split, supports ``"train"`` (default), ``"val"``, or ``"test"``.
    transform (callable, optional): A function/transform that takes in a PIL image or torch.Tensor, depends on the given loader,
        and returns a transformed version. E.g, ``transforms.RandomCrop``
    target_transform (callable, optional): A function/transform that takes in them target and transforms it.
    download (bool, optional): If true, downloads the dataset from the internet and puts it in root directory. If
        dataset is already downloaded, it is not downloaded again.
    loader (callable, optional): A function to load an image given its path.
        By default, it uses PIL as its image loader, but users could also pass in
        ``torchvision.io.decode_image`` for decoding image data into tensors directly.
z3https://dl.fbaipublicfiles.com/clevr/CLEVR_v1.0.zip b11922020e72d0cd9154779b2d3d07d2trainNFrootsplit	transformtarget_transformdownloadloaderreturnc                    > [        USS5      U l        [        TU ]  XUS9  X`l        [
        R                  " U R                  5      S-  U l        U R                  [
        R                  " [        U R                  5      R                  5      R                  -  U l        U(       a  U R                  5         U R                  5       (       d  [!        S5      e[#        U R                  R%                  SU R                  5      R'                  S5      5      U l        U   U R                  S:w  a  [+        U R                  S	-  S
U R                   S3-  5       n[,        R.                  " U5      nS S S 5        WS	    V	s0 s H  oS   [1        U	S   5      _M     n
n	U R(                   Vs/ s H  oUR2                     PM     snU l        g S /[1        U R(                  5      -  U l        g ! , (       d  f       N= fs  sn	f s  snf )Nr   )r   valtest)r   r   clevrzHDataset not found or corrupted. You can use download=True to download itimages*r   scenesCLEVR_z_scenes.jsonimage_filenameobjects)r   _splitsuper__init__r   pathlibPathr   _base_folderr   _URLpathstem_data_folder	_download_check_existsRuntimeErrorsortedjoinpathglob_image_filesopenjsonloadlenname_labels)selfr   r   r   r   r   r   filecontentscenenum_objects
image_file	__class__s               R/var/www/auris/envauris/lib/python3.13/site-packages/torchvision/datasets/clevr.pyr%   CLEVRClassification.__init__"   s    %UG5MNEUV#LL3g= --Xdii=P=U=U0V0[0[[NN!!##ijj"4#4#4#=#=h#T#Y#YZ]#^_;;& d''(2vdkk],5WWX\`))D/ YW^_gWhiWhe!12Ci8H4IIWhKiKOK\K\]K\Z
8K\]DL 6C(9(9$::DL YXi]s   G%:G6%G;%
G3c                 ,    [        U R                  5      $ N)r7   r3   r:   s    rA   __len__CLEVRClassification.__len__B   s    4$$%%    idxc                     U R                   U   nU R                  U   nU R                  U5      nU R                  (       a  U R                  U5      nU R                  (       a  U R	                  U5      nXC4$ rD   )r3   r9   r   r   r   )r:   rI   r?   labelimages        rA   __getitem__CLEVRClassification.__getitem__E   sd    &&s+
S!J'>>NN5)E  ))%0E|rH   c                 x    U R                   R                  5       =(       a    U R                   R                  5       $ rD   )r,   existsis_dirrE   s    rA   r.   !CLEVRClassification._check_existsS   s+      '')Hd.?.?.F.F.HHrH   c                     U R                  5       (       a  g [        U R                  [        U R                  5      U R
                  S9  g )N)md5)r.   r
   r)   strr(   _MD5rE   s    rA   r-   CLEVRClassification._downloadV   s3    $TYYD4E4E0FDIIVrH   c                      SU R                    3$ )Nzsplit=)r#   rE   s    rA   
extra_reprCLEVRClassification.extra_repr\   s    }%%rH   )r(   r,   r3   r9   r#   r   )r   N)__name__
__module____qualname____firstlineno____doc__r)   rV   r	   r   rU   r&   r'   r   r   boolr   r%   intrF   tuplerM   r.   r-   rY   __static_attributes____classcell__)r@   s   @rA   r   r      s    $ AD-D
 (,/3<J;C%&; ; H%	;
 #8,; ; %W\\ 123S89; 
; ;@& &s uS#X It IW&C & &rH   r   )r5   r&   typingr   r   r   r   urllib.parser   folderr	   utilsr
   r   visionr   r    rH   rA   <module>rk      s+      1 1 ! " ? !Q&- Q&rH   