+
     °³j¹2  ã                   óÞ   € ^ RI t ^ RIt ^ RIHt ^ RIHtHtHtHtH	t	 ^ RI
Ht ^RIHt R R ltR R	 ltR
 R ltRR R llt ! R R]4      tRtR R ltR R ltR R lt ! R R]4      tR# )é    N)ÚPath)ÚAnyÚCallableÚcastÚOptionalÚUnion)ÚImage)ÚVisionDatasetc                óx   € V ^8„  d   QhR\         R\        \         \        \         R3,          3,          R\        /# )é   ÚfilenameÚ
extensions.Úreturn)Ústrr   ÚtupleÚbool)Úformats   "Ú\/home/luca/screen-checking/.venv/lib/python3.14/site-packages/torchvision/datasets/folder.pyÚ__annotate__r      s:   € ÷ 
gñ 
g¬ð 
g¼%ÄÄUÌ3ÐPSÈ8Å_Ð@TÕ:Uð 
gÔZ^ñ 
gó    c                óŠ   € V P                  4       P                  \        V\        4      '       d   V4      # \	        V4      4      # )zèChecks if a file is an allowed extension.

Args:
    filename (string): path to a file
    extensions (tuple of strings): extensions to consider (lowercase)

Returns:
    bool: True if the filename ends with one of given extensions
)ÚlowerÚendswithÚ
isinstancer   r   )r   r   s   &&r   Úhas_file_allowed_extensionr      s7   € ð �>‰>Ó×$Ñ$´:¸jÌ#×3NÒ3N ZÓfÐfÔTYÐZdÓTeÓfÐfr   c                ó0   € V ^8„  d   QhR\         R\        /# )r   r   r   ©r   r   )r   s   "r   r   r      s   € ÷ 	@ñ 	@œCð 	@¤Dñ 	@r   c                ó"   € \        V \        4      # )z¨Checks if a file is an allowed image extension.

Args:
    filename (string): path to a file

Returns:
    bool: True if the filename ends with a known image extension
)r   ÚIMG_EXTENSIONS)r   s   &r   Úis_image_filer       s   € ô & h´Ó?Ð?r   c                ó¬   € V ^8„  d   QhR\         \        \        3,          R\        \        \        ,          \
        \        \        3,          3,          /# ©r   Ú	directoryr   ©r   r   r   r   ÚlistÚdictÚint)r   s   "r   r   r   $   s9   € ÷ 
!ñ 
!œE¤#¤t )Õ,ð 
!´´t¼CµyÄ$ÄsÌCÀxÅ.Ð7PÕ1Qñ 
!r   c                óÊ   € \        R \        P                  ! V 4       4       4      pV'       g   \        RV  R24      h\	        V4       UUu/ uF  w  r#W2bK	  	  pppW3# u uppi )zOFinds the class folders in a dataset.

See :class:`DatasetFolder` for details.
c              3   óh   "  € T F(  qP                  4       '       g   K  VP                  x € K*  	  R # 5i©N)Úis_dirÚname)Ú.0Úentrys   & r   Ú	<genexpr>Úfind_classes.<locals>.<genexpr>)   s   é € ÐUÑ-B EÇlÁlÇn”Z�U—Z–ZÓ-Bùs   ‚2ž2z"Couldn't find any class folder in Ú.)ÚsortedÚosÚscandirÚFileNotFoundErrorÚ	enumerate)r#   ÚclassesÚiÚcls_nameÚclass_to_idxs   &    r   Úfind_classesr;   $   sc   € ô
 ÑU¬R¯ZªZ¸	Ô-BÓUÓU€GßÜÐ"DÀYÀKÈqÐ QÓRÐRä3<¸WÔ3EÔFÑ3E¡K A�H’KÑ3E€LÑFØÐ Ð ùó Gs   ÁAc                ó~  € V ^8„  d   QhR\         \        \        3,          R\        \        \        \
        3,          ,          R\        \         \        \        \        R3,          3,          ,          R\        \        \        .\        3,          ,          R\        R\        \        \        \
        3,          ,          /# ©r   r#   r:   r   .Úis_valid_fileÚallow_emptyr   )
r   r   r   r   r&   r'   r   r   r   r%   )r   s   "r   r   r   1   sŽ   € ÷ 9ñ 9Ü”Sœ$�YÕð9äœ4¤¤S �>Õ*ð9ô œœs¤E¬#¨s¨(¥OÐ3Õ4Õ5ð9ô œH¤c U¬D [Õ1Õ2ð	9ô
 ð9ô 
