Ë
    Dêñi†  ã                   óz   — d dl mZ d dlmZ d dlmZmZmZmZ d dl	m
Z
 ddlmZmZmZmZ ddlmZ  G d„ d	e«      Zy
)é    )Újoin)ÚPath)ÚAnyÚCallableÚOptionalÚUnion)ÚImageé   )Úcheck_integrityÚdownload_and_extract_archiveÚlist_dirÚ
list_files)ÚVisionDatasetc                   óÖ   ‡ — e Zd ZdZdZdZdddœZ	 	 	 	 	 ddeee	f   d	e
d
ee   dee   de
deeeee	f   gef      ddfˆ fd„Zdefd„Zdedeeef   fd„Zde
fd„Zdd„Zdefd„Zˆ xZS )ÚOmniglota‚  `Omniglot <https://github.com/brendenlake/omniglot>`_ Dataset.

    Args:
        root (str or ``pathlib.Path``): Root directory of dataset where directory
            ``omniglot-py`` exists.
        background (bool, optional): If True, creates dataset from the "background" set, otherwise
            creates from the "evaluation" set. This terminology is defined by the authors.
        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 zip files from the internet and
            puts it in root directory. If the zip files are already downloaded, they are not
            downloaded again.
        loader (callable, optional): A function to load an image given its path.
            By default, it uses PIL as its image loader, but users could also pass in
            ``torchvision.io.decode_image`` for decoding image data into tensors directly.
    zomniglot-pyzDhttps://raw.githubusercontent.com/brendenlake/omniglot/master/pythonÚ 68d2efa1b9178cc56df9314c21c6e718Ú 6b91aef0f799c5bb55b94e3f2daec811)Úimages_backgroundÚimages_evaluationNÚrootÚ
backgroundÚ	transformÚtarget_transformÚdownloadÚloaderÚreturnc                 ó   •‡ — t         ‰
‰ �  t        |‰ j                  «      ||¬«       |‰ _        |r‰ j                  «        ‰ j                  «       st        d«      ‚t        ‰ j                  ‰ j                  «       «      ‰ _
        t        ‰ j                  «      ‰ _        t        ˆ fd„‰ j                  D «       g «      ‰ _        t        ‰ j                  «      D ���	cg c]5  \  }}t!        t        ‰ j                  |«      d«      D �	cg c]  }	|	|f‘Œ c}	‘Œ7 c}	}}‰ _        t        ‰ j"                  g «      ‰ _        |‰ _        y c c}	w c c}	}}w )N)r   r   zHDataset not found or corrupted. You can use download=True to download itc              3   ó–   •K  — | ];  }t        t        ‰j                  |«      «      D �cg c]  }t        ||«      ‘Œ c}–— Œ= y c c}w ­w©N)r   r   Útarget_folder)Ú.0ÚaÚcÚselfs      €ú_/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/torchvision/datasets/omniglot.pyú	<genexpr>z$Omniglot.__init__.<locals>.<genexpr>;   s7   øè ø€ ÒbÈQ¤(¬4°×0BÑ0BÀAÓ+FÓ"GÖH˜QŒd�1�a�jÖHÑbùÒHùs   ƒ&A	©A¼A	z.png)ÚsuperÚ__init__r   Úfolderr   r   Ú_check_integrityÚRuntimeErrorr   Ú_get_target_folderr    r   Ú
