
    hh                     b    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
  SSKJr   " S S\5      rg	)
    )Path)AnyCallableOptionalUnion   )default_loader)download_and_extract_archive)VisionDatasetc                      ^  \ rS rSrSrSrSrSSS\4S\\	\
4   S\\   S	\\   S
\S\\\	\
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rU =r$ )SUN397
   a  `The SUN397 Data Set <https://vision.princeton.edu/projects/2010/SUN/>`_.

The SUN397 or Scene UNderstanding (SUN) is a dataset for scene recognition consisting of
397 categories with 108'754 images.

Args:
    root (str or ``pathlib.Path``): Root directory of the dataset.
    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.
    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.
z;http://vision.princeton.edu/projects/2010/SUN/SUN397.tar.gz 8ca2778205c41d23104230ba66911c7aNFroot	transformtarget_transformdownloadloaderreturnc           
      6  > [         T	U ]  XUS9  [        U R                  5      S-  U l        U(       a  U R                  5         U R                  5       (       d  [        S5      e[        U R                  S-  5       nU Vs/ s H  owSS  R                  5       PM     snU l
        S S S 5        [        [        U R                  [        [        U R                  5      5      5      5      U l        [!        U R                  R#                  S5      5      U l        U R$                   Vs/ s HF  oR                  SR'                  UR)                  U R                  5      R*                  SS	 5         PMH     snU l        XPl        g s  snf ! , (       d  f       N= fs  snf )
N)r   r   r   z;Dataset not found. You can use download=True to download itzClassName.txt   z	sun_*.jpg/r   )super__init__r   r   	_data_dir	_download_check_existsRuntimeErroropenstripclassesdictziprangelenclass_to_idxlistrglob_image_filesjoinrelative_toparts_labelsr   )
selfr   r   r   r   r   fcpath	__class__s
            S/var/www/auris/envauris/lib/python3.13/site-packages/torchvision/datasets/sun397.pyr   SUN397.__init__    s?    	EUVdii83NN!!##\]]$..?23q3451aabEKKM15DL 4 !T\\5T\\9J3K!LM !5!5k!BC cgbsbs
bsZ^chht'7'7'G'M'MaPR'STUbs
  6 43
s%   <FF F$AF F
Fc                 ,    [        U R                  5      $ N)r&   r*   r/   s    r4   __len__SUN397.__len__<   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$ r7   )r*   r.   r   r   r   )r/   r<   
image_filelabelimages        r4   __getitem__SUN397.__getitem__?   sa     --c2DLL4EEJ'>>NN5)E  ))%0E|r;   c                 6    U R                   R                  5       $ r7   )r   is_dirr8   s    r4   r   SUN397._check_existsK   s    ~~$$&&r;   c                     U R                  5       (       a  g [        U R                  U R                  U R                  S9  g )N)download_rootmd5)r   r
   _DATASET_URLr   _DATASET_MD5r8   s    r4   r   SUN397._downloadN   s1    $T%6%6diiUYUfUfgr;   )r   r*   r.   r'   r"   r   )r   N)__name__
__module____qualname____firstlineno____doc__rI   rJ   r	   r   strr   r   r   boolr   r   intr9   tuplerA   r   r   __static_attributes____classcell__)r3   s   @r4   r   r   
   s    $ QL5L
 )-/34BCI H% #8,	
  %T	*+S01 
 8& &
s 
uS#X 
't 'h hr;   r   N)pathlibr   typingr   r   r   r   folderr	   utilsr
   visionr   r    r;   r4   <module>r]      s'     1 1 " / !Gh] Ghr;   