ó
    Eñi¹  ã                   ó^   • S SK r S SKJrJrJrJr  SSKJr  SSKJ	r	  SSK
Jr   " S S\5      rg)	é    N)ÚAnyÚCallableÚOptionalÚUnioné   )Údefault_loader)Úverify_str_arg)ÚVisionDatasetc                   óÎ   ^ • \ rS rSrSrSSSS\4S\\\R                  4   S\S\
\   S	\
\   S
\S\\/\4   SS4U 4S jjjrS\4S jrS\S\\\4   4S jrS\4S jrS rSrU =r$ )ÚStanfordCarsé
   aJ  Stanford Cars  Dataset

The Cars dataset contains 16,185 images of 196 classes of cars. The data is
split into 8,144 training images and 8,041 testing images, where each class
has been split roughly in a 50-50 split

The original URL is https://ai.stanford.edu/~jkrause/cars/car_dataset.html,
the dataset isn't available online anymore.

.. note::

    This class needs `scipy <https://docs.scipy.org/doc/>`_ to load target files from `.mat` format.

Args:
    root (str or ``pathlib.Path``): Root directory of dataset
    split (string, optional): The dataset split, supports ``"train"`` (default) or ``"test"``.
    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.
    download (bool, optional): This parameter exists for backward compatibility but it does not
        download the dataset, since the original URL is not available anymore.
    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.
ÚtrainNFÚrootÚsplitÚ	transformÚtarget_transformÚdownloadÚloaderÚreturnc                 óˆ  >•  SS K Jn  [        TU ]  XUS9  [        USS5      U l        [        R                  " U5      S-  U l
        U R                  S-  nU R                  S:X  a  US	-  U l        U R                  S
-  U l        O(U R                  S-  U l        U R                  S-  U l        U(       a  U R                  5         U R                  5       (       d  [        S5      eUR                  U R                  SS9S    V	s/ s H&  n	[!        U R                  U	S   -  5      U	S   S-
  4PM(     sn	U l        UR                  [!        US-  5      SS9S   R%                  5       U l        [)        U R&                  5       V
Vs0 s H  u  p«Xº_M	     snn
U l        X`l        g ! [         a    [        S5      ef = fs  sn	f s  snn
f )Nr   zQScipy is not found. This dataset needs to have scipy installed: pip install scipy)r   r   r   )r   ÚtestÚstanford_carsÚdevkitr   zcars_train_annos.matÚ
cars_trainzcars_test_annos_withlabels.matÚ	cars_testzDataset not found.T)Ú
squeeze_meÚannotationsÚfnameÚclassr   zcars_meta.matÚclass_names)Úscipy.ioÚioÚImportErrorÚRuntimeErrorÚsuperÚ__init__r	   Ú_splitÚpathlibÚPathÚ_base_folderÚ_annotations_mat_pathÚ_images_base_pathr   Ú_check_existsÚloadmatÚstrÚ_samplesÚtolistÚclassesÚ	enumerateÚclass_to_idxr   )Úselfr   r   r   r   r   r   Úsior   Ú
annotationÚiÚclsÚ	__class__s               €Ú_/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torchvision/datasets/stanford_cars.pyr&   ÚStanfordCars.__init__&   s¿  ø€ ð	tÝ"ô 	‰Ñ˜ÐEUÐÑVä$ U¨GÐ5FÓGˆŒÜ#ŸLšL¨Ó.°Ñ@ˆÔØ×"Ñ" XÑ-ˆà�;‰;˜'Ó!Ø)/Ð2HÑ)HˆDÔ&Ø%)×%6Ñ%6¸Ñ%EˆDÕ"à)-×):Ñ):Ð=]Ñ)]ˆDÔ&Ø%)×%6Ñ%6¸Ñ%DˆDÔ"æØ�M‰MŒOà×!Ñ!×#Ñ#ÜÐ3Ó4Ð4ð "Ÿk™k¨$×*DÑ*DÐQU˜kÐVÐWdÒeó
ò
 f�
ô �D×*Ñ*¨Z¸Ñ-@Ñ@ÓAØ˜7Ñ# aÑ'óñ fñ
ˆŒð —{‘{¤3 v°Ñ'?Ó#@ÈT�{ÐRÐS`Ña×hÑhÓjˆŒÜ2;¸D¿L¹LÔ2IÔJÒ2I©¨˜SšVÑ2IÒJˆÔØ�øôA ó 	tÜÐrÓsÐsð	tüò,
ùó Ks   ƒF  Ä-F9ÆF>Æ F6c                 ó,   • [        U R                  5      $ )N)Úlenr0   ©r5   s    r;   Ú__len__ÚStanfordCars.__len__T   s   € Ü�4—=‘=Ó!Ð!ó    Úidxc                 óÄ   • 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$ )z.Returns pil_image and class_id for given index)r0   r   r   r   )r5   rC   Ú
image_pathÚtargetÚimages        r;   Ú__getitem__ÚStanfordCars.__getitem__W   s]   € à!Ÿ]™]¨3Ñ/Ñˆ
Ø—‘˜JÓ'ˆà�>‰>Ñ%Ø—N‘N 5Ó)ˆEØ× Ñ Ñ,Ø×*Ñ*¨6Ó2ˆFØˆ}ÐrB   c                 ó¾   • U R                   S-  R                  5       (       d  gU R                  R                  5       =(       a    U R                  R                  5       $ )Nr   F)r*   Úis_dirr+   Úexistsr,   r?   s    r;   r-   ÚStanfordCars._check_existsb   sH   € Ø×!Ñ! HÑ,×4Ñ4×6Ñ6Øà×)Ñ)×0Ñ0Ó2×V°t×7MÑ7M×7TÑ7TÓ7VÐVrB   c                 ó   • [        S5      e)NzTThe original URL is broken so the StanfordCars dataset cannot be downloaded anymore.)Ú
ValueErrorr?   s    r;   r   ÚStanfordCars.downloadh   s   € ÜÐoÓpÐprB   )r+   r*   r,   r0   r'   r4   r2   r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r/   r(   r)   r   r   Úboolr   r&   Úintr@   ÚtuplerH   r-   r   Ú__static_attributes__Ú__classcell__)r:   s   @r;   r   r   
   sÌ   ø† ñð< Ø(,Ø/3ØØ'5ñ,à�C˜Ÿ™Ð%Ñ&ð,ð ð,ð ˜HÑ%ð	,ð
 # 8Ñ,ð,ð ð,ð ˜#˜ ˜Ñ$ð,ð 
÷,ð ,ð\"˜ô "ð	˜sð 	 u¨S°#¨X¡ô 	ðW˜tô W÷qð qrB   r   )r(   Útypingr   r   r   r   Úfolderr   Úutilsr	   Úvisionr
   r   © rB   r;   Ú<module>r`      s'   ðÛ ß 1Ó 1å "å !Ý !ô_q�=õ _qrB   