Ë
    Dêñiø  ã                   ór   — d dl Z d dl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 ddlmZ  G d„ d	e«      Zy)
é    N)ÚPath)ÚAnyÚCallableÚOptionalÚUnion)ÚImageé   )Údownload_and_extract_archive)ÚVisionDatasetc                   óØ   ‡ — e Zd ZdZdZddgZdZdZ	 	 	 	 	 ddee	e
f   ded	ee   d
ee   dee   defˆ fd„Zdedeeef   fd„Zdedefd„Zdefd„Zede	fd„«       Zdefd„Zdd„Zˆ xZS )ÚKittiuÂ  `KITTI <http://www.cvlibs.net/datasets/kitti/eval_object.php?obj_benchmark>`_ Dataset.

    It corresponds to the "left color images of object" dataset, for object detection.

    Args:
        root (str or ``pathlib.Path``): Root directory where images are downloaded to.
            Expects the following folder structure if download=False:

            .. code::

                <root>
                    â””â”€â”€ Kitti
                        â””â”€ raw
                            â”œâ”€â”€ training
                            |   â”œâ”€â”€ image_2
                            |   â””â”€â”€ label_2
                            â””â”€â”€ testing
                                â””â”€â”€ image_2
        train (bool, optional): Use ``train`` split if true, else ``test`` split.
            Defaults to ``train``.
        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.
        transforms (callable, optional): A function/transform that takes input sample
            and its target as entry and returns a transformed version.
        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.

    z0https://s3.eu-central-1.amazonaws.com/avg-kitti/zdata_object_image_2.zipzdata_object_label_2.zipÚimage_2Úlabel_2ÚrootÚtrainÚ	transformÚtarget_transformÚ
transformsÚdownloadc           	      óJ  •— t         ‰
| �  ||||¬«       g | _        g | _        || _        | j                  rdnd| _        |r| j                  «        | j                  «       st        d«      ‚t        j                  j                  | j                  | j
                  | j                  «      }| j                  r?t        j                  j                  | j                  | j
                  | j                  «      }t        j                  |«      D ]–  }	| j                  j!                  t        j                  j                  ||	«      «       | j                  sŒI| j                  j!                  t        j                  j                  |	j#                  d«      d   › d�«      «       Œ˜ y )N)r   r   r   ÚtrainingÚtestingz<Dataset not found. You may use download=True to download it.ú.r   z.txt)ÚsuperÚ__init__ÚimagesÚtargetsr   Ú	_locationr   Ú_check_existsÚRuntimeErrorÚosÚpathÚjoinÚ_raw_folderÚimage_dir_nameÚlabels_dir_nameÚlistdirÚappendÚsplit)Úselfr   r   r   r   r   r   Ú	image_dirÚ
labels_dirÚimg_fileÚ	__class__s             €ú\/var/www/pod-logistic/pod-ai/venv/lib/python3.12/site-packages/torchvision/datasets/kitti.pyr   zKitti.__init__5   s;  ø€ ô 	‰ÑØØØ-Ø!ð	 	ô 	
ð ˆŒØˆŒØˆŒ
Ø'+§z¢z™°yˆŒáØ�M‰MŒOØ×!Ñ!Ô#ÜÐ]Ó^Ð^ä—G‘G—L‘L ×!1Ñ!1°4·>±>À4×CVÑCVÓWˆ	Ø�:Š:ÜŸ™Ÿ™ d×&6Ñ&6¸¿¹È×H\ÑH\Ó]ˆJÜŸ
™
 9Ó-ò 	_ˆHØ�K‰K×ÑœrŸw™wŸ|™|¨I°xÓ@ÔAØ�z‹zØ—‘×#Ñ#¤B§G¡G§L¡L°ÀÇÁÈsÓ@SÐTUÑ@VÐ?WÐW[Ð=\Ó$]Õ^ñ	_ó    ÚindexÚreturnc                 óÎ   — t        j                  | j                  |   «      }| j                  r| j	                  |«      nd}| j
                  r| j                  ||«      \  }}||fS )aÄ  Get item at a given index.

        Args:
            index (int): Index
        Returns:
            tuple: (image, target), where
            target is a list of dictionaries with the following keys:

            - type: str
            - truncated: float
            - occluded: int
            - alpha: float
            - bbox: float[4]
            - dimensions: float[3]
            - locations: float[3]
            - rotation_y: float

        N)r   Úopenr   r   Ú_parse_targetr   )r*   r1   ÚimageÚtargets       r/   Ú__getitem__zKitti.__getitem__V   sX   € ô& —
