ó
    Eñiž  ã                   óf   • 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	J
r
Jr  SSKJr   " S S\5      rg)	é    N)ÚAnyÚCallableÚOptionalÚUnion)ÚImageé   )Ú_decompressÚdownload_file_from_google_driveÚverify_str_arg)ÚVisionDatasetc                   óÚ   ^ • \ rS rSrSrSSS.SSS.SS	S.S
.r    SS\\\R                  4   S\S\
\   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S jrSrU =r$ )ÚPCAMé
   a€  `PCAM Dataset   <https://github.com/basveeling/pcam>`_.

The PatchCamelyon dataset is a binary classification dataset with 327,680
color images (96px x 96px), extracted from histopathologic scans of lymph node
sections. Each image is annotated with a binary label indicating presence of
metastatic tissue.

This dataset requires the ``h5py`` package which you can install with ``pip install h5py``.

Args:
     root (str or ``pathlib.Path``): Root directory of the dataset.
     split (string, optional): The dataset split, supports ``"train"`` (default), ``"test"`` or ``"val"``.
     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 into ``root/pcam``. If
         dataset is already downloaded, it is not downloaded again.

         .. warning::

            To download the dataset `gdown <https://github.com/wkentaro/gdown>`_ is required.
)z&camelyonpatch_level_2_split_train_x.h5z!1Ka0XfEMiwgCYPdTI-vv6eUElOBnKFKQ2Ú 1571f514728f59376b705fc836ff4b63)z&camelyonpatch_level_2_split_train_y.h5z!1269yhu3pZDP8UYFQs-NYs3FPwuK-nGSGÚ 35c2d7259d906cfc8143347bb8e05be7)ÚimagesÚtargets)z%camelyonpatch_level_2_split_test_x.h5Ú!1qV65ZqZvWzuIVthK8eVDhIwrbnsJdbg_Ú d8c2d60d490dbd479f8199bdfa0cf6ec)z%camelyonpatch_level_2_split_test_y.h5Ú!17BHrSrwWKjYsOgTMmoqrIjDy6Fa2o_gPÚ 60a7035772fbdb7f34eb86d4420cf66a)z&camelyonpatch_level_2_split_valid_x.h5z!1hgshYGWK8V-eGRy8LToWJJgDU_rXWVJ3Ú d5b63470df7cfa627aeec8b9dc0c066e)z&camelyonpatch_level_2_split_valid_y.h5z!1bH8ZRbhSVAhScTS0p9-ZzGnX91cHT3uOÚ 2b85f58b927af9964a4c15b8f7e8f179©ÚtrainÚtestÚvalÚrootÚsplitÚ	transformÚtarget_transformÚdownloadc                 óL  >•  SS K nX`l         [        USS5      U l        [
        TU ]  XUS9  [        R                  " U R                  5      S-  U l
        U(       a  U R                  5         U R                  5       (       d  [        S5      eg ! [         a    [        S5      ef = f)Nr   zYh5py is not found. This dataset needs to have h5py installed: please run pip install h5pyr   r   )r    r!   Úpcamz;Dataset not found. You can use download=True to download it)Úh5pyÚImportErrorÚRuntimeErrorr   Ú_splitÚsuperÚ__init__ÚpathlibÚPathr   Ú_base_folderÚ	_downloadÚ_check_exists)Úselfr   r   r    r!   r"   r%   Ú	__class__s          €ÚV/home/mande/repo/quber/.venv/lib/python3.13/site-packages/torchvision/datasets/pcam.pyr*   ÚPCAM.__init__I   sž   ø€ ð	ÛàŒIô % U¨GÐ5MÓNˆŒä‰Ñ˜ÐEUÐÑVÜ#ŸLšL¨¯©Ó3°fÑ<ˆÔæØ�N‰NÔà×!Ñ!×#Ñ#ÜÐ\Ó]Ð]ð $øô ó 	ÜØkóð ð	ús   ƒ
B ÂB#Úreturnc                 óê   • U R                   U R                     S   S   nU R                  R                  U R                  U-  5       nUS   R
                  S   sS S S 5        $ ! , (       d  f       g = f)Nr   r   Úx)Ú_FILESr(   r%   ÚFiler-   Úshape)r0   Úimages_fileÚimages_datas      r2   Ú__len__ÚPCAM.__len__e   sZ   € Ø—k‘k $§+¡+Ñ.¨xÑ8¸Ñ;ˆØ�Y‰Y�^‰^˜D×-Ñ-°Ñ;Ô<ÀØ˜sÑ#×)Ñ)¨!Ñ,÷ =×<×<ús   ÁA$Á$
A2Úidxc                 ó–  • U R                   U R                     S   S   nU R                  R                  U R                  U-  5       n[
        R                  " US   U   5      R                  S5      nS S S 5        U R                   U R                     S   S   nU R                  R                  U R                  U-  5       n[        US   USSS4   5      nS S S 5        U R                  (       a  U R                  W5      nU R                  (       a  U R                  W5      nWW4$ ! , (       d  f       N»= f! , (       d  f       Ng= f)Nr   r   r6   ÚRGBr   Úy)r7   r(   r%   r8   r-   r   Ú	fromarrayÚconvertÚintr    r!   )r0   r>   r:   r;   ÚimageÚtargets_fileÚtargets_dataÚtargets           r2   Ú__getitem__ÚPCAM.__getitem__j   s  € Ø—k‘k $§+¡+Ñ.¨xÑ8¸Ñ;ˆØ�Y‰Y�^‰^˜D×-Ñ-°Ñ;Ô<ÀÜ—O’O K°Ñ$4°SÑ$9Ó:×BÑBÀ5ÓIˆE÷ =ð —{‘{ 4§;¡;Ñ/°	Ñ:¸1Ñ=ˆØ�Y‰Y�^‰^˜D×-Ñ-°Ñ<Ô=ÀÜ˜ cÑ*¨3°°1°a¨<Ñ8Ó9ˆF÷ >ð �>�>Ø—N‘N 5Ó)ˆEØ× × Ø×*Ñ*¨6Ó2ˆFà�fˆ}Ð÷ =Õ<ú÷ >Õ=ús   Á,D)ÃD:Ä)
D7Ä:
Ec                 ó¬   ^ • T R                   T R                     S   S   nT R                   T R                     S   S   n[        U 4S jX4 5       5      $ )Nr   r   r   c              3   óv   >#   • U  H.  nTR                   R                  U5      R                  5       v •  M0     g 7f)N)r-   ÚjoinpathÚexists)Ú.0Úh5_filer0   s     €r2   Ú	<genexpr>Ú%PCAM._check_exists.<locals>.<genexpr>}   s0   øé € ÐkÒOjÀG�4×$Ñ$×-Ñ-¨gÓ6×=Ñ=×?Ð?ÒOjùs   ƒ69)r7   r(   Úall)r0   r:   rF   s   `  r2   r/   ÚPCAM._check_existsz   sP   ø€ Ø—k‘k $§+¡+Ñ.¨xÑ8¸Ñ;ˆØ—{‘{ 4§;¡;Ñ/°	Ñ:¸1Ñ=ˆÜÔkÐP[ÑOjÓkÓkÐkó    c                 ó  • U R                  5       (       a  g U R                  U R                     R                  5        HJ  u  pnUS-   n[	        U[        U R                  5      XCS9  [        [        U R                  U-  5      5        ML     g )Nz.gz)ÚfilenameÚmd5)r/   r7   r(   Úvaluesr
   Ústrr-   r	   )r0   Ú	file_nameÚfile_idrX   Úarchive_names        r2   r.   ÚPCAM._download   st   € Ø×Ñ×ÑØà'+§{¡{°4·;±;Ñ'?×'FÑ'FÖ'HÑ#ˆI Ø$ uÑ,ˆLÜ+¨G´S¸×9JÑ9JÓ5KÐVbÒlÜœ˜D×-Ñ-°Ñ<Ó=Ö>ò (IrU   )r-   r(   r%   )r   NNF)r4   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r7   r   rZ   r+   r,   r   r   Úboolr*   rD   r<   Útupler   rI   r/   r.   Ú__static_attributes__Ú__classcell__)r1   s   @r2   r   r   
   sã   ø† ñð2ð
ñ
ðð
ñ
ðð
ñ
ñ3%€FðT Ø(,Ø/3Øñ^à�C˜Ÿ™Ð%Ñ&ð^ð ð^ð ˜HÑ%ð	^ð
 # 8Ñ,ð^ð ÷^ð ^ð8-˜ô -ð
˜sð  u¨S°#¨X¡ô ð l˜tô l÷
?ò ?rU   r   )r+   Útypingr   r   r   r   ÚPILr   Úutilsr	   r
   r   Úvisionr   r   © rU   r2   Ú<module>rm      s(   ðÛ ß 1Ó 1å ç OÑ OÝ !ô|?ˆ=õ |?rU   