Œ%””S��/Õñ9r   c                ó¬  a€ \         P                  P                  V 4      p Vf   \        V 4      w  rQMV'       g   \	        R4      hSRJ ;'       d    VRJ pSRJ;'       d    VRJpV'       g	   V'       d   \	        R4      hSe
   R V3R llp\        \        \        .\        3,          V4      p. p\        4       p	\        VP                  4       4       Fë  p
W,          p\         P                  P                  W
4      p\         P                  P                  V4      '       g   KQ  \        \         P                  ! VRR7      4       Fu  w  rÕp\        V4       F`  p\         P                  P                  Wß4      pV! V4      '       g   K2  VV3pVP                  V4       W©9  g   KO  V	P!                  V
4       Kb  	  Kw  	  Kí  	  \        VP                  4       4      V	,
          pV'       di   V'       ga   RR	P                  \        V4      4       R
2pSe4   TR\#        S\        4      '       d   SMR	P                  S4       2,          p\%        V4      hV# )zßGenerates a list of samples of a form (path_to_sample, class).

See :class:`DatasetFolder` for details.

Note: The class_to_idx parameter is here optional and will use the logic of the ``find_classes`` function
by default.
NzE'class_to_index' must have at least one entry to collect any samples.zMBoth extensions and is_valid_file cannot be None or not None at the same timec                ó0   € V ^8„  d   QhR\         R\        /# )r   Úxr   r   )r   s   "r   r   Ú"make_dataset.<locals>.__annotate__M   s   € ÷ 	=ñ 	=œSð 	=¤Tñ 	=r   c                 ó   <€ \        V S4      # r*   )r   )rB   r   s   &€r   r>   Ú#make_dataset.<locals>.is_valid_fileM   s   ø€ Ü-¨a°Ó<Ð<r   T)Úfollowlinksz$Found no valid file for the classes z, z. zSupported extensions are: )r3   ÚpathÚ
expanduserr;   Ú
ValueErrorr   r   r   r   Úsetr2   ÚkeysÚjoinÚisdirÚwalkÚappendÚaddr   r5   )r#   r:   r   r>   r?   Ú_Ú	both_noneÚboth_somethingÚ	instancesÚavailable_classesÚtarget_classÚclass_indexÚ
target_dirÚrootÚfnamesÚfnamerG   ÚitemÚempty_classesÚmsgs   &&f&&               r   Úmake_datasetr_   1   só  ø€ ô —‘×"Ñ" 9Ó-€IàÒÜ& yÓ1‰ˆˆ<ßÜÐ`ÓaÐaà˜dÐ"×<Ð< }¸Ð'<€IØ tÐ+×IÐI°ÀTÐ0I€Nß—NÜÐhÓiÐiàÒ÷	=ð 	=ô œ¤3 %¬ +Õ.°Ó>€Mà€IÜ›ÐÜ˜|×0Ñ0Ó2Ö3ˆØ"Õ0ˆÜ—W‘W—\‘\ )Ó:ˆ
Ü�w‰w�}‰}˜Z×(Ò(ÙÜ%¤b§g¢g¨jÀdÔ&KÖL‰OˆD�VÜ ž�Ü—w‘w—|‘| DÓ0�Ù  ×&Ô&Ø Ð,�DØ×$Ñ$ TÔ*à#Ö<Ø)×-Ñ-¨lÖ;ó (ó  Mñ 4ô ˜×)Ñ)Ó+Ó,Ð/@Õ@€MßŸ[Ø4°T·Y±Y¼vÀmÓ?TÓ5UÐ4VÐVXÐYˆØÒ!ØÐ/¼jÈÔUX×>YÒ>Y±
Ð_c×_hÑ_hÐisÓ_tÐ/uÐvÕvˆCÜ Ó$Ð$àÐr   c                   óœ   a a€ ] tR t^mt oRtRV3R lV 3R lllt]RV3R lR ll4       tV3R lR ltV3R lR	 lt	V3R
 lR lt
RtVtV ;t# )ÚDatasetFoldera0  A generic data loader.

This default directory structure can be customized by overriding the
:meth:`find_classes` method.

Args:
    root (str or ``pathlib.Path``): Root directory path.
    loader (callable): A function to load a sample given its path.
    extensions (tuple[string]): A list of allowed extensions.
        both extensions and is_valid_file should not be passed.
    transform (callable, optional): A function/transform that takes in
        a sample and returns a transformed version.
        E.g, ``transforms.RandomCrop`` for images.
    target_transform (callable, optional): A function/transform that takes
        in the target and transforms it.
    is_valid_file (callable, optional): A function that takes path of a file
        and check if the file is a valid file (used to check of corrupt files)
        both extensions and is_valid_file should not be passed.
    allow_empty(bool, optional): If True, empty folders are considered to be valid classes.
        An error is raised on empty folders if False (default).

 Attributes:
    classes (list): List of the class names sorted alphabetically.
    class_to_idx (dict): Dict with items (class_name, class_index).
    samples (list): List of (sample path, class_index) tuples
    targets (list): The class_index value for each image in the dataset
c                óâ   <€ V ^8„  d   QhRS[ S[S[3,          RS[S[.S[3,          RS[S[S[R3,          ,          RS[S[,          RS[S[,          RS[S[S[.S[3,          ,          RS[R	R
/# )r   rY   Úloaderr   .Ú	transformÚtarget_transformr>   r?   r   N)r   r   r   r   r   r   r   r   )r   Ú__classdict__s   "€r   r   ÚDatasetFolder.__annotate__Š   s–   ø€ ÷ /ñ /á‘C™�IÕð/ñ ™#˜¡˜Õ$ð/ñ ™U¡3¨ 8�_Õ-ð	/ñ
 ™HÕ%ð/ñ #¡8Õ,ð/ñ  ¡©#¨±¨Õ 5Õ6ð/ñ ð/ð 
ñ/r   c                ó$  <€ \         SV `  WVR 7       V P                  V P                  4      w  r‰V P	                  V P                  V	VVVR7      p
W n        W0n        W€n        W�n        W n	        V
 Uu. uF  q»^,          NK  	  upV n
        R# u upi ))rd   re   )r:   r   r>   r?   N)ÚsuperÚ__init__r;   rY   r_   rc   r   r7   r:   ÚsamplesÚtargets)ÚselfrY   rc   r   rd   re   r>   r?   r7   r:   rk   ÚsÚ	__class__s   &&&&&&&&    €r   rj   ÚDatasetFolder.__init__Š   s�   ø€ ô 	‰Ñ˜ÐEUÐÔVØ $× 1Ñ 1°$·)±)Ó <ÑˆØ×#Ñ#Ø�I‰IØ%Ø!Ø'Ø#ð $ó 
