
    QЦi                     j    S SK r S SKrS SKJrJrJrJrJr  S SKr	SSK
JrJr  SSKJr   " S S\5      rg)    N)AnyCallableOptionalTupleUnion   )download_and_extract_archiveverify_str_arg)VisionDatasetc                      ^  \ rS rSrSrSrSr     SS\\\	R                  4   S\S\S	\\   S
\\   S\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\4S jrSS jrSrU =r$ )DTD   a  `Describable Textures Dataset (DTD) <https://www.robots.ox.ac.uk/~vgg/data/dtd/>`_.

Args:
    root (str or ``pathlib.Path``): Root directory of the dataset.
    split (string, optional): The dataset split, supports ``"train"`` (default), ``"val"``, or ``"test"``.
    partition (int, optional): The dataset partition. Should be ``1 <= partition <= 10``. Defaults to ``1``.

        .. note::

            The partition only changes which split each image belongs to. Thus, regardless of the selected
            partition, combining all splits will result in all images.

    transform (callable, optional): A function/transform that takes in a PIL image and returns a transformed
        version. E.g, ``transforms.RandomCrop``.
    target_transform (callable, optional): A function/transform that takes in the 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. Default is False.
zDhttps://www.robots.ox.ac.uk/~vgg/data/dtd/download/dtd-r1.0.1.tar.gz fff73e5086ae6bdbea199a49dfb8a4c1Nrootsplit	partition	transformtarget_transformdownloadreturnc           
        > [        USS5      U l        [        U[        5      (       d  SUs=::  a  S::  d  O  [	        SU S35      eX0l        [        TU ]  XUS9  [        R                  " U R                  5      [        U 5      R                  R                  5       -  U l        U R                  S-  U l        U R                  S	-  U l        U R                  S
-  U l        U(       a  U R%                  5         U R'                  5       (       d  [)        S5      e/ U l        / n[-        U R                   U R                   U R
                   S3-  5       nU Hi  n	U	R/                  5       R1                  S5      u  pU R*                  R3                  U R"                  R5                  X5      5        UR3                  U
5        Mk     S S S 5        [7        [9        U5      5      U l        [=        [?        U R:                  [A        [C        U R:                  5      5      5      5      U l"        U V
s/ s H  oRD                  U
   PM     sn
U l#        g ! , (       d  f       N= fs  sn
f )Nr   )trainvaltestr   
   zPParameter 'partition' should be an integer with `1 <= partition <= 10`, but got z instead)r   r   dtdlabelsimagesz;Dataset not found. You can use download=True to download itz.txt/)$r
   _split
isinstanceint
ValueError
_partitionsuper__init__pathlibPathr   type__name__lower_base_folder_data_folder_meta_folder_images_folder	_download_check_existsRuntimeError_image_filesopenstripr   appendjoinpathsortedsetclassesdictziprangelenclass_to_idx_labels)selfr   r   r   r   r   r   r:   filelineclsname	__class__s               W/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/torchvision/datasets/dtd.pyr&   DTD.__init__#   s    %UG5MN)S))1	3GR3G$+X/  $EUV#LL3d4j6I6I6O6O6QQ --5 --8"//(:NN!!##\]]$##doo5Fd&KKLPT JJL..s3	!!(()<)<)E)Ec)PQs#  M c'l+ T\\5T\\9J3K!LM:AB'3))#.'B ML Cs   A0I&I
Ic                 ,    [        U R                  5      $ N)r>   r3   rA   s    rG   __len__DTD.__len__L   s    4$$%%    idxc                 &   U R                   U   U R                  U   p2[        R                  R	                  U5      R                  S5      nU R                  (       a  U R                  U5      nU R                  (       a  U R                  U5      nXC4$ )NRGB)r3   r@   PILImager4   convertr   r   )rA   rO   
image_filelabelimages        rG   __getitem__DTD.__getitem__O   sp     --c2DLL4EE		z*2259>>NN5)E  ))%0E|rN   c                 :    SU R                    SU R                   3$ )Nzsplit=z, partition=)r    r$   rK   s    rG   
extra_reprDTD.extra_repr[   s    }L0ABBrN   c                     [         R                  R                  U R                  5      =(       a)    [         R                  R	                  U R                  5      $ rJ   )ospathexistsr-   isdirrK   s    rG   r1   DTD._check_exists^   s3    ww~~d//0URWW]]4CTCT5UUrN   c                     U R                  5       (       a  g [        U R                  [        U R                  5      U R
                  S9  g )N)download_rootmd5)r1   r	   _URLstrr,   _MD5rK   s    rG   r0   DTD._downloada   s6    $TYYc$BSBS>TZ^ZcZcdrN   )
r,   r-   r3   r/   r@   r.   r$   r    r?   r:   )r   r   NNF)r   N)r*   
__module____qualname____firstlineno____doc__rf   rh   r   rg   r'   r(   r"   r   r   boolr&   rL   r   r   rX   r[   r1   r0   __static_attributes____classcell__)rF   s   @rG   r   r      s    ( RD-D
 (,/3'CC%&'C 'C 	'C
 H%'C #8,'C 'C 
'C 'CR& &
s 
uS#X 
CC CVt Ve erN   r   )r^   r'   typingr   r   r   r   r   	PIL.ImagerR   utilsr	   r
   visionr   r    rN   rG   <module>rv      s*    	  8 8  ? !Ye- YerN   