ó
    Eñiµ  ã                   ór   • 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  SSKJr   " S	 S
\5      rg)é    N)ÚPath)ÚAnyÚCallableÚOptionalÚUnioné   )Ú_Image_fromarrayé   )Údownload_url)ÚVisionDatasetc                   ó¦   ^ • \ rS rSrSr/ 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rU =r$ )ÚUSPSé   aê  `USPS <https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/multiclass.html#usps>`_ Dataset.
The data-format is : [label [index:value ]*256 \n] * num_lines, where ``label`` lies in ``[1, 10]``.
The value for each pixel lies in ``[-1, 1]``. Here we transform the ``label`` into ``[0, 9]``
and make pixel values in ``[0, 255]``.

Args:
    root (str or ``pathlib.Path``): Root directory of dataset to store``USPS`` data files.
    train (bool, optional): If True, creates dataset from ``usps.bz2``,
        otherwise from ``usps.t.bz2``.
    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.

)zKhttps://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/multiclass/usps.bz2zusps.bz2Ú ec16c51db3855ca6c91edd34d0e9b197)zMhttps://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/multiclass/usps.t.bz2z
usps.t.bz2Ú 8ea070ee2aca1ac39742fdd1ef5ed118)ÚtrainÚtestNÚrootr   Ú	transformÚtarget_transformÚdownloadÚreturnc                 ó¬  >• [         TU ]  XUS9  U(       a  SOSnU R                  U   u  pxn	[        R                  R                  U R                  U5      n
U(       a8  [        R                  R                  U
5      (       d  [        XpR                  X‰S9  SS K	nUR                  U
5       nUR                  5        Vs/ s H   oÝR                  5       R                  5       PM"     nnU VVs/ s H*  oÿSS   Vs/ s H  nUR                  S5      S   PM     snPM,     nnn[        R                  " U[        R                   S	9R#                  S
5      nUS-   S-  S-  R%                  [        R&                  S	9nU Vs/ s H  n[)        US   5      S-
  PM     nnS S S 5        WU l        WU l        g s  snf s  snf s  snnf s  snf ! , (       d  f       N2= f)N)r   r   r   r   )Úmd5r   r
   Ú:éÿÿÿÿ)Údtype)r   é   r   r   éÿ   )ÚsuperÚ__init__Ú
split_listÚosÚpathÚjoinr   Úexistsr   Úbz2ÚopenÚ	readlinesÚdecodeÚsplitÚnpÚasarrayÚfloat32ÚreshapeÚastypeÚuint8ÚintÚdataÚtargets)Úselfr   r   r   r   r   r+   ÚurlÚfilenameÚchecksumÚ	full_pathr'   ÚfpÚlineÚraw_datar3   ÚxÚtmp_listÚimgsÚdr4   Ú	__class__s                        €ÚV/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torchvision/datasets/usps.pyr!   ÚUSPS.__init__-   sm  ø€ ô 	‰Ñ˜ÐEUÐÑVÞ ‘ fˆØ"&§/¡/°%Ñ"8Ñˆ�xÜ—G‘G—L‘L §¡¨HÓ5ˆ	æœBŸG™GŸN™N¨9×5Ñ5Ü˜Ÿi™i¨Ò@ãà�X‰X�iÔ  BØ:<¿,¹,¼.ÓIº.°$Ÿ™›×+Ñ+Ö-¹.ˆHÐIÙIQÔRÊÀ¸¸±8Ó<²8¨a˜Ÿ™ › bÔ)±8Ô<ÉˆHÑRÜ—:’:˜h¬b¯j©jÑ9×AÑAÀ,ÓOˆDØ˜A‘X ‘N SÑ(×0Ñ0´r·x±xÐ0Ð@ˆDÙ.6Ó7ªh¨”s˜1˜Q™4“y 1”}©hˆGÐ7÷ !ð ˆŒ	Øˆ�ùò JùÚ<ùÓRùò 8÷ !Õ úsO   Â+GÂ>'F0Ã%GÃ,F:Ã8F5ÄF:ÄAGÅ<G ÆGÆ0GÆ5F:Æ:GÇ
GÚindexc                 óà   • U R                   U   [        U R                  U   5      p2[        USS9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.
ÚL)Úmode)r3   r2   r4   r	   r   r   )r5   rD   ÚimgÚtargets       rB   Ú__getitem__ÚUSPS.__getitem__I   sl   € ð —i‘i Ñ&¬¨D¯L©L¸Ñ,?Ó(@ˆVô ˜s¨Ñ-ˆà�>‰>Ñ%Ø—.‘. Ó%ˆCà× Ñ Ñ,Ø×*Ñ*¨6Ó2ˆFàˆ{Ðó    c                 ó,   • [        U R                  5      $ )N)Úlenr3   )r5   s    rB   Ú__len__ÚUSPS.__len___   s   € Ü�4—9‘9‹~ÐrL   )r3   r4   )TNNF)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r"   r   Ústrr   Úboolr   r   r!   r2   Útupler   rJ   rO   Ú__static_attributes__Ú__classcell__)rA   s   @rB   r   r      sª   ø† ñò(
ò

ñ€Jð  Ø(,Ø/3Øñà�C˜�IÑðð ðð ˜HÑ%ð	ð
 # 8Ñ,ðð ðð 
÷ð ð8 ð ¨¨s°C¨x©ô ð,˜÷ ò rL   r   )r#   Úpathlibr   Útypingr   r   r   r   Únumpyr,   Úutilsr	   r   Úvisionr   r   © rL   rB   Ú<module>ra      s+   ðÛ 	Ý ß 1Ó 1ã å $Ý Ý !ôTˆ=õ TrL   