Ë
    DêñiÕ  ã                   óz   — d dl Zd dlmZ d dlmZmZmZmZ d dl	Z
d dlmZ ddlmZmZmZ ddlmZ  G d„ d	e«      Zy)
é    N)ÚPath)ÚAnyÚCallableÚOptionalÚUnion)ÚImageé   )Úcheck_integrityÚdownload_urlÚverify_str_arg)ÚVisionDatasetc                   óº   ‡ — e Zd ZdZg d¢g d¢g d¢dœZ	 	 	 	 ddeeef   ded	ee	   d
ee	   de
ddfˆ fd„Zdedeeef   fd„Zdefd„Zde
fd„Zdd„Zdefd„Zˆ xZS )ÚSVHNaˆ  `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         ‰| �  |||¬«       t        |dt        | j                  j                  «       «      «      | _        | j                  |   d   | _        | j                  |   d   | _        | j                  |   d   | _	        |r| j                  «        | j                  «       st        d«      ‚dd lm} |j                  t         j"                  j%                  | j&                  | j                  «      «      }|d   | _        |d   j+                  t,        j.                  «      j1                  «       | _        t-        j4                  | j2                  | j2                  d	k(  d«       t-        j6                  | j(                  d
«      | _        y )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	           €ú[/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/torchvision/datasets/svhn.pyr#   zSVHN.__init__6   s0  ø€ ô 	‰Ñ˜¨Ð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                 ó  — | j                   |   t        | j                  |   «      }}t        j                  t        j                  |d«      «      }| j                  �| j                  |«      }| j                  �| j                  |«      }||fS )z–
        Args:
            index (int): Index

        Returns:
            tuple: (image, target) where target is index of the target class.
        )r	   r   r   )	r2   Úintr7   r   Ú	fromarrayr4   r9   r   r   )r:   r@   ÚimgÚtargets       r>   Ú__getitem__zSVHN.__getitem__^   s}   € ð —i‘i Ñ&¬¨D¯K©K¸Ñ,>Ó(?ˆVˆô �o‰oœbŸl™l¨3°	Ó:Ó;ˆà�>‰>Ð%Ø—.‘. Ó%ˆCà× Ñ Ð,Ø×*Ñ*¨6Ó2ˆFà�Fˆ{Ðr?   c                 ó,   — t        | j                  «      S )N)Úlenr2   ©r:   s    r>   Ú__len__zSVHN.__len__t   s   € Ü�4—9‘9‹~Ðr?   c                 ó¾   — | j                   }| j                  | j                     d   }t        j                  j                  || j                  «      }t        ||«      S ©Nr   )r   r%   r   r/   r0   r1   r(   r
   )r:   r   Úmd5Úfpaths       r>   r*   zSVHN._check_integrityw   sG   € Ø�y‰yˆØ�o‰o˜dŸj™jÑ)¨!Ñ,ˆÜ—‘—‘˜T 4§=¡=Ó1ˆÜ˜u cÓ*Ð*r?   c                 ó”   — | j                   | j                     d   }t        | j                  | j                  | j
                  |«       y rL   )r%   r   r   r'   r   r(   )r:   rM   s     r>   r   zSVHN.download}   s3   € Ø�o‰o˜dŸj™jÑ)¨!Ñ,ˆÜ�T—X‘X˜tŸy™y¨$¯-©-¸Õ=r?   c                 ó:   —  dj                   di | j                  ¤ŽS )NzSplit: {split}© )ÚformatÚ__dict__rI   s    r>   Ú
extra_reprzSVHN.extra_repr�   s   € Ø&Ð×&Ñ&Ñ7¨¯©Ñ7Ð7r?   )r   NNF)r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r%   r   Ústrr   r   r   Úboolr#   rB   r$   r   rF   rJ   r*   r   rT   Ú__classcell__)r=   s   @r>   r   r      sÃ   ø„ ñò0
ò

ò

ñ€Jð* Ø(,Ø/3Øñ&:à�C˜�IÑð&:ð ð&:ð ˜HÑ%ð	&:ð
 # 8Ñ,ð&:ð ð&:ð 
õ&:ðP ð ¨¨s°C¨x©ó ð,˜ó ð+ $ó +ó>ð8˜C÷ 8r?   r   )Úos.pathr/   Úpathlibr   Útypingr   r   r   r   Únumpyr4   ÚPILr   Úutilsr
   r   r   Úvisionr   r   rQ   r?   r>   ú<module>rc      s.   ðÛ Ý ß 1Ó 1ã Ý ç @Ñ @Ý !ôv8ˆ=õ v8r?   