‘
˜4Ÿ;™; uÑ-Ó.ˆØ.2¯jªj�×#Ñ# EÔ*¸dˆØ�?Š?Ø ŸO™O¨E°6Ó:‰MˆE�6Ø�fˆ}Ðr0   c                 óø  — g }t        | j                  |   «      5 }t        j                  |d¬«      }|D ]�  }|j	                  |d   t        |d   «      t        |d   «      t        |d   «      |dd D �cg c]  }t        |«      ‘Œ c}|dd	 D �cg c]  }t        |«      ‘Œ c}|d	d
 D �cg c]  }t        |«      ‘Œ c}t        |d
   «      dœ«       ŒŸ 	 d d d «       |S c c}w c c}w c c}w # 1 sw Y   |S xY w)Nú )Ú	delimiterr   r	   é   é   é   é   é   é   )ÚtypeÚ	truncatedÚoccludedÚalphaÚbboxÚ
dimensionsÚlocationÚ
rotation_y)r4   r   ÚcsvÚreaderr(   ÚfloatÚint)r*   r1   r7   ÚinpÚcontentÚlineÚxs          r/   r5   zKitti._parse_targeto   sî   € ØˆÜ�$—,‘,˜uÑ%Ó&ð 	¨#Ü—j‘j °Ô4ˆGØò �Ø—‘à $ Q¡Ü%*¨4°©7£^Ü$'¨¨Q©£LÜ!& t¨A¡w£Ø37¸¸!°9Ö =¨a¤ q¥Ò =Ø9=¸aÀ¸Ö&D°A¤u¨Q¥xÒ&DØ7;¸B¸r°{Ö$C°!¤U¨1¥XÒ$CÜ&+¨D°©H£oñ	õñ÷	ð ˆùò !>ùÚ&DùÚ$C÷	ð ˆús6   ›AC/Á5C Â	C/ÂC%Â"	C/Â+C*Â=C/Ã C/Ã/C9c                 ó,   — t        | j                  «      S ©N)Úlenr   ©r*   s    r/   Ú__len__zKitti.__len__‚   s   € Ü�4—;‘;ÓÐr0   c                 ó€   — t         j                  j                  | j                  | j                  j
                  d«      S )NÚraw)r!   r"   r#   r   r.   Ú__name__rU   s    r/   r$   zKitti._raw_folder…   s'   € ä�w‰w�|‰|˜DŸI™I t§~¡~×'>Ñ'>ÀÓFÐFr0   c                 ó”   ‡ — ‰ j                   g}‰ j                  r|j                  ‰ j                  «       t	        ˆ fd„|D «       «      S )z#Check if the data directory exists.c              3   óÂ   •K  — | ]V  }t         j                  j                  t         j                  j                  ‰j                  ‰j
                  |«      «      –— ŒX y ­wrS   )r!   r"   Úisdirr#   r$   r   )Ú.0Úfnamer*   s     €r/   ú	<genexpr>z&Kitti._check_exists.<locals>.<genexpr>Ž   s;   øè ø€ ÒmÐ\a”2—7‘7—=‘=¤§¡§¡¨d×.>Ñ.>ÀÇÁÐPUÓ!V×WÑmùs   ƒAA)r%   r   r(   r&   Úall)r*   Úfolderss   ` r/   r   zKitti._check_exists‰   s<   ø€ à×&Ñ&Ð'ˆØ�:Š:Ø�N‰N˜4×/Ñ/Ô0ÜÓmÐelÔmÓmÐmr0   c                 óÖ   — | j                  «       ryt        j                  | j                  d¬«       | j                  D ](  }t        | j                  › |› �| j                  |¬«       Œ* y)z4Download the KITTI data if it doesn't exist already.NT)Úexist_ok)ÚurlÚdownload_rootÚfilename)r   r!   Úmakedirsr$   Ú	resourcesr
   Údata_url)r*   r^   s     r/   r   zKitti.download�   s`   € ð ×ÑÔØä
�‰�D×$Ñ$¨tÕ4ð —^‘^ò 	ˆEÜ(Ø—}‘}�o e WÐ-Ø"×.Ñ.Øöñ	r0   )TNNNF)r2   N)rY   Ú
__module__Ú__qualname__Ú__doc__ri   rh   r%   r&   r   Ústrr   Úboolr   r   r   rM   Útupler   r8   Úlistr5   rV   Úpropertyr$   r   r   Ú__classcell__)r.   s   @r/   r   r      s  ø„ ñð@ B€Hà!Ø!ð€Ið €NØ€Oð
 Ø(,Ø/3Ø)-Øñ_à�C˜�IÑð_ð ð_ð ˜HÑ%ð	_ð
 # 8Ñ,ð_ð ˜XÑ&ð_ð õ_ðB ð ¨¨s°C¨x©ó ð2 3ð ¨4ó ð& ˜ó  ð ðG˜Sò Gó ðGðn˜tó n÷r0   r   )rJ   r!   Úpathlibr   Útypingr   r   r   r   ÚPILr   Úutilsr
   Úvisionr   r   © r0   r/   ú<module>ry      s+   ðÛ 
Û 	Ý ß 1Ó 1å å /Ý !ôRˆMõ Rr0   