
    hp"                        S SK r S SKrS SKJr  S SKJrJrJrJr  S SK	J
r   S SKJr  S SKJr  SSKJrJr  SS	KJr  S
SS\R.                  R1                  SS5      S.SSS\R.                  R1                  SSS5      S.SSS\R.                  R1                  SS5      S.SSS\R.                  R1                  SS5      S.SSS\R.                  R1                  SS5      S.S S!S"\R.                  R1                  SS#5      S.S$S%S&\R.                  R1                  SS#5      S.S'.r " S( S)\5      r " S* S+\5      r " S, S-\5      rg! \ a
    S SK	Jr   GN)f = f).    N)Path)AnyCallableOptionalUnion)Element)parse)Image   )download_and_extract_archiveverify_str_arg)VisionDatasetzJhttp://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrainval_11-May-2012.tarzVOCtrainval_11-May-2012.tar 6cd6e144f989b92b3379bac3b3de84fd	VOCdevkitVOC2012)urlfilenamemd5base_dirzJhttp://host.robots.ox.ac.uk/pascal/VOC/voc2011/VOCtrainval_25-May-2011.tarzVOCtrainval_25-May-2011.tar 6c3384ef61512963050cb5d687e5bf1eTrainValVOC2011zJhttp://host.robots.ox.ac.uk/pascal/VOC/voc2010/VOCtrainval_03-May-2010.tarzVOCtrainval_03-May-2010.tar da459979d0c395079b5c75ee67908abbVOC2010zJhttp://host.robots.ox.ac.uk/pascal/VOC/voc2009/VOCtrainval_11-May-2009.tarzVOCtrainval_11-May-2009.tar a3e00b113cfcfebf17e343f59da3caa1VOC2009zJhttp://host.robots.ox.ac.uk/pascal/VOC/voc2008/VOCtrainval_14-Jul-2008.tar 2629fa636546599198acfcfbfcf1904aVOC2008zJhttp://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtrainval_06-Nov-2007.tarzVOCtrainval_06-Nov-2007.tar c52e279531787c972589f7e41ab4ae64VOC2007zFhttp://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtest_06-Nov-2007.tarzVOCtest_06-Nov-2007.tar b6e924de25625d8de591ea690078ad9f)201220112010200920082007	2007-testc                      ^  \ rS rSr% \\S'   \\S'   \\S'         SS\\\4   S\S\S\S	\	\
   S
\	\
   S\	\
   4U 4S jjjrS\4S jrSrU =r$ )_VOCBase?   _SPLITS_DIR_TARGET_DIR_TARGET_FILE_EXTrootyear	image_setdownload	transformtarget_transform
