
    QЦi                     z    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Jr  SSKJrJr  SSKJr   " S S	\5      rg
)    )Path)AnyCallableOptionalTupleUnion)Image   )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\\\	4   S\S\S\
\   S\
\   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   a$  `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 and returns a transformed
        version, e.g. ``transforms.RandomCrop``.
    target_transform (callable, optional): A function/transform that takes in the target and transforms it.

 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	n03888257Nrootsplitsize	transformtarget_transform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  opR(                  U   PM     snU l        U R&                  R-                  5        VVV	s0 s H  u  pxU R(                  U     H  oU_M     M      sn	nnU l        [1        U R                  U R&                  SS	9U l        g s  snf s  sn	nnf )
N)r.   r/   r,   train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   _samples)selfr+   r,   r-   downloadr.   r/   wnididx
class_name	__class__s             ^/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/torchvision/datasets/imagenette.pyr6   Imagenette.__init__1   sj    	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   'F9%%F>c                 6    U R                   R                  5       $ N)r=   existsrJ   s    rP   rA   Imagenette._check_existsO   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._downloadR   s,    $TYY		tyyIrW   rM   c                     U R                   U   u  p#[        R                  " U5      R                  S5      nU R                  b  U R	                  U5      nU R
                  b  U R                  U5      nXC4$ )NRGB)rI   r	   openconvertr.   r/   )rJ   rM   pathlabelimages        rP   __getitem__Imagenette.__getitem__X   sg    mmC(

4 ((/>>%NN5)E  ,))%0E|rW   c                 ,    [        U R                  5      $ rS   )lenrI   rU   s    rP   __len__Imagenette.__len__d   s    4==!!rW   )r?   r;   rI   r8   r=   r7   r:   rH   rF   rD   rC   )r2   r   FNN)__name__
__module____qualname____firstlineno____doc__r9   rE   r   r>   r   r   r   r6   boolrA   r@   intr   r   rb   rf   __static_attributes____classcell__)rO   s   @rP   r   r      s    ( swwI .E).2,2U#+N  (,/3]CI] ] 	] H%] #8,] 
] ]<(t (J
s 
uS#X 
" " "rW   r   N)pathlibr   typingr   r   r   r   r   PILr	   folderr   r   utilsr   r   visionr   r    rW   rP   <module>rx      s(     8 8  . ? !Z" Z"rW   