
    h                         S SK rS SKrS SKJr  S SKJrJrJrJ	r	  S SK
rS SKJr  SSKJrJr  SSKJr   " S S	\5      r " S
 S\5      rg)    N)Path)AnyCallableOptionalUnion)Image   )check_integritydownload_and_extract_archive)VisionDatasetc                     ^  \ rS rSrSrSrSrSrSrSS/S	S
/SS/SS/SS//r	SS//r
SSSS.r    S'S\\\4   S\S\\   S\\   S\SS4U 4S jjjrS(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\4S% jrS&rU =r$ ))CIFAR10   a.  `CIFAR10 <https://www.cs.toronto.edu/~kriz/cifar.html>`_ Dataset.

Args:
    root (str or ``pathlib.Path``): Root directory of dataset where directory
        ``cifar-10-batches-py`` exists or will be saved to if download is set to True.
    train (bool, optional): If True, creates dataset from training set, otherwise
        creates from test set.
    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.

zcifar-10-batches-pyz7https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gzzcifar-10-python.tar.gz c58f30108f718f92721af3b95e74349adata_batch_1 c99cafc152244af753f735de768cd75fdata_batch_2 d4bba439e000b95fd0a9bffe97cbabecdata_batch_3 54ebc095f3ab1f0389bbae665268c751data_batch_4 634d18415352ddfa80567beed471001adata_batch_5 482c414d41f54cd18b22e5b47cb7c3cb
test_batch 40351d587109b95175f43aff81a1287ezbatches.metalabel_names 5ff9c542aee3614f3951f8cda6e48888filenamekeymd5Nroottrain	transformtarget_transformdownloadreturnc                   > [         TU ]  XUS9  X l        U(       a  U R                  5         U R	                  5       (       d  [        S5      eU R                  (       a  U R                  nOU R                  n/ U l        / U l	        U H  u  px[        R                  R                  U R                  U R                  U5      n	[        U	S5       n
[         R"                  " U
SS9nU R                  R%                  US   5        SU;   a  U R                  R'                  US   5        OU R                  R'                  US   5        S S S 5        M     [(        R*                  " U R                  5      R-                  S	S
SS5      U l        U R                  R/                  S5      U l        U R1                  5         g ! , (       d  f       GMA  = f)N)r%   r&   zHDataset not found or corrupted. You can use download=True to download itrblatin1encodingdatalabelsfine_labels       )r      r2   r	   )super__init__r$   r'   _check_integrityRuntimeError
train_list	test_listr.   targetsospathjoinr#   base_folderopenpickleloadappendextendnpvstackreshape	transpose
_load_meta)selfr#   r$   r%   r&   r'   downloaded_list	file_namechecksum	file_pathfentry	__class__s               R/var/www/auris/envauris/lib/python3.13/site-packages/torchvision/datasets/cifar.pyr6   CIFAR10.__init__4   sY    	EUV
MMO$$&&ijj::"ooO"nnO	 $3ITYY0@0@)LIi&!A9		  v/u$LL''h8LL''m(<= '& $3 IIdii(00QB?	II''5	 '&s   A7F88
G	c                    [         R                  R                  U R                  U R                  U R
                  S   5      n[        XR
                  S   5      (       d  [        S5      e[        US5       n[        R                  " USS9nX0R
                  S      U l        S S S 5        [        U R                  5       VVs0 s H  u  pEXT_M	     snnU l        g ! , (       d  f       N>= fs  snnf )Nr    r"   zVDataset metadata file not found or corrupted. You can use download=True to download itr*   r+   r,   r!   )r<   r=   r>   r#   r?   metar
   r8   r@   rA   rB   classes	enumerateclass_to_idx)rJ   r=   infiler.   i_classs         rR   rI   CIFAR10._load_meta_   s    ww||DIIt'7'7:9NOtYYu%566wxx$;;v9D		% 01DL  9B$,,8OP8O91VY8OP  Qs   7,CC,
C)indexc                     U R                   U   U R                  U   p2[        R                  " U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.
)r.   r;   r   	fromarrayr%   r&   )rJ   r]   imgtargets       rR   __getitem__CIFAR10.__getitem__h   si     ii&U(;V ooc">>%..%C  ,**62F{    c                 ,    [        U R                  5      $ )N)lenr.   rJ   s    rR   __len__CIFAR10.__len__~   s    499~rd   c                     U R                   U R                  -    HL  u  p[        R                  R	                  U R
                  U R                  U5      n[        X25      (       a  ML    g   g)NFT)r9   r:   r<   r=   r>   r#   r?   r
   )rJ   r    r"   fpaths       rR   r7   CIFAR10._check_integrity   sN    !__t~~=MHGGLLD,<,<hGE"5.. > rd   c                     U R                  5       (       a  g [        U R                  U R                  U R                  U R
                  S9  g )N)r    r"   )r7   r   urlr#   r    tgz_md5rg   s    rR   r'   CIFAR10.download   s5      ""$TXXtyy4==VZVbVbcrd   c                 2    U R                   SL a  SOSnSU 3$ )NTTrainTestzSplit: )r$   )rJ   splits     rR   
extra_reprCIFAR10.extra_repr   s!    ::-6  rd   )rX   rV   r.   r;   r$   )TNNF)r(   N)__name__
__module____qualname____firstlineno____doc__r?   rn   r    ro   r9   r:   rU   r   strr   boolr   r   r6   rI   inttupler   rb   rh   r7   r'   ru   __static_attributes____classcell__)rQ   s   @rR   r   r      s,   " (K
CC'H0G	;<	;<	;<	;<	;<J 
9:I #1D (,/3)CI) ) H%	)
 #8,) ) 
) )VQ sCx , $ d
!C ! !rd   r   c                   H    \ rS rSrSrSrSrSrSrSS//r	S	S
//r
SSSS.rSrg)CIFAR100   zq`CIFAR100 <https://www.cs.toronto.edu/~kriz/cifar.html>`_ Dataset.

This is a subclass of the `CIFAR10` Dataset.
zcifar-100-pythonz8https://www.cs.toronto.edu/~kriz/cifar-100-python.tar.gzzcifar-100-python.tar.gz eb9058c3a382ffc7106e4002c42a8d85r$    16019d7e3df5f24257cddd939b257f8dtest f0ef6b0ae62326f3e7ffdfab6717acfcrU   fine_label_names 7973b15100ade9c7d40fb424638fde48r    N)rw   rx   ry   rz   r{   r?   rn   r    ro   r9   r:   rU   r   r   rd   rR   r   r      sQ    
 %K
DC(H0G	45J
 
34I !1Drd   r   )os.pathr<   rA   pathlibr   typingr   r   r   r   numpyrE   PILr   utilsr
   r   visionr   r   r   r   rd   rR   <module>r      s;       1 1   @ !B!m B!Jw rd   