
    h;                     ~    S SK rS SKJr  S SKJrJrJrJrJ	r	  S SK
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)AnyCallablecastOptionalUnion)Image   )check_integritydownload_and_extract_archiveverify_str_arg)VisionDatasetc                     ^  \ rS rSrSrSrSrSrSrSr	Sr
S	S
/SS/SS//rSS/SS//rSr     S)S\\\4   S\S\\   S\\   S\\   S\SS4U 4S jjjrS\\   S\\   4S jrS\S\\\4   4S jrS\4S  jrS*S!\S"\\   S\\R8                  \\R8                     4   4S# jjrS\4S$ jrS+S% jrS\4S& jr S\\   SS4S' jr!S(r"U =r#$ ),STL10   a  `STL10 <https://cs.stanford.edu/~acoates/stl10/>`_ Dataset.

Args:
    root (str or ``pathlib.Path``): Root directory of dataset where directory
        ``stl10_binary`` exists.
    split (string): One of {'train', 'test', 'unlabeled', 'train+unlabeled'}.
        Accordingly, dataset is selected.
    folds (int, optional): One of {0-9} or None.
        For training, loads one of the 10 pre-defined folds of 1k samples for the
        standard evaluation procedure. If no value is passed, loads the 5k samples.
    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.
stl10_binaryz9http://ai.stanford.edu/~acoates/stl10/stl10_binary.tar.gzzstl10_binary.tar.gz 91f7769df0f17e558f3565bffb0c7dfbzclass_names.txtzfold_indices.txtztrain_X.bin 918c2871b30a85fa023e0c44e0bee87fztrain_y.bin 5a34089d4802c674881badbb80307741zunlabeled_X.bin 5242ba1fed5e4be9e1e742405eb56ca4z
test_X.bin 7f263ba9f9e0b06b93213547f721ac82z
test_y.bin 36f9794fa4beb8a2c72628de14fa638e)traintrain+unlabeled	unlabeledtestNrootsplitfolds	transformtarget_transformdownloadreturnc                   > [         TU ]  XUS9  [        USU R                  5      U l        U R                  U5      U l        U(       a  U R                  5         O U R                  5       (       d  [        S5      eU   U R                  S:X  a{  U R                  U R                  S   S   U R                  S   S   5      u  U l        U l        [        [        R                   U R                  5      U l        U R#                  U5        GOU R                  S:X  Ga  U R                  U R                  S   S   U R                  S   S   5      u  U l        U l        [        [        R                   U R                  5      U l        U R#                  U5        U R                  U R                  S   S   5      u  px[        R$                  " U R                  U45      U l        [        R$                  " U R                  [        R&                  " S	/UR(                  S   -  5      45      U l        OU R                  S
:X  a`  U R                  U R                  S   S   5      u  U l        n[        R&                  " S	/U R                  R(                  S   -  5      U l        O?U R                  U R*                  S   S   U R*                  S   S   5      u  U l        U l        [,        R.                  R1                  U R2                  U R4                  U R6                  5      n	[,        R.                  R9                  U	5      (       a8  [;        U	5       n
U
R=                  5       R?                  5       U l         S S S 5        g g ! , (       d  f       g = f)N)r    r!   r   zHDataset not found or corrupted. You can use download=True to download itr   r   r
   r      r   )!super__init__r   splitsr   _verify_foldsr   r"   _check_integrityRuntimeError_STL10__loadfile
train_listdatalabelsr   npndarray_STL10__load_foldsconcatenateasarrayshape	test_listospathjoinr   base_folderclass_names_fileisfileopenread
splitlinesclasses)selfr   r   r   r    r!   r"   unlabeled_data_
class_filef	__class__s              R/var/www/auris/envauris/lib/python3.13/site-packages/torchvision/datasets/stl10.pyr(   STL10.__init__/   s    	EUV#E7DKK@
''.
MMO&&((ijj 	:: %)__T__Q5G5JDOO\]L^_`La%b"DIt{rzz4;;7DKe$ZZ,,%)__T__Q5G5JDOO\]L^_`La%b"DIt{rzz4;;7DKe$ $0B10E FN		>'BCDI..$++rzz2$I]I]^_I`B`7a)bcDKZZ;&??4??1+=a+@ALDIq**bTDIIOOA,>%>?DK%)__T^^A5Fq5I4>>Z[K\]^K_%`"DIt{WW\\$))T-=-=t?T?TU
77>>*%%j!Q vvx224 "! &!!s   $M33
Nc                     Uc  U$ [        U[        5      (       a-  U[        S5      ;   a  U$ Sn[        UR	                  U5      5      eSn[        UR	                  [        U5      5      5      e)N
   zDValue for argument folds should be in the range [0, 10), but got {}.z>Expected type None or int for argument folds, but got type {}.)
isinstanceintrange
ValueErrorformattype)rB   r   msgs      rH   r*   STL10._verify_folds[   s`    =Ls##b	!XCSZZ.//RCSZZU455    indexc                 ^   U R                   b'  U R                  U   [        U R                   U   5      p2OU R                  U   Sp2[        R                  " [
        R                  " US5      5      nU R                  b  U R                  U5      nU R                  b  U R                  U5      nX#4$ )zn
Args:
    index (int): Index

Returns:
    tuple: (image, target) where target is index of the target class.
N)r
   r%   r   )	r0   r/   rM   r	   	fromarrayr1   	transposer    r!   )rB   rU   imgtargets       rH   __getitem__STL10.__getitem__g   s     ;;"))E*CE0B,C))E*D oobll3	:;>>%..%C  ,**62F{rT   c                 4    U R                   R                  S   $ )Nr   )r/   r6   rB   s    rH   __len__STL10.__len__   s    yyq!!rT   	data_filelabels_filec                 z   S nU(       ap  [         R                  R                  U R                  U R                  U5      n[        US5       n[        R                  " U[        R                  S9S-
  nS S S 5        [         R                  R                  U R                  U R                  U5      n[        US5       n[        R                  " U[        R                  S9n[        R                  " US5      n[        R                  " US5      nS S S 5        X4$ ! , (       d  f       N= f! , (       d  f       WU4$ = f)Nrb)dtyper
   )r&      `   rg   )r   r
   rf   r%   )r8   r9   r:   r   r;   r>   r1   fromfileuint8reshaperX   )	rB   ra   rb   r0   path_to_labelsrF   path_to_data
everythingimagess	            rH   
__loadfileSTL10.__loadfile   s    WW\\$))T5E5E{SNnd+qQbhh7!; , ww||DIIt/?/?K,%Qbhh7JZZ
O<F\\&,7F	 & ~ ,+ &% v~s   'D;AD)
D&)
D:c                     U R                   U R                  -    HL  u  p[        R                  R	                  U R
                  U R                  U5      n[        X25      (       a  ML    g   g)NFT)r.   r7   r8   r9   r:   r   r;   r   )rB   filenamemd5fpaths       rH   r+   STL10._check_integrity   sN    !__t~~=MHGGLLD,<,<hGE"5.. > rT   c                     U R                  5       (       a  g [        U R                  U R                  U R                  U R
                  S9  U R                  5         g )N)rr   rs   )r+   r   urlr   rr   tgz_md5r^   s    rH   r"   STL10.download   sA      ""$TXXtyy4==VZVbVbcrT   c                 :    SR                   " S0 U R                  D6$ )NzSplit: {split} )rP   __dict__r^   s    rH   
extra_reprSTL10.extra_repr   s    &&777rT   c                    Uc  g [         R                  R                  U R                  U R                  U R
                  5      n[        U5       nUR                  5       R                  5       U   n[        R                  " U[        R                  SS9nU R                  US S 2S S 2S S 24   U l        U R                  b  U R                  U   U l        S S S 5        g ! , (       d  f       g = f)N )re   sep)r8   r9   r:   r   r;   folds_list_filer>   r?   r@   r1   
fromstringint64r/   r0   )rB   r   path_to_foldsrF   str_idxlist_idxs         rH   __load_foldsSTL10.__load_folds   s    =TYY0@0@$BVBVW- Affh))+E2G}}WBHH#FH		(Aq!"34DI{{&"kk(3 !  s   BC
C+)rA   r/   r   r0   r   )r   NNNF)N)r#   N)$__name__
__module____qualname____firstlineno____doc__r;   rw   rr   rx   r<   r   r.   r7   r)   r   strr   r   rM   r   boolr(   r*   tupler   r[   r_   r1   r2   r-   r+   r"   r}   r3   __static_attributes____classcell__)rG   s   @rH   r   r      s   & !K
EC$H0G((O	:;	:;	>?J  BClTvEwxI>F
 #(,/3*5CI*5 *5 }	*5
 H%*5 #8,*5 *5 
*5 *5X
68C= 
6Xc] 
6 sCx 4" "C hsm uUWU_U_aijljtjtauUuOv  $  8C 8
4(3- 
4D 
4 
4rT   r   )os.pathr8   pathlibr   typingr   r   r   r   r   numpyr1   PILr	   utilsr   r   r   visionr   r   r{   rT   rH   <module>r      s.      7 7   P P !b4M b4rT   