transformsc           
      0  > [         TU ]  XXV5        [        US[        SS5       Vs/ s H  n[	        U5      PM     snS9U l        / SQn	US:X  a  U	R                  S5        [        USU	5      U l        US:X  a  US:X  a  S	OUn
[        U
   nUS
   U l	        US   U l
        US   U l        US   n[        R                  R                  U R                  U5      nU(       a4  [!        U R                  U R                  U R                  U R                  S9  [        R                  R#                  U5      (       d  [%        S5      e[        R                  R                  USU R&                  5      n[        R                  R                  XR)                  S5      S-   5      n[+        [        R                  R                  U5      5       nUR-                  5        Vs/ s H  nUR/                  5       PM     nnS S S 5        [        R                  R                  US5      nW Vs/ s H&  n[        R                  R                  UUS-   5      PM(     snU l        [        R                  R                  XR2                  5      nU Vs/ s H0  n[        R                  R                  UUU R4                  -   5      PM2     snU l        [9        U R0                  5      [9        U R6                  5      :X  d   eg s  snf s  snf ! , (       d  f       GN= fs  snf s  snf )Nr0   i  i  )valid_values)traintrainvalvalr'   testr1   r(   r   r   r   r   )r   r   zHDataset not found or corrupted. You can use download=True to download it	ImageSets
z.txt
JPEGImagesz.jpg)super__init__r   rangestrr0   appendr1   DATASET_YEAR_DICTr   r   r   ospathjoinr/   r   isdirRuntimeErrorr,   rstripopen	readlinesstripimagesr-   r.   targetslen)selfr/   r0   r1   r2   r3   r4   r5   yrvalid_image_setskeydataset_year_dictr   voc_root
splits_dirsplit_ffx
file_names	image_dir
target_dir	__class__s                        P/var/www/auris/envauris/lib/python3.13/site-packages/torchvision/datasets/voc.pyr@   _VOCBase.__init__D   s[    	9G"4QVW[]aQb>cQb2s2wQb>cd	76>##F+'	;@PQ!V^	V0Ck-c2$U+)*5$U+$Z077<<		84(499t}}Z^ZbZbcww}}X&&ijjWW\\(K9I9IJ
'',,z+;+;D+AF+JK"'',,w'(A-.[[];]!'')]J; ) GGLL<8	DNOJqrww||Iq6z:JOWW\\(,<,<=
U_`U_PQZT5J5J1JKU_`4;;3t||#4444E ?d4 < )( P as/   K2K<K74K<"-L7L7K<<
Lreturnc                 ,    [        U R                  5      $ N)rP   rN   rQ   s    r_   __len___VOCBase.__len__t   s    4;;    )r   r1   rN   r   rO   r   r0   )r"   r8   FNNN)__name__
__module____qualname____firstlineno__rB   __annotations__r   r   boolr   r   r@   intre   __static_attributes____classcell__)r^   s   @r_   r*   r*   ?   s    
  (,/3)-.5CI.5 .5 	.5
 .5 H%.5 #8,.5 X&.5 .5`     rg   r*   c                   ^    \ rS rSrSrSrSrSr\S\	\
   4S j5       rS\S\\\4   4S	 jrS
rg)VOCSegmentationx   a  `Pascal VOC <http://host.robots.ox.ac.uk/pascal/VOC/>`_ Segmentation Dataset.

Args:
    root (str or ``pathlib.Path``): Root directory of the VOC Dataset.
    year (string, optional): The dataset year, supports years ``"2007"`` to ``"2012"``.
    image_set (string, optional): Select the image_set to use, ``"train"``, ``"trainval"`` or ``"val"``. If
        ``year=="2007"``, can also be ``"test"``.
    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.
    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.
    transforms (callable, optional): A function/transform that takes input sample and its target as entry
        and returns a transformed version.
SegmentationSegmentationClassz.pngra   c                     U R                   $ rc   rO   rd   s    r_   masksVOCSegmentation.masks       ||rg   indexc                     [         R                  " U R                  U   5      R                  S5      n[         R                  " U R                  U   5      nU R
                  b  U R                  X#5      u  p#X#4$ )zk
Args:
    index (int): Index

Returns:
    tuple: (image, target) where target is the image segmentation.
RGB)r
   rK   rN   convertrx   r5   rQ   r{   imgtargets       r_   __getitem__VOCSegmentation.__getitem__   s_     jjU+,44U;DJJu-.??&//#6KC{rg    N)rh   ri   rj   rk   __doc__r,   r-   r.   propertylistrB   rx   rn   tupler   r   ro   r   rg   r_   rr   rr   x   sQ    $ !K%KtCy   sCx rg   rr   c                       \ rS rSrSrSrSrSr\S\	\
   4S j5       rS\S\\\4   4S	 jr\S
\S\\
\4   4S j5       rSrg)VOCDetection   a.  `Pascal VOC <http://host.robots.ox.ac.uk/pascal/VOC/>`_ Detection Dataset.

Args:
    root (str or ``pathlib.Path``): Root directory of the VOC Dataset.
    year (string, optional): The dataset year, supports years ``"2007"`` to ``"2012"``.
    image_set (string, optional): Select the image_set to use, ``"train"``, ``"trainval"`` or ``"val"``. If
        ``year=="2007"``, can also be ``"test"``.
    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.
        (default: alphabetic indexing of VOC's 20 classes).
    transform (callable, optional): A function/transform that takes in a PIL image
        and returns a transformed version. E.g, ``transforms.RandomCrop``
    target_transform (callable, required): A function/transform that takes in the
        target and transforms it.
    transforms (callable, optional): A function/transform that takes input sample and its target as entry
        and returns a transformed version.
MainAnnotationsz.xmlra   c                     U R                   $ rc   rw   rd   s    r_   annotationsVOCDetection.annotations   rz   rg   r{   c                    [         R                  " U R                  U   5      R                  S5      nU R	                  [        U R                  U   5      R                  5       5      nU R                  b  U R                  X#5      u  p#X#4$ )zq
Args:
    index (int): Index

Returns:
    tuple: (image, target) where target is a dictionary of the XML tree.
r}   )	r
   rK   rN   r~   parse_voc_xmlET_parser   getrootr5   r   s       r_   r   VOCDetection.__getitem__   sq     jjU+,44U;##HT-=-=e-D$E$M$M$OP??&//#6KC{rg   nodec           	      F   0 n[        U 5      nU(       a  [        R                  " [         5      n[        [        R
                  U5       H/  nUR                  5        H  u  pVX5   R                  U5        M     M1     U R                  S:X  a	  US   /US'   U R                  UR                  5        VVs0 s H  u  pVU[        U5      S:X  a  US   OU_M     snn0nU R                  (       a/  U R                  R                  5       nU(       d  XqU R                  '   U$ s  snnf )N
annotationobjectr   r   )r   collectionsdefaultdictmapr   r   itemsrC   tagrP   textrM   )r   voc_dictchildrendef_dicdcindvr   s           r_   r   VOCDetection.parse_voc_xml   s    #%:&1&=&=d&CG,44h? hhjFCL''* ) @ xx<'%,X%6$7!QXQ^Q^Q`"aQ`vs3A!!#BQ`"abH9999??$D%)" #bs   3#Dr   N)rh   ri   rj   rk   r   r,   r-   r.   r   r   rB   r   rn   r   r   r   staticmethod
ET_Elementdictr   ro   r   rg   r_   r   r      s{    & KKT#Y   sCx   J 4S>  rg   r   )r   rE   pathlibr   typingr   r   r   r   xml.etree.ElementTreer   r   defusedxml.ElementTreer	   r   ImportErrorPILr
   utilsr   r   visionr   rF   rG   rD   r*   rr   r   r   rg   r_   <module>r      si    	  1 1 788  ? ! \11GGLLi8	 \11GGLL[)D	 \11GGLLi8	 \11GGLLi8	 \11GGLLi8	 \11GGLLi8	 X-1GGLLi8	K+ \6 } 6 r)h )X<8 <w  8778s   E EE