
    h+                         S SK r S SK Jr  S SKJr  S SKJr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Jr  SS	KJr   " S
 S\5      rg)    N)path)Path)AnyCallablecastOptionalUnion)urljoin   )default_loader)check_integritydownload_and_extract_archiveverify_str_arg)VisionDatasetc                     ^  \ rS rSrSrSrSrSSS.rSrS	S
SSS.r	SSSSSSSSS.r
SSSSS\4S\\\4   S\S\S\S\\   S\\   S\\/\4   S S4U 4S! jjjrS"\S \\\4   4S# jrS \4S$ jr\S \4S% j5       r\S \4S& j5       rS1S\S \\\   \\\4   4   4S' jjr S1S\S \\\\\\S4   4      \\\S4      4   4S( jjrS2S) jrS2S* jr S \4S+ jr!S\S \4S, jr"S-\S.\S\S \4S/ jr#S0r$U =r%$ )3	Places365   a  `Places365 <http://places2.csail.mit.edu/index.html>`_ classification dataset.

Args:
    root (str or ``pathlib.Path``): Root directory of the Places365 dataset.
    split (string, optional): The dataset split. Can be one of ``train-standard`` (default), ``train-challenge``,
        ``val``, ``test``.
    small (bool, optional): If ``True``, uses the small images, i.e. resized to 256 x 256 pixels, instead of the
        high resolution ones.
    download (bool, optional): If ``True``, downloads the dataset components and places them in ``root``. Already
        downloaded archives are not downloaded again.
    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.
    loader (callable, optional): A function to load an image given its path.

 Attributes:
    classes (list): List of the class names.
    class_to_idx (dict): Dict with items (class_name, class_index).
    imgs (list): List of (image path, class_index) tuples
    targets (list): The class_index value for each image in the dataset

Raises:
    RuntimeError: If ``download is False`` and the meta files, i.e. the devkit, are not present or corrupted.
    RuntimeError: If ``download is True`` and the image archive is already extracted.
)train-standardtrain-challengevaltestz+http://data.csail.mit.edu/places/places365/)zfilelist_places365-standard.tar 35a0585fee1fa656440f3ab298f8479c)z filelist_places365-challenge.tar 70a8307e459c3de41690a7c76c931734)standard	challenge)zcategories_places365.txt 06c963b85866bd0649f97cb43dd16673)zplaces365_train_standard.txt 30f37515461640559006b8329efbed1a)zplaces365_train_challenge.txt b2931dc997b8c33c27e7329c073a6b57)zplaces365_val.txt e9f2fd57bfd9d07630173f4e8708e4b1)zplaces365_test.txt 2fce8233fe493576d724142e45d93653)z!train_large_places365standard.tar 67e186b496a84c929568076ed01a8aa1)z"train_large_places365challenge.tar 605f18e68e510c82b958664ea134545f)zval_large.tar 9b71c4993ad89d2d8bcbdc4aef38042f)ztest_large.tar 41a4b6b724b1d2cd862fb3871ed59913)ztrain_256_places365standard.tar 53ca1c756c3d1e7809517cc47c5561c5)z train_256_places365challenge.tar 741915038a5e3471ec7332404dfb64ef)zval_256.tar e27b17d8d44f4af9a78502beb927f808)ztest_256.tar f532f6ad7b582262a2ec8009075e186b))r   F)r   F)r   F)r   F)r   T)r   T)r   T)r   Tr   FNrootsplitsmalldownload	transformtarget_transformloaderreturnc                   > [         TU ]  XUS9  U R                  U5      U l        X0l        Xpl        U R                  U5      u  U l        U l        U R                  U5      u  U l
        U l        U(       a  U R                  5         g g )N)r-   r.   )super__init___verify_splitr*   r+   r/   load_categoriesclassesclass_to_idxload_file_listimgstargetsdownload_images)	selfr)   r*   r+   r,   r-   r.   r/   	__class__s	           V/var/www/auris/envauris/lib/python3.13/site-packages/torchvision/datasets/places365.pyr3   Places365.__init__D   s{     	EUV''.

*.*>*>x*H'd'"&"5"5h"?	4<  "     indexc                     U R                   U   u  p#U R                  U5      nU R                  b  U R                  XC5      u  pCXC4$ N)r9   r/   
transforms)r<   rA   filetargetimages        r>   __getitem__Places365.__getitem__Z   sB    yy'D!??& OOE:ME}r@   c                 ,    [        U R                  5      $ rC   )lenr9   r<   s    r>   __len__Places365.__len__c   s    499~r@   c                 *    SU R                   ;   a  S$ S$ )Nr   r   )r*   rL   s    r>   variantPlaces365.variantf   s    )TZZ7{GZGr@   c                     U R                   (       a  SOSnU R                  R                  S5      (       a  SU SU R                   3nOU R                   SU 3n[        R
                  " U R                  U5      $ )N256largetraindata__)r+   r*   
startswithrP   r   joinr)   )r<   sizedirs      r>   
images_dirPlaces365.images_dirj   sc    