ˆð ŒØ$ŒàŒØ(ÔØŒÙ&-Ó.¡g ˜!Ÿ˜¡gÑ.ˆŽùÒ.s   Á2Bc                óÜ   <€ V ^8„  d   QhRS[ S[S[3,          RS[S[S[3,          RS[S[S[R3,          ,          RS[S[S[.S[3,          ,          RS[RS[	S[S[S[3,          ,          /# r=   )
r   r   r   r&   r'   r   r   r   r   r%   )r   rf   s   "€r   r   rg   §   s€   ø€ ÷ &
ñ &
Ù™™d˜Õ#ð&
á™3¡˜8•nð&
ñ ™U¡3¨ 8�_Õ-ð&
ñ  ¡©#¨±¨Õ 5Õ6ð	&
ñ
 ð&
ñ 
‰e‘C™�H�oÕ	ñ&
r   c                ó<   € Vf   \        R4      h\        WW#VR7      # )a‚  Generates a list of samples of a form (path_to_sample, class).

This can be overridden to e.g. read files from a compressed zip file instead of from the disk.

Args:
    directory (str): root dataset directory, corresponding to ``self.root``.
    class_to_idx (Dict[str, int]): Dictionary mapping class name to class index.
    extensions (optional): A list of allowed extensions.
        Either extensions or is_valid_file should be passed. Defaults to None.
    is_valid_file (optional): A function that takes path of a file
        and checks if the file is a valid file
        (used to check of corrupt files) both extensions and
        is_valid_file should not be passed. Defaults to None.
    allow_empty(bool, optional): If True, empty folders are considered to be valid classes.
        An error is raised on empty folders if False (default).

Raises:
    ValueError: In case ``class_to_idx`` is empty.
    ValueError: In case ``extensions`` and ``is_valid_file`` are None or both are not None.
    FileNotFoundError: In case no valid file was found for any class.

Returns:
    List[Tuple[str, int]]: samples of a form (path_to_sample, class)
z*The class_to_idx parameter cannot be None.)r   r>   r?   )rI   r_   )r#   r:   r   r>   r?   s   &&&&&r   r_   ÚDatasetFolder.make_dataset¦   s.   € ð@ Òô ÐIÓJÐJÜØ°
Ðepô
ð 	
r   c                óx   <€ V ^8„  d   QhRS[ S[S[3,          RS[S[S[,          S[S[S[3,          3,          /# r"   r$   )r   rf   s   "€r   r   rg   Ï   s=   ø€ ÷ 'ñ '¡e©C±¨IÕ&6ð '¹5ÁÁcÅÉDÑQTÑVYÐQYÍNÐAZÕ;[ñ 'r   c                ó   € \        V4      # )uÔ  Find the class folders in a dataset structured as follows::

    directory/
    â”œâ”€â”€ class_x
    â”‚   â”œâ”€â”€ xxx.ext
    â”‚   â”œâ”€â”€ xxy.ext
    â”‚   â””â”€â”€ ...
    â”‚       â””â”€â”€ xxz.ext
    â””â”€â”€ class_y
        â”œâ”€â”€ 123.ext
        â”œâ”€â”€ nsdf3.ext
        â””â”€â”€ ...
        â””â”€â”€ asd932_.ext

This method can be overridden to only consider
a subset of classes, or to adapt to a different dataset directory structure.

Args:
    directory(str): Root directory path, corresponding to ``self.root``

Raises:
    FileNotFoundError: If ``dir`` has no class folders.

Returns:
    (Tuple[List[str], Dict[str, int]]): List of all classes and dictionary mapping each class to an index.
)r;   )rm   r#   s   &&r   r;   ÚDatasetFolder.find_classesÏ   s   € ô6 ˜IÓ&Ð&r   c                ó<   <€ V ^8„  d   QhRS[ RS[S[S[3,          /# )r   Úindexr   )r'   r   r   )r   rf   s   "€r   r   rg   ì   s#   ø€ ÷ ñ ¡ð ©©s±C¨x­ñ r   c                óÐ   € V P                   V,          w  r#V P                  V4      pV P                  e   V P                  V4      pV P                  e   V P                  V4      pWC3# )zu
Args:
    index (int): Index

Returns:
    tuple: (sample, target) where target is class_index of the target class.
)rk   rc   rd   re   )rm   rx   rG   ÚtargetÚsamples   &&   r   Ú__getitem__ÚDatasetFolder.__getitem__ì   s^   € ð —|‘| EÕ*‰ˆØ—‘˜TÓ"ˆØ�>‰>Ò%Ø—^‘^ FÓ+ˆFØ× Ñ Ò,Ø×*Ñ*¨6Ó2ˆFàˆ~Ðr   c                ó    <€ V ^8„  d   QhRS[ /# )r   r   )r'   )r   rf   s   "€r   r   rg   ý   s   ø€ ÷ !ñ !™ñ !r   c                ó,   € \        V P                  4      # r*   )Úlenrk   )rm   s   &r   Ú__len__ÚDatasetFolder.__len__ý   s   € Ü�4—<‘<Ó Ð r   )r:   r7   r   rc   rk   rl   )NNNNF)NNF)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rj   Ústaticmethodr_   r;   r|   r�   Ú__static_attributes__Ú__classdictcell__Ú__classcell__©ro   rf   s   @@r   ra   ra   m   sQ   ù‡ € ñ÷8/õ /ð8 ÷&
ñ &
ó ð&
÷P'ð '÷:ð ÷"!÷ !ð !r   ra   c                óf   € V ^8„  d   QhR\         \        \        3,          R\        P                  /# ©r   rG   r   )r   r   r   r	   )r   s   "r   r   r     s'   € ÷ "ñ "”Uœ3¤˜9Õ%ð "¬%¯+©+ñ "r   c                 ó¶   € \        V R 4      ;_uu_ 4       p\        P                   ! V4      pVP                  R4      uuRRR4       #   + '       g   i     R# ; i)ÚrbÚRGBN)Úopenr	   Úconvert)rG   ÚfÚimgs   &  r   Ú
pil_loaderr–     s9   € ä	ˆd�D×	Ô	˜QÜ�jŠj˜‹mˆØ�{‰{˜5Ó!÷ 
×	×	Ó	ús   •'AÁA	c                óR   € V ^8„  d   QhR\         \        \        3,          R\        /# rŽ   ©r   r   r   r   )r   s   "r   r   r     s#   € ÷  ñ  œ%¤¤T 	Õ*ð  ¬sñ  r   c                 óf   € ^ RI p VP                  V 4      #   \         d    \        T 4      u # i ; i)r   N)Úaccimager	   ÚOSErrorr–   )rG   rš   s   & r   Úaccimage_loaderrœ     s3   € Ûð Ø�~‰~˜dÓ#Ð#øÜô  ä˜$ÓÒð ús   † —0¯0c                óR   € V ^8„  d   QhR\         \        \        3,          R\        /# rŽ   r˜   )r   s   "r   r   r     s#   € ÷  ñ  œœs¤D˜yÕ)ð  ¬cñ  r   c                 óR   € ^ RI Hp V! 4       R8X  d   \        V 4      # \        V 4      # )r   )Úget_image_backendrš   )ÚtorchvisionrŸ   rœ   r–   )rG   rŸ   s   & r   Údefault_loaderr¡     s&   € Ý-áÓ˜jÔ(Ü˜tÓ$Ð$ä˜$ÓÐr   c                   óP   a a€ ] tR tRt oRtRR]RR3V3R lV 3R llltRtVtV ;t	# )ÚImageFolderi  aB  A generic data loader where the images are arranged in this way by default: ::

    root/dog/xxx.png
    root/dog/xxy.png
    root/dog/[...]/xxz.png

    root/cat/123.png
    root/cat/nsdf3.png
    root/cat/[...]/asd932_.png

This class inherits from :class:`~torchvision.datasets.DatasetFolder` so
the same methods can be overridden to customize the dataset.

Args:
    root (str or ``pathlib.Path``): Root directory path.
    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.
    loader (callable, optional): A function to load an image given its path.
    is_valid_file (callable, optional): A function that takes path of an Image file
        and check if the file is a valid file (used to check of corrupt files)
    allow_empty(bool, optional): If True, empty folders are considered to be valid classes.
        An error is raised on empty folders if False (default).

 Attributes:
    classes (list): List of the class names sorted alphabetically.
    class_to_idx (dict): Dict with items (class_name, class_index).
    imgs (list): List of (image path, class_index) tuples
NFc                ó´   <€ V ^8„  d   QhRS[ S[S[3,          RS[S[,          RS[S[,          RS[S[.S[3,          RS[S[S[.S[3,          ,          RS[/# )r   rY   rd   re   rc   r>   r?   )r   r   r   r   r   r   r   )r   rf   s   "€r   r   ÚImageFolder.__annotate__?  su   ø€ ÷ !ñ !á‘C™�IÕð!ñ ™HÕ%ð!ñ #¡8Õ,ð	!ñ
 ™#˜¡˜Õ$ð!ñ  ¡©#¨±¨Õ 5Õ6ð!ñ ñ!r   c           
     ój   <€ \         ST `  TTVf   \        MR VVVVR7       V P                  V n        R # )N)rd   re   r>   r?   )ri   rj   r   rk   Úimgs)rm   rY   rd   re   rc   r>   r?   ro   s   &&&&&&&€r   rj   ÚImageFolder.__init__?  s@   ø€ ô 	‰ÑØØØ+Ò3�N¸ØØ-Ø'Ø#ð 	ô 	
ð —L‘LˆŽ	r   )r§   )
rƒ   r„   r…   r†   r‡   r¡   rj   r‰   rŠ   r‹   rŒ   s   @@r   r£   r£     s+   ù‡ € ñðD )-Ø/3Ø'5Ø9=Ø!÷!÷ !õ !r   r£   )NNNF)	z.jpgz.jpegz.pngz.ppmz.bmpz.pgmz.tifz.tiffz.webp)r3   Úos.pathÚpathlibr   Útypingr   r   r   r   r   ÚPILr	   Úvisionr
   r   r    r;   r_   ra   r   r–   rœ   r¡   r£   © r   r   Ú<module>r¯      sc   ðÛ 	Û Ý ß 7Õ 7å å !õ
gõ	@õ
!÷9ôxQ!�Mô Q!ðh ]€õ"õ õ ô2!�-ö 2!r   