ó
    EñiÕ  ã                   óz   • 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Jr  SSKJr   " S S	\5      rg)
é    N)ÚPath)ÚAnyÚCallableÚOptionalÚUnion)ÚImageé   )Úcheck_integrityÚdownload_urlÚverify_str_arg)ÚVisionDatasetc                   óÒ   ^ • \ rS rSrSr/ SQ/ SQ/ SQS.r    SS\\\4   S	\S
\	\
   S\	\
   S\SS4U 4S jj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$ )ÚSVHNé   aD  `SVHN <http://ufldl.stanford.edu/housenumbers/>`_ Dataset.
Note: The SVHN dataset assigns the label `10` to the digit `0`. However, in this Dataset,
we assign the label `0` to the digit `0` to be compatible with PyTorch loss functions which
expect the class labels to be in the range `[0, C-1]`

.. warning::

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

Args:
    root (str or ``pathlib.Path``): Root directory of the dataset where the data is stored.
    split (string): One of {'train', 'test', 'extra'}.
        Accordingly dataset is selected. 'extra' is Extra training 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.

)z6http://ufldl.stanford.edu/housenumbers/train_32x32.matztrain_32x32.matÚ e26dedcc434d2e4c54c9b2d4a06d8373)z5http://ufldl.stanford.edu/housenumbers/test_32x32.matztest_32x32.matÚ eb5a983be6a315427106f1b164d9cef3)z6http://ufldl.stanford.edu/housenumbers/extra_32x32.matzextra_32x32.matÚ a93ce644f1a588dc4d68dda5feec44a7)ÚtrainÚtestÚextraNÚrootÚsplitÚ	transformÚtarget_transformÚdownloadÚreturnc                 ó:  >• [         TU ]  XUS9  [        US[        U R                  R                  5       5      5      U l        U R                  U   S   U l        U R                  U   S   U l        U R                  U   S   U l	        U(       a  U R                  5         U R                  5       (       d  [        S5      eSS KJn  UR                  [         R"                  R%                  U R&                  U R                  5      5      nUS   U l        US   R+                  [,        R.                  5      R1                  5       U l        [,        R4                  " U R2                  U R2                  S	:H  S5        [,        R6                  " U R(                  S
5      U l        g )N)r   r   r   r   r	   é   zHDataset not found or corrupted. You can use download=True to download itÚXÚyé
   )é   r   r   r	   )ÚsuperÚ__init__r   ÚtupleÚ
split_listÚkeysr   ÚurlÚfilenameÚfile_md5r   Ú_check_integrityÚRuntimeErrorÚscipy.ioÚioÚloadmatÚosÚpathÚjoinr   ÚdataÚastypeÚnpÚint64ÚsqueezeÚlabelsÚplaceÚ	transpose)	Úselfr   r   r   r   r   ÚsioÚ
loaded_matÚ	__class__s	           €ÚV/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torchvision/datasets/svhn.pyr$   ÚSVHN.__init__6   s1  ø€ ô 	‰Ñ˜ÐEUÐÑVÜ# E¨7´E¸$¿/¹/×:NÑ:NÓ:PÓ4QÓRˆŒ
Ø—?‘? 5Ñ)¨!Ñ,ˆŒØŸ™¨Ñ.¨qÑ1ˆŒØŸ™¨Ñ.¨qÑ1ˆŒæØ�M‰MŒOà×$Ñ$×&Ñ&ÜÐiÓjÐjõ 	ð —[‘[¤§¡§¡¨d¯i©i¸¿¹Ó!GÓHˆ
à˜s‘OˆŒ	ð
 ! ‘o×,Ñ,¬R¯X©XÓ6×>Ñ>Ó@ˆŒô
 	�Š�—‘˜dŸk™k¨RÑ/°Ô3Ü—L’L §¡¨LÓ9ˆ�	ó    Úindexc                 ó"  • U R                   U   [        U R                  U   5      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.
)r	   r   r   )	r3   Úintr8   r   Ú	fromarrayr5   r:   r   r   )r;   rB   ÚimgÚtargets       r?   Ú__getitem__ÚSVHN.__getitem__^   sy   € ð —i‘i Ñ&¬¨D¯K©K¸Ñ,>Ó(?ˆVô �oŠoœbŸlšl¨3°	Ó:Ó;ˆà�>‰>Ñ%Ø—.‘. Ó%ˆCà× Ñ Ñ,Ø×*Ñ*¨6Ó2ˆFàˆ{ÐrA   c                 ó,   • [        U R                  5      $ )N)Úlenr3   ©r;   s    r?   Ú__len__ÚSVHN.__len__t   s   € Ü�4—9‘9‹~ÐrA   c                 óº   • U R                   nU R                  U R                     S   n[        R                  R                  XR                  5      n[        X25      $ ©Nr   )r   r&   r   r0   r1   r2   r)   r
   )r;   r   Úmd5Úfpaths       r?   r+   ÚSVHN._check_integrityw   sC   € Ø�y‰yˆØ�o‰o˜dŸj™jÑ)¨!Ñ,ˆÜ—‘—‘˜T§=¡=Ó1ˆÜ˜uÓ*Ð*rA   c                 ó”   • U R                   U R                     S   n[        U R                  U R                  U R
                  U5        g rP   )r&   r   r   r(   r   r)   )r;   rQ   s     r?   r   ÚSVHN.download}   s3   € Ø�o‰o˜dŸj™jÑ)¨!Ñ,ˆÜ�T—X‘X˜tŸy™y¨$¯-©-¸Õ=rA   c                 ó:   • SR                   " S0 U R                  D6$ )NzSplit: {split}© )ÚformatÚ__dict__rL   s    r?   Ú
extra_reprÚSVHN.extra_repr�   s   € Ø×&Ò&Ñ7¨¯©Ñ7Ð7rA   )r3   r*   r)   r8   r   r(   )r   NNF)r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r&   r   Ústrr   r   r   Úboolr$   rD   r%   r   rH   rM   r+   r   rZ   Ú__static_attributes__Ú__classcell__)r>   s   @r?   r   r      sÍ   ø† ñò0
ò

ò

ñ€Jð* Ø(,Ø/3Øñ&:à�C˜�IÑð&:ð ð&:ð ˜HÑ%ð	&:ð
 # 8Ñ,ð&:ð ð&:ð 
÷&:ð &:ðP ð ¨¨s°C¨x©ô ð,˜ô ð+ $ô +ô>ð8˜C÷ 8ò 8rA   r   )Úos.pathr0   Úpathlibr   Útypingr   r   r   r   Únumpyr5   ÚPILr   Úutilsr
   r   r   Úvisionr   r   rW   rA   r?   Ú<module>rl      s.   ðÛ Ý ß 1Ó 1ã Ý ç @Ñ @Ý !ôv8ˆ=õ v8rA   