
    h^!                         S SK r S SKrS SKJr  S SKJr  S SKJrJrJ	r	J
r
  S SKrS SKrSSKJrJrJrJr  SSKJr  \" S/ S	Q5      r " S
 S\5      rg)    N)
namedtuple)Path)AnyCallableOptionalUnion   )check_integritydownload_file_from_google_driveextract_archiveverify_str_arg)VisionDatasetCSV)headerindexdatac                      ^  \ rS rSrSrSr/ SQr     SS\\\	4   S\S\\
\   \4   S	\\   S
\\   S\SS4U 4S jjjr SS\S\\   S\4S jjrS\4S jrSS jrS\S\\\4   4S jrS\4S jrS\4S jrSrU =r$ )CelebA   a  `Large-scale CelebFaces Attributes (CelebA) Dataset <http://mmlab.ie.cuhk.edu.hk/projects/CelebA.html>`_ Dataset.

Args:
    root (str or ``pathlib.Path``): Root directory where images are downloaded to.
    split (string): One of {'train', 'valid', 'test', 'all'}.
        Accordingly dataset is selected.
    target_type (string or list, optional): Type of target to use, ``attr``, ``identity``, ``bbox``,
        or ``landmarks``. Can also be a list to output a tuple with all specified target types.
        The targets represent:

            - ``attr`` (Tensor shape=(40,) dtype=int): binary (0, 1) labels for attributes
            - ``identity`` (int): label for each person (data points with the same identity are the same person)
            - ``bbox`` (Tensor shape=(4,) dtype=int): bounding box (x, y, width, height)
            - ``landmarks`` (Tensor shape=(10,) dtype=int): landmark points (lefteye_x, lefteye_y, righteye_x,
              righteye_y, nose_x, nose_y, leftmouth_x, leftmouth_y, rightmouth_x, rightmouth_y)

        Defaults to ``attr``. If empty, ``None`` will be returned as target.

    transform (callable, optional): A function/transform that takes in a PIL image
        and returns a transformed version. E.g, ``transforms.PILToTensor``
    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.

        .. warning::

            To download the dataset `gdown <https://github.com/wkentaro/gdown>`_ is required.
