
    hD                     j    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
Jr  SSKJr   " S S\5      rg)	    N)AnyCallableOptionalUnion   )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S\4S	\\	\
R                  4   S
\	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\4S jrSS jrSrU =r$ )DTD   a9  `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 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 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.
    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.
zDhttps://www.robots.ox.ac.uk/~vgg/data/dtd/download/dtd-r1.0.1.tar.gz fff73e5086ae6bdbea199a49dfb8a4c1trainr   NFrootsplit	partition	transformtarget_transformdownloadloader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#        Xpl$        g ! , (       d  f       N= fs  snf )Nr   )r   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_labelsr   )selfr   r   r   r   r   r   r   r;   filelineclsname	__class__s                P/var/www/auris/envauris/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?   r4   rB   s    rH   __len__DTD.__len__Q   s    4$$%%    idxc                     U R                   U   U R                  U   p2U R                  U5      nU R                  (       a  U R                  U5      nU R                  (       a  U R	                  U5      nXC4$ rK   )r4   rA   r   r   r   )rB   rP   
image_filelabelimages        rH   __getitem__DTD.__getitem__T   sa     --c2DLL4EEJ'>>NN5)E  ))%0E|rO   c                 :    SU R                    SU R                   3$ )Nzsplit=z, partition=)r!   r%   rL   s    rH   
extra_reprDTD.extra_repr`   s    }L0ABBrO   c                     [         R                  R                  U R                  5      =(       a)    [         R                  R	                  U R                  5      $ rK   )ospathexistsr.   isdirrL   s    rH   r2   DTD._check_existsc   s3    ww~~d//0URWW]]4CTCT5UUrO   c                     U R                  5       (       a  g [        U R                  [        U R                  5      U R
                  S9  g )N)download_rootmd5)r2   r	   _URLstrr-   _MD5rL   s    rH   r1   DTD._downloadf   s6    $TYYc$BSBS>TZ^ZcZcdrO   )r-   r.   r4   r0   rA   r/   r%   r!   r@   r;   r   )r   N)r+   
__module____qualname____firstlineno____doc__rc   re   r   r   rd   r(   r)   r#   r   r   boolr   r'   rM   tuplerU   rX   r2   r1   __static_attributes____classcell__)rG   s   @rH   r   r      s   . RD-D
 (,/3<J)C%&) ) 	)
 H%) #8,) ) %W\\ 123S89) 
) )V& &
s 
uS#X 
CC CVt Ve erO   r   )r[   r(   typingr   r   r   r   folderr   utilsr	   r
   visionr   r    rO   rH   <module>rt      s*    	  1 1 " ? !^e- ^erO   