u::  ))$q/CZZL$(CyyC((r@   c                   ^ S[         S[        [         [        4   4S jmU R                  u  p#[        R
                  " U R                  U5      nU R                  X#U5      (       d  U R                  5         [        U5       n[        U4S jU 5       5      nS S S 5        [        WR                  5       5      U4$ ! , (       d  f       N)= f)Nliner0   c                 @    U R                  5       u  pU[        U5      4$ rC   )r*   int)r_   clsidxs      r>   process*Places365.load_categories.<locals>.processt   s    zz|HCC= r@   c              3   4   >#    U  H  nT" U5      v   M     g 7frC    ).0r_   rd   s     r>   	<genexpr>,Places365.load_categories.<locals>.<genexpr>~   s     ="$"s   )strtuplera   _CATEGORIES_METAr   rY   r)   _check_integritydownload_devkitopendictsortedkeys)r<   r,   rE   md5fhr7   rd   s         @r>   r5   Places365.load_categoriess   s    	!# 	!%S/ 	! ))	yyD)$$T99  "$Z2="==L  l'')*L88 Zs   B::
Cc           	        ^  SS[         S[        [         [        [        S 4   4   4U 4S jjjnT R                  T R
                     u  p4[        R                  " T R                  U5      nT R                  X4U5      (       d  T R                  5         [        U5       nU Vs/ s H
  ob" U5      PM     nnS S S 5        [        W6 u  pU[        U	5      4$ s  snf ! , (       d  f       N*= f)Nr_   r0   c                   > U R                  5       S /-   S S u  p#[        [        U5      nUb  [        U5      OS n[        R
                  " TR                  UR                  U5      R                  U[        R                  5      5      U4$ )N   )r*   r   rk   ra   r   rY   r\   lstripreplaceossep)r_   r}   rG   rc   r<   s       r>   rd   )Places365.load_file_list.<locals>.process   sn    **,$/!4JEe$E!o#c(4C99T__ell3.?.G.GRVV.TUWZZZr@   )/)rk   rl   r	   ra   _FILE_LIST_METAr*   r   rY   r)   rn   ro   rp   ziplist)
r<   r,   rd   rE   rt   ru   r_   imagesrW   r:   s
   `         r>   r8   Places365.load_file_list   s    	[# 	[5eCI6F1F+G 	[ 	[ ((4	yyD)$$T99  "$Z2023gdmF3  &\
tG}$$ 4 Zs   C!C2CC
C&c                     U R                   U R                     u  p[        [        U R                  U5      U R
                  US9  g )Nrt   )_DEVKIT_METArP   r   r
   	_BASE_URLr)   r<   rE   rt   s      r>   ro   Places365.download_devkit   s4    %%dll3	$WT^^T%BDIISVWr@   c                    [         R                  " U R                  5      (       a  g U R                  U R                  U R
                  4   u  p[        [        U R                  U5      U R                  US9  U R                  R                  S5      (       a?  [        R                  " U R                  R                  SS5      S   U R                  5        g g )Nr   rU   rW   r   r   )r   existsr\   _IMAGES_METAr*   r+   r   r
   r   r)   rX   r|   renamersplitr   s      r>   r;   Places365.download_images   s    ;;t''%%tzz4::&>?	$WT^^T%BDIISVW::  ))IIdoo,,S!4Q7I *r@   c                 X    SR                  S5      R                  " S0 U R                  D6$ )N
)zSplit: {split}zSmall: {small}rg   )rY   format__dict__rL   s    r>   
extra_reprPlaces365.extra_repr   s$    yy=>EEVVVr@   c                 0    [        USU R                  5      $ )Nr*   )r   _SPLITS)r<   r*   s     r>   r4   Places365._verify_split   s    eWdll;;r@   rE   rt   c                 R    [        XS9nU(       d  U(       d  [        SU S35      eU$ )Nr   z	The file zJ does not exist or is corrupted. You can set download=True to download it.)r   RuntimeError)r<   rE   rt   r,   	integritys        r>   rn   Places365._check_integrity   s3    #D2	D6!kl  r@   )r7   r6   r9   r/   r+   r*   r:   )T)r0   N)&__name__
__module____qualname____firstlineno____doc__r   r   r   rm   r   r   r   r	   rk   r   boolr   r   r   r3   ra   rl   rH   rM   propertyrP   r\   r   rq   r5   r8   ro   r;   r   r4   rn   __static_attributes____classcell__)r=   s   @r>   r   r      s   6 CG=I \]L
 X _`HJ	O $m$nMO"i#kJL	L &(,/3'5#CI# # 	#
 # H%# #8,# #$# 
# #, sCx   H H H )C ) )9 9d3icSVh>W8X 9   $%%	tE#uS$Y//014c4i8H3II	J%(XJWC W<3 <3 <S s d t  r@   r   )r|   r   pathlibr   typingr   r   r   r   r	   urllib.parser
   folderr   utilsr   r   r   visionr   r   rg   r@   r>   <module>r      s1    	   7 7   " P P !d dr@   