celeba))0B7EVK8r0v71pZjFTYXZWM3FlRnM 00d2c5bc6d35e252742224ab0c1e8fcbimg_align_celeba.zip)0B7EVK8r0v71pblRyaVFSWGxPY0U 75e246fa4810816ffd6ee81facbd244clist_attr_celeba.txt)z!1_ee_0u7vcNLOfNLegJRHmolfH5ICW-XS 32bd1bd63d3c78cd57e08160ec5ed1e2identity_CelebA.txt)0B7EVK8r0v71pbThiMVRxWXZ4dU0 00566efa6fedff7a56946cd1c10f1c16list_bbox_celeba.txt)0B7EVK8r0v71pd0FJY3Blby1HUTQ cc24ecafdb5b50baae59b03474781f8clist_landmarks_align_celeba.txt)0B7EVK8r0v71pY0NSMzRuSXJEVkk d32c9cbf5e040fd4025c592c306e6668list_eval_partition.txtNrootsplittarget_type	transformtarget_transformdownloadreturnc                   > [         TU ]  XUS9  X l        [        U[        5      (       a  X0l        OU/U l        U R
                  (       d  U R                  b  [        S5      eU(       a  U R                  5         U R                  5       (       d  [        S5      eSSSS S.nU[        [        U[        5      (       a  UR                  5       OUSS5         nU R                  S	5      n	U R                  S
5      n
U R                  SSS9nU R                  SSS9nU R                  SSS9nUc  [        S 5      OU	R                  U:H  R!                  5       nU[        S 5      :X  a  U	R"                  U l        OL[&        R                   " [&        R(                  " U5      5       Vs/ s H  oR"                  U   PM     snU l        U
R                  U   U l        UR                  U   U l        UR                  U   U l        UR                  U   U l        [&        R2                  " U R0                  S-   SSS9U l        UR4                  U l        g s  snf )N)r+   r,   z6target_transform is specified but target_type is emptyzHDataset not found or corrupted. You can use download=True to download itr   r	      )trainvalidtestallr)   r'   r   r!   )r   r$   r   floor)rounding_mode)super__init__r)   
isinstancelistr*   r,   RuntimeErrorr-   _check_integrityr   strlower	_load_csvslicer   squeezer   filenametorchnonzeroidentitybboxlandmarks_alignattrdivr   
attr_names)selfr(   r)   r*   r+   r,   r-   	split_mapsplit_splitsrE   rF   rG   rH   maski	__class__s                   S/var/www/auris/envauris/lib/python3.13/site-packages/torchvision/datasets/celeba.pyr8   CelebA.__init__A   s    	EUV
k4((* +}DD$9$9$EWXXMMO$$&&ijj 	
	 !+E3!7!7U1
  9:>>"78~~4Q~?..)JST.U~~4Q~?$nuT{6;;&3H2Q2Q2S5;"LLDM6;mmEMMRVDW6XY6X\\!_6XYDM d+IIdO	.33D9IIdO	IIdii!mQgF	++ Zs    I
rB   r   c           	         [        [        R                  R                  U R                  U R
                  U5      5       n[        [        R                  " USSS95      nS S S 5        Ub  WU   nXBS-   S  nO/ nW Vs/ s H  ofS   PM	     nnU Vs/ s H  ofSS  PM	     nnU Vs/ s H  n[        [        [        U5      5      PM     n	n[        XW[        R                  " U	5      5      $ ! , (       d  f       N= fs  snf s  snf s  snf )N T)	delimiterskipinitialspacer	   r   )openospathjoinr(   base_folderr:   csvreadermapintr   rC   tensor)
rK   rB   r   csv_filer   headersrowindicesrP   data_ints
             rR   r?   CelebA._load_csv{   s    
 "'',,tyy$*:*:HEF(

8sTRSD G 6lG
%DG%)*Tcq6T*#'(4CAB4(/34t!DS!%t47U\\(%;<< GF +(4s    C*=C;D %#D*
C8c                    U R                    Hv  u  pn[        R                  R                  U R                  U R
                  U5      n[        R                  R                  U5      u  pUS;  d  Md  [        XB5      (       a  Mv    g   [        R                  R                  [        R                  R                  U R                  U R
                  S5      5      $ )N)z.zipz.7zFimg_align_celeba)		file_listrY   rZ   r[   r(   r\   splitextr
   isdir)rK   _md5rB   fpathexts         rR   r<   CelebA._check_integrity   s     $AHGGLLD,<,<hGEWW%%h/FA /)/%2M2M !/ ww}}RWW\\$))T5E5EGYZ[[    c                 V   U R                  5       (       a  g U R                   HE  u  pn[        U[        R                  R                  U R                  U R                  5      X25        MG     [        [        R                  R                  U R                  U R                  S5      5        g )Nr   )	r<   rj   r   rY   rZ   r[   r(   r\   r   )rK   file_idrn   rB   s       rR   r-   CelebA.download   ss      ""&*nn"G(+GRWW\\$))TM]M]5^`hn '5 	TYY0@0@BXYZrr   r   c           	      &   [         R                  R                  [        R                  R                  U R                  U R                  SU R                  U   5      5      n/ nU R                   H  nUS:X  a$  UR                  U R                  US S 24   5        M-  US:X  a"  UR                  U R                  US4   5        MU  US:X  a$  UR                  U R                  US S 24   5        M  US:X  a$  UR                  U R                  US S 24   5        M  [        SU S35      e   U R                   b  U R!                  U5      nU(       a@  [#        U5      S	:  a  [%        U5      OUS   nU R&                  b  U R'                  U5      nX#4$ S nX#4$ )
Nri   rH   rE   r   rF   	landmarkszTarget type "z" is not recognized.r	   )PILImagerX   rY   rZ   r[   r(   r\   rB   r*   appendrH   rE   rF   rG   
ValueErrorr+   lentupler,   )rK   r   Xtargetts        rR   __getitem__CelebA.__getitem__   sY   IINN277<<		43C3CEWY]YfYfglYmno!!AF{diiq12jdmmE1H56fdiiq12k!d225!8<= !=3G!HII " >>%q!A&)&kAoU6]6!9F$$0..v6 y Fyrr   c                 ,    [        U R                  5      $ N)r|   rH   )rK   s    rR   __len__CelebA.__len__   s    499~rr   c                 `    SS/nSR                  U5      R                  " S0 U R                  D6$ )NzTarget type: {target_type}zSplit: {split}
 )r[   format__dict__)rK   liness     rR   
extra_reprCelebA.extra_repr   s.    -/?@yy&&777rr   )rH   rJ   rF   rB   rE   rG   r)   r*   )r1   rH   NNFr   )r.   N)__name__
__module____qualname____firstlineno____doc__r\   rj   r   r=   r   r:   r   r   boolr8   r`   r   r?   r<   r-   r}   r   r   r   r   __static_attributes____classcell__)rQ   s   @rR   r   r      s   > KI  -3(,/38&CI8& 8& 49c>*	8&
 H%8& #8,8& 8& 
8& 8&z !%== = 
	=(
\$ 
\[ sCx < 8C 8 8rr   r   )r]   rY   collectionsr   pathlibr   typingr   r   r   r   rx   rC   utilsr
   r   r   r   visionr   r   r   r   rr   rR   <module>r      sA    
 	 "  1 1 
  d d !34w8] w8rr   