
    h                     n    S SK Jr  S SKJrJrJrJr  SSKJrJ	r	J
r
  SSKJrJr  SSKJr   " S S\5      rg	)
    )Path)AnyCallableOptionalUnion   )default_loaderfind_classesmake_dataset)download_and_extract_archiveverify_str_arg)VisionDatasetc                      ^  \ rS rSrSrSSSS.rSSS	S
SSSSSSS.
rSSSSS\4S\\	\
4   S\	S\	S\\   S\\   S\\	/\4   SS4U 4S jjjrS\4S jrS rS \S\\\4   4S! jrS\4S" jrS#rU =r$ )$
Imagenette	   aG  `Imagenette <https://github.com/fastai/imagenette#imagenette-1>`_ image classification dataset.

Args:
    root (str or ``pathlib.Path``): Root directory of the Imagenette dataset.
    split (string, optional): The dataset split. Supports ``"train"`` (default), and ``"val"``.
    size (string, optional): The image size. Supports ``"full"`` (default), ``"320px"``, and ``"160px"``.
    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 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.
    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.

 Attributes:
    classes (list): List of the class name tuples.
    class_to_idx (dict): Dict with items (class name, class index).
    wnids (list): List of the WordNet IDs.
    wnid_to_idx (dict): Dict with items (WordNet ID, class index).
)z:https://s3.amazonaws.com/fast-ai-imageclas/imagenette2.tgz fe2fc210e6bb7c5664d602c3cd71e612)z>https://s3.amazonaws.com/fast-ai-imageclas/imagenette2-320.tgz 3df6f0d01a2c9592104656642f5e78a3)z>https://s3.amazonaws.com/fast-ai-imageclas/imagenette2-160.tgz e793b78cc4c9e9a4ccc0c1155377a412full320px160px)tenchzTinca tinca)zEnglish springerzEnglish springer spaniel)zcassette player)z	chain sawchainsaw)churchzchurch building)zFrench hornhorn)zgarbage truckdustcart)zgas pumpzgasoline pumpzpetrol pumpzisland dispenser)z	golf ball)	parachutechute)
	n01440764	n02102040	n02979186	n03000684	n03028079	n03394916	n03417042	n03425413	n03445777	n03888257trainr   FNrootsplitsize	transformtarget_transformloaderreturnc                   > [         TU ]  XUS9  [        USSS/5      U l        [        US/ SQ5      U l        U R
                  U R                     u  U l        U l        [        U R                  5      [        U R                  5      R                  -  U l        [        U R                  U R                  -  5      U l        U(       a  U R                  5         O U R                  5       (       d  [!        S5      e[#        U R                  5      u  U l        U l        U R$                   Vs/ s H  oR(                  U   PM     snU l        U R&                  R-                  5        VV	V
s0 s H  u  pU R(                  U     H  oU	_M     M      sn
n	nU l        [1        U R                  U R&                  SS	9U l        Xpl        g s  snf s  sn
n	nf )
N)r.   r/   r,   r*   valr-   r   z<Dataset not found. You can use download=True to download it.z.jpeg)
extensions)super__init__r   _split_size	_ARCHIVES_url_md5r   r+   stem
_size_rootstr_image_root	_download_check_existsRuntimeErrorr
   wnidswnid_to_idx_WNID_TO_CLASSclassesitemsclass_to_idxr   _samplesr0   )selfr+   r,   r-   downloadr.   r/   r0   wnididx
class_name	__class__s              W/var/www/auris/envauris/lib/python3.13/site-packages/torchvision/datasets/imagenette.pyr6   Imagenette.__init__2   so    	EUV$UGgu5EF#D&2LM
#~~djj9	49tyy/DO,@,@@t<=NN##%%]^^'3D4D4D'E$
D$>BjjIjd++D1jI-1-=-=-C-C-E
-E	X\XkXklpXq*OXqJ-E
 %T%5%5t7G7GT[\ J
s   'F?%%Gc                 6    U R                   R                  5       $ N)r=   existsrJ   s    rP   rA   Imagenette._check_existsR   s    %%''    c                     U R                  5       (       a  g [        U R                  U R                  U R                  S9  g )N)md5)rA   r   r:   r+   r;   rU   s    rP   r@   Imagenette._downloadU   s,    $TYY		tyyIrW   rM   c                     U R                   U   u  p#U R                  U5      nU R                  b  U R                  U5      nU R                  b  U R                  U5      nXC4$ rS   )rI   r0   r.   r/   )rJ   rM   pathlabelimages        rP   __getitem__Imagenette.__getitem__[   s\    mmC(D!>>%NN5)E  ,))%0E|rW   c                 ,    [        U R                  5      $ rS   )lenrI   rU   s    rP   __len__Imagenette.__len__g   s    4==!!rW   )r?   r;   rI   r8   r=   r7   r:   rH   rF   r0   rD   rC   )__name__
__module____qualname____firstlineno____doc__r9   rE   r	   r   r>   r   r   r   r   r6   boolrA   r@   inttupler_   rc   __static_attributes____classcell__)rO   s   @rP   r   r   	   s   . swwI .E).2,2U#+N  (,/3'5CI  	 H% #8, #$ 
 @(t (J
s 
uS#X 
" " "rW   r   N)pathlibr   typingr   r   r   r   folderr	   r
   r   utilsr   r   visionr   r    rW   rP   <module>ru      s(     1 1 > > ? !_" _"rW   