_alphabetsÚsumÚ_charactersÚ	enumerater   Ú_character_imagesÚ_flat_character_imagesr   )r$   r   r   r   r   r   r   ÚidxÚ	characterÚimageÚ	__class__s   `         €r%   r(   zOmniglot.__init__&   s  ù€ ô 	‰Ñœ˜d D§K¡KÓ0¸IÐXhÐÔiØ$ˆŒáØ�M‰MŒOà×$Ñ$Ô&ÜÐiÓjÐjä! $§)¡)¨T×-DÑ-DÓ-FÓGˆÔÜ" 4×#5Ñ#5Ó6ˆŒÜ&)ÛbÐRV×RaÑRaÔbÐdfó'
ˆÔô
 #,¨D×,<Ñ,<Ó"=÷"
ð "
á��Yô (2´$°t×7IÑ7IÈ9Ó2UÐW]Ó'^Ö_˜eˆe�SŠ\Ô_ô"
ˆÔô >AÀ×AWÑAWÐY[Ó=\ˆÔ#Øˆ�ùò	 `ùô"
s   Ã*E	ÄEÄE	ÅE	c                 ó,   — t        | j                  «      S r   )Úlenr2   ©r$   s    r%   Ú__len__zOmniglot.__len__D   s   € Ü�4×.Ñ.Ó/Ð/ó    Úindexc                 óp  — | j                   |   \  }}t        | j                  | j                  |   |«      }| j                  €&t        j                  |d¬«      j                  d«      n| j	                  |«      }| j                  r| j                  |«      }| j                  r| j                  |«      }||fS )z 
        Args:
            index (int): Index

        Returns:
            tuple: (image, target) where target is index of the target character class.
        Úr)ÚmodeÚL)
r2   r   r    r/   r   r	   ÚopenÚconvertr   r   )r$   r<   Ú
image_nameÚcharacter_classÚ
image_pathr5   s         r%   Ú__getitem__zOmniglot.__getitem__G   s¥   € ð '+×&AÑ&AÀ%Ñ&HÑ#ˆ
�OÜ˜$×,Ñ,¨d×.>Ñ.>¸Ñ.OÐQ[Ó\ˆ
ØAEÇÁÐAT”—
‘
˜:¨CÔ0×8Ñ8¸Ô=ÐZ^×ZeÑZeÐfpÓZqˆà�>Š>Ø—N‘N 5Ó)ˆEà× Ò Ø"×3Ñ3°OÓDˆOà�oÐ%Ð%r;   c                 ó†   — | j                  «       }t        t        | j                  |dz   «      | j                  |   «      syy)Nú.zipFT)r,   r   r   r   Úzips_md5)r$   Úzip_filenames     r%   r*   zOmniglot._check_integrity[   s:   € Ø×.Ñ.Ó0ˆÜœt D§I¡I¨|¸fÑ/DÓEÀtÇ}Á}ÐUaÑGbÔcØØr;   c                 óÀ   — | j                  «       ry | j                  «       }|dz   }| j                  dz   |z   }t        || j                  || j
                  |   ¬«       y )NrH   ú/)ÚfilenameÚmd5)r*   r,   Údownload_url_prefixr   r   rI   )r$   rM   rJ   Úurls       r%   r   zOmniglot.downloada   s]   € Ø× Ñ Ô"Øà×*Ñ*Ó,ˆØ &Ñ(ˆØ×&Ñ&¨Ñ,¨|Ñ;ˆÜ$ S¨$¯)©)¸lÐPT×P]ÑP]Ð^fÑPgÖhr;   c                 ó"   — | j                   rdS dS )Nr   r   )r   r9   s    r%   r,   zOmniglot._get_target_folderj   s   € Ø&*§o¢oÐ"ÐNÐ;NÐNr;   )TNNFN)r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r)   rO   rI   r   Ústrr   Úboolr   r   r   r(   Úintr:   ÚtuplerF   r*   r   r,   Ú__classcell__)r6   s   @r%   r   r      sñ   ø„ ñð& €FØ`Ðà?Ø?ñ€Hð  Ø(,Ø/3ØØ>Bñà�C˜�IÑðð ðð ˜HÑ%ð	ð
 # 8Ñ,ðð ðð ˜ 5¨¨d¨Ñ#3Ð"4°cÐ"9Ñ:Ñ;ðð 
õð<0˜ó 0ð& ð &¨¨s°C¨x©ó &ð( $ó óiðO C÷ Or;   r   N)Úos.pathr   Úpathlibr   Útypingr   r   r   r   ÚPILr	   Úutilsr   r   r   r   Úvisionr   r   © r;   r%   ú<module>rb      s-   ðÝ Ý ß 1Ó 1å ç VÓ VÝ !ô`Oˆ}õ `Or;   