ó
    Eñi  ã                   ó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  o™S   [1        U	S   5      _M     n
n	U R(                   Vs/ s H  oºU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               €ÚW/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torchvision/datasets/clevr.pyr%   ÚCLEVRClassification.__init__"   s—  ø€ ô % U¨GÐ5MÓNˆŒÜ‰Ñ˜ÐEUÐÑVØŒÜ#ŸLšL¨¯©Ó3°gÑ=ˆÔØ ×-Ñ-´·²¼XÀdÇiÁiÓ=P×=UÑ=UÓ0V×0[Ñ0[Ñ[ˆÔæØ�N‰NÔà×!Ñ!×#Ñ#ÜÐiÓjÐjä" 4×#4Ñ#4×#=Ñ#=¸hÈÏÉÓ#T×#YÑ#YÐZ]Ó#^Ó_ˆÔáØ�;‰;˜&Ó Ü�d×'Ñ'¨(Ñ2°v¸d¿k¹k¸]È,Ð5WÑWÔXÐ\`ÜŸ)š) D›/�÷ YàW^Ð_gÒWhÓiÒWhÈeÐ!1Ñ2´C¸¸iÑ8HÓ4IÒIÑWhˆKÐiØKO×K\ÒK\Ó]ÒK\¸Z¨
¯©Ô8ÑK\Ñ]ˆD�Là ˜6¤C¨×(9Ñ(9Ó$:Ñ:ˆD�L÷ 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Ó'ˆà�>�>Ø—N‘N 5Ó)ˆEà× × Ø×)Ñ)¨%Ó0ˆEàˆ|ÐrH   c                 óx   • U R                   R                  5       =(       a    U R                   R                  5       $ rD   )r,   ÚexistsÚis_dirrE   s    rA   r.   Ú!CLEVRClassification._check_existsS   s+   € Ø× Ñ ×'Ñ'Ó)×H¨d×.?Ñ.?×.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   € Ø×Ñ×ÑØä$ T§Y¡Y´°D×4EÑ4EÓ0FÈDÏIÉIÓ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Ð3°SÐ8Ñ9ð;ð 
÷;ð ;ð@&˜ô &ð˜sð  u¨S°#¨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   