§
    l¬¸j$ ã                  óœ  — d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlZddlZddlmZmZmZmZ dd	lmZmZmZ  G d
„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ dee¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z dS )z«
Ultralytics Results, Boxes, Masks, SemanticMask, Keypoints, Probs, and OBB classes for handling inference results.

Usage: See https://docs.ultralytics.com/modes/predict
é    )Úannotations)Údeepcopy)Úcached_property)ÚPath)ÚAnyN)ÚLOGGERÚDataExportMixinÚSimpleClassÚops)Ú	AnnotatorÚcolorsÚsave_one_boxc                  óX   — e Zd ZdZdd„Zedd
„¦   «         Zd„ Zd„ Zd„ Z	d„ Z
dd„Zd„ ZdS )Ú
BaseTensoraŸ  Base tensor class with additional methods for easy manipulation and device handling.

    This class provides a foundation for tensor-like objects with device management capabilities, supporting both
    PyTorch tensors and NumPy arrays. It includes methods for moving data between devices and converting between tensor
    types.

    Attributes:
        data (torch.Tensor | np.ndarray): Prediction data such as bounding boxes, masks, or keypoints.
        orig_shape (tuple[int, int]): Original shape of the image, typically in the format (height, width).

    Methods:
        cpu: Return a copy of the tensor stored in CPU memory.
        numpy: Return a copy of the tensor as a numpy array.
        cuda: Move the tensor to GPU memory, returning a new instance if necessary.
        to: Return a copy of the tensor with the specified device and dtype.

    Examples:
        >>> import torch
        >>> data = torch.tensor([[1, 2, 3], [4, 5, 6]])
        >>> orig_shape = (720, 1280)
        >>> base_tensor = BaseTensor(data, orig_shape)
        >>> cpu_tensor = base_tensor.cpu()
        >>> numpy_array = base_tensor.numpy()
        >>> gpu_tensor = base_tensor.cuda()
    Údataútorch.Tensor | np.ndarrayÚ
orig_shapeútuple[int, int]ÚreturnÚNonec                ó‚   — t          |t          j        t          j        f¦  «        s
J d¦   «         ‚|| _        || _        dS )a3  Initialize BaseTensor with prediction data and the original shape of the image.

        Args:
            data (torch.Tensor | np.ndarray): Prediction data such as bounding boxes, masks, or keypoints.
            orig_shape (tuple[int, int]): Original shape of the image in (height, width) format.
        z'data must be torch.Tensor or np.ndarrayN)Ú
isinstanceÚtorchÚTensorÚnpÚndarrayr   r   )Úselfr   r   s      új/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/ultralytics/engine/results.pyÚ__init__zBaseTensor.__init__1   s>   € õ ˜$¥¤­r¬zÐ :Ñ;Ô;ÐfÐfÐ=fÑfÔfÐ;ØˆŒ	Ø$ˆŒˆˆó    útuple[int, ...]c                ó   — | j         j        S )aU  Return the shape of the underlying data tensor.

        Returns:
            (tuple[int, ...]): The shape of the data tensor.

        Examples:
            >>> data = torch.rand(100, 4)
            >>> base_tensor = BaseTensor(data, orig_shape=(720, 1280))
            >>> print(base_tensor.shape)
            torch.Size([100, 4])
        )r   Úshape©r   s    r   r#   zBaseTensor.shape<   s   € ð ŒyŒÐr    c                ó¨   — t          | j        t          j        ¦  «        r| n1|                      | j                             ¦   «         | j        ¦  «        S )aþ  Return a copy of the tensor stored in CPU memory.

        Returns:
            (BaseTensor): A new BaseTensor object with the data tensor moved to CPU memory.

        Examples:
            >>> data = torch.tensor([[1, 2, 3], [4, 5, 6]]).cuda()
            >>> base_tensor = BaseTensor(data, orig_shape=(720, 1280))
            >>> cpu_tensor = base_tensor.cpu()
            >>> isinstance(cpu_tensor, BaseTensor)
            True
            >>> cpu_tensor.data.device
            device(type='cpu')
        )r   r   r   r   Ú	__class__Úcpur   r$   s    r   r'   zBaseTensor.cpuK   s=   € õ " $¤)­R¬ZÑ8Ô8Ðnˆtˆt¸d¿nºnÈTÌYÏ]Ê]É_Ì_Ð^bÔ^mÑ>nÔ>nÐnr    c                óÌ   — t          | j        t          j        ¦  «        r| nC|                      | j                             ¦   «                              ¦   «         | j        ¦  «        S )aá  Return a copy of this object with its data converted to a NumPy array.

        Returns:
            (BaseTensor): A new instance with `data` as a NumPy array.

        Examples:
            >>> data = torch.tensor([[1, 2, 3], [4, 5, 6]])
            >>> orig_shape = (720, 1280)
            >>> base_tensor = BaseTensor(data, orig_shape)
            >>> numpy_tensor = base_tensor.numpy()
            >>> print(type(numpy_tensor.data))
            <class 'numpy.ndarray'>
        )r   r   r   r   r&   r'   Únumpyr   r$   s    r   r)   zBaseTensor.numpy\   sI   € õ " $¤)­R¬ZÑ8Ô8Ðvˆtˆt¸d¿nºnÈTÌYÏ]Ê]É_Ì_×MbÒMbÑMdÔMdÐfjÔfuÑ>vÔ>vÐvr    c                óŠ   — |                       t          j        | j        ¦  «                             ¦   «         | j        ¦  «        S )aö  Move the tensor to GPU memory.

        Returns:
            (BaseTensor): A new BaseTensor instance with the data moved to GPU memory.

        Examples:
            >>> import torch
            >>> from ultralytics.engine.results import BaseTensor
            >>> data = torch.tensor([[1, 2, 3], [4, 5, 6]])
            >>> base_tensor = BaseTensor(data, orig_shape=(720, 1280))
            >>> gpu_tensor = base_tensor.cuda()
            >>> print(gpu_tensor.data.device)
            cuda:0
        )r&   r   Ú	as_tensorr   Úcudar   r$   s    r   r,   zBaseTensor.cudal   s2   € ð �~Š~�eœo¨d¬iÑ8Ô8×=Ò=Ñ?Ô?ÀÄÑQÔQÐQr    c                ó|   — |                        t          j        | j        ¦  «        j        |i |¤Ž| j        ¦  «        S )am  Return a copy of the tensor with the specified device and dtype.

        Args:
            *args (Any): Variable length argument list to be passed to torch.Tensor.to().
            **kwargs (Any): Arbitrary keyword arguments to be passed to torch.Tensor.to().

        Returns:
            (BaseTensor): A new BaseTensor instance with the data moved to the specified device and/or dtype.

        Examples:
            >>> base_tensor = BaseTensor(torch.randn(3, 4), orig_shape=(480, 640))
            >>> cuda_tensor = base_tensor.to("cuda")
            >>> float16_tensor = base_tensor.to(dtype=torch.float16)
        )r&   r   r+   r   Útor   ©r   ÚargsÚkwargss      r   r.   zBaseTensor.to}   s9   € ð �~Š~Ð;�eœo¨d¬iÑ8Ô8Ô;¸TÐLÀVÐLÐLÈdÌoÑ^Ô^Ð^r    Úintc                ó*   — t          | j        ¦  «        S )ae  Return the length of the underlying data tensor.

        Returns:
            (int): The number of elements in the first dimension of the data tensor.

        Examples:
            >>> data = torch.tensor([[1, 2, 3], [4, 5, 6]])
            >>> base_tensor = BaseTensor(data, orig_shape=(720, 1280))
            >>> len(base_tensor)
            2
        )Úlenr   r$   s    r   Ú__len__zBaseTensor.__len__Ž   s   € õ �4”9‰~Œ~Ðr    c                óN   — |                       | j        |         | j        ¦  «        S )aS  Return a new BaseTensor instance containing the specified indexed elements of the data tensor.

        Args:
            idx (int | list[int] | torch.Tensor): Index or indices to select from the data tensor.

        Returns:
            (BaseTensor): A new BaseTensor instance containing the indexed data.

        Examples:
            >>> data = torch.tensor([[1, 2, 3], [4, 5, 6]])
            >>> base_tensor = BaseTensor(data, orig_shape=(720, 1280))
            >>> result = base_tensor[0]  # Select the first row
            >>> print(result.data)
            tensor([1, 2, 3])
        )r&   r   r   ©r   Úidxs     r   Ú__getitem__zBaseTensor.__getitem__œ   s    € ð  �~Š~˜dœi¨œn¨d¬oÑ>Ô>Ð>r    N)r   r   r   r   r   r   )r   r!   ©r   r2   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr#   r'   r)   r,   r.   r5   r9   © r    r   r   r      s½   € € € € € ðð ð4	%ð 	%ð 	%ð 	%ð ðð ð ñ „Xððoð oð oð"wð wð wð Rð Rð Rð"_ð _ð _ð"ð ð ð ð?ð ?ð ?ð ?ð ?r    r   c                  ó    — e Zd ZdZdd„Zd„ ZdS )Ú_DenseResultTensorzZA BaseTensor representing zero or one dense per-image result, immune to row-wise indexing.r   r2   c                óH   — t          | j        j        d         dk    ¦  «        S )zAReturn 1 if the map holds data, 0 if a prior indexing emptied it.r   )r2   r   r#   r$   s    r   r5   z_DenseResultTensor.__len__²   s   € å�4”9”? 1Ô%¨Ò)Ñ*Ô*Ð*r    c                ób  — t          |t          j        ¦  «        r&|                     ¦   «                              ¦   «         n|}t          j        t          j        t          | ¦  «        ¦  «        |         ¦  «        dk    }|  	                    |r| j
        dd…         n| j
        | j        ¦  «        S )zgReturn the intact map for any index selecting the one result, or an emptied map for an empty selection.r   N)r   r   r   r'   r)   r   ÚsizeÚaranger4   r&   r   r   )r   r8   Úemptys      r   r9   z_DenseResultTensor.__getitem__¶   sƒ   € å#-¨cµ5´<Ñ#@Ô#@ÐIˆc�gŠg‰iŒi�oŠoÑÔÐÀcˆÝ”�œ	¥# d¡)¤)Ñ,Ô,¨SÔ1Ñ2Ô2°aÒ7ˆØ�~Š~¨uÐC˜dœi¨¨¨œm˜m¸$¼)ÀTÄ_ÑUÔUÐUr    Nr:   )r;   r<   r=   r>   r5   r9   r@   r    r   rB   rB   ¯   sB   € € € € € ØdÐdð+ð +ð +ð +ðVð Vð Vð Vð Vr    rB   c                  ó   — e Zd ZdZdS )ÚSemanticMaskz.Semantic segmentation class map for one image.N©r;   r<   r=   r>   r@   r    r   rI   rI   ½   s   € € € € € Ø8Ð8Ð8Ð8r    rI   c                  ó   — e Zd ZdZdS )ÚDepthMapz9Per-pixel depth map (meters) for one image, shape (H, W).NrJ   r@   r    r   rL   rL   Á   s   € € € € € ØCÐCÐCÐCr    rL   c                  óî   — e Zd ZdZ	 	 	 	 	 	 	 	 dJdKd„Zd„ ZdLd„Z	 	 	 	 	 	 	 dMdNd„ZdOd„Zd„ Z	d„ Z
d„ Zd„ Zd „ Z	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dPdQd:„Zd;„ ZdRdSd<„ZdTd=„ZdUdVdA„Z edB¦  «        fdWdE„ZdXdYdI„ZdS )ZÚResultsa›
  A class for storing and manipulating inference results.

    This class provides comprehensive functionality for handling inference results from various Ultralytics models,
    including detection, instance segmentation, semantic segmentation, depth estimation, classification, pose
    estimation, and oriented bounding box detection. It supports visualization, data export, and various coordinate
    transformations.

    Attributes:
        orig_img (np.ndarray): The original image as a numpy array.
        orig_shape (tuple[int, int]): Original image shape in (height, width) format.
        boxes (Boxes | None): Detected bounding boxes.
        masks (Masks | None): Segmentation masks.
        probs (Probs | None): Classification probabilities.
        keypoints (Keypoints | None): Detected keypoints.
        obb (OBB | None): Oriented bounding boxes.
        semantic_mask (SemanticMask | None): Semantic segmentation class map.
        depth (DepthMap | None): Per-pixel depth map.
        speed (dict): Dictionary containing inference speed information.
        names (dict): Dictionary mapping class indices to class names.
        path (str): Path to the input image file.
        save_dir (str | None): Directory to save results.

    Methods:
        update: Update the Results object with new detection data.
        cpu: Return a copy of the Results object with all tensors moved to CPU memory.
        numpy: Convert all tensors in the Results object to numpy arrays.
        cuda: Move all tensors in the Results object to GPU memory.
        to: Move all tensors to the specified device and dtype.
        new: Create a new Results object with the same image, path, names, and speed attributes.
        plot: Plot detection results on an input BGR image.
        show: Display the image with annotated inference results.
        save: Save annotated inference results image to file.
        verbose: Return a log string for each task in the results.
        save_txt: Save detection results to a text file.
        save_crop: Save cropped detection images to specified directory.
        summary: Convert inference results to a summarized dictionary.
        to_df: Convert detection results to a Polars DataFrame.
        to_json: Convert detection results to JSON format.
        to_csv: Convert detection results to a CSV format.

    Examples:
        >>> results = model("path/to/image.jpg")
        >>> result = results[0]  # Get the first result
        >>> boxes = result.boxes  # Get the boxes for the first result
        >>> masks = result.masks  # Get the masks for the first result
        >>> for result in results:
        ...     result.plot()  # Plot detection results
    NÚorig_imgú
np.ndarrayÚpathÚstrÚnamesúdict[int, str]Úboxesútorch.Tensor | NoneÚmasksÚprobsÚ	keypointsÚobbÚspeedúdict[str, float] | NoneÚsemantic_maskÚdepthr   r   c                ó*  — || _         |j        dd…         | _        |�t          || j        ¦  «        nd| _        |�t          || j        ¦  «        nd| _        |�t          |¦  «        nd| _        |�t          || j        ¦  «        nd| _
        |�t          || j        ¦  «        nd| _        |
�t          |
| j        ¦  «        nd| _        |�t          || j        ¦  «        nd| _        |	�|	nddddœ| _        || _        || _        d| _        d| _        dS )aü  Initialize the Results class for storing and manipulating inference results.

        Args:
            orig_img (np.ndarray): The original image as a numpy array.
            path (str): The path to the image file.
            names (dict): A dictionary of class names.
            boxes (torch.Tensor | None): A 2D tensor of bounding box coordinates for each detection.
            masks (torch.Tensor | None): A 3D tensor of detection masks, where each mask is a binary image.
            probs (torch.Tensor | None): A 1D tensor of probabilities of each class for classification task.
            keypoints (torch.Tensor | None): A 2D tensor of keypoint coordinates for each detection.
            obb (torch.Tensor | None): A 2D tensor of oriented bounding box coordinates for each detection.
            semantic_mask (torch.Tensor | None): A 2D tensor of class IDs for semantic segmentation results.
            depth (torch.Tensor | None): A 2D float tensor of per-pixel depth values (H, W).
            speed (dict | None): A dictionary containing preprocess, inference, and postprocess speeds (ms/image).

        Notes:
            For the default pose model, keypoint indices for human body pose estimation are:
            0: Nose, 1: Left Eye, 2: Right Eye, 3: Left Ear, 4: Right Ear
            5: Left Shoulder, 6: Right Shoulder, 7: Left Elbow, 8: Right Elbow
            9: Left Wrist, 10: Right Wrist, 11: Left Hip, 12: Right Hip
            13: Left Knee, 14: Right Knee, 15: Left Ankle, 16: Right Ankle
        Né   )Ú
preprocessÚ	inferenceÚpostprocess)rU   rW   rX   rY   rZ   r]   r^   )rO   r#   r   ÚBoxesrU   ÚMasksrW   ÚProbsrX   Ú	KeypointsrY   ÚOBBrZ   rI   r]   rL   r^   r[   rS   rQ   Úsave_dirÚ_keys)r   rO   rQ   rS   rU   rW   rX   rY   rZ   r[   r]   r^   s               r   r   zResults.__init__÷   s!  € ðH !ˆŒØ"œ.¨¨!¨Ô,ˆŒØ6;Ð6G•U˜5 $¤/Ñ2Ô2Ð2ÈTˆŒ
Ø6;Ð6G•U˜5 $¤/Ñ2Ô2Ð2ÈTˆŒ
Ø%*Ð%6•U˜5‘\”\�\¸DˆŒ
ØBKÐBW� 9¨d¬oÑ>Ô>Ð>Ð]aˆŒØ03°•3�s˜DœOÑ,Ô,Ð,ÀTˆŒØMZÐMf�\¨-¸¼ÑIÔIÐIÐlpˆÔØ9>Ð9J•X˜e T¤_Ñ5Ô5Ð5ÐPTˆŒ
Ø#Ð/�U�UÀDÐW[ÐlpÐ5qÐ5qˆŒ
ØˆŒ
ØˆŒ	ØˆŒØ\ˆŒ
ˆ
ˆ
r    c                ó.   — |                       d|¦  «        S )a	  Return a Results object for a specific index of inference results.

        Args:
            idx (int | slice): Index or slice to retrieve from the Results object.

        Returns:
            (Results): A new Results object containing the specified subset of inference results.

        Examples:
            >>> results = model("path/to/image.jpg")  # Perform inference
            >>> single_result = results[0]  # Get the first result
            >>> subset_results = results[1:4]  # Get a slice of results
        r9   ©Ú_applyr7   s     r   r9   zResults.__getitem__*  s   € ð �{Š{˜=¨#Ñ.Ô.Ð.r    r2   c                ó`   — | j         D ]%}t          | |¦  «        }|�t          |¦  «        c S Œ&dS )a´  Return the number of results in the Results object.

        Returns:
            (int): The number of results, determined by the length of the first non-empty attribute in (boxes, masks,
                probs, keypoints, obb, semantic_mask, or depth). Empty Results objects return 0.

        Examples:
            >>> results = Results(orig_img, path, names, boxes=torch.rand(5, 6))
            >>> len(results)
            5
        Nr   )rj   Úgetattrr4   )r   ÚkÚvs      r   r5   zResults.__len__:  sB   € ð ”ð 	ð 	ˆAÝ˜˜aÑ Ô ˆAØˆ}Ý˜1‘v”v���ð àˆqr    c                ó¶  — |�2t          t          j        || j        ¦  «        | j        ¦  «        | _        |�t          || j        ¦  «        | _        |�t          |¦  «        | _        |�t          || j        ¦  «        | _
        |�t          || j        ¦  «        | _        |�t          || j        ¦  «        | _        |�t          || j        ¦  «        | _        dS dS )a=  Update the Results object with new detection data.

        This method allows updating the boxes, masks, keypoints, probabilities, and oriented bounding boxes (OBB) of
        the Results object. It ensures that boxes are clipped to the original image shape.

        Args:
            boxes (torch.Tensor | None): A tensor of shape (N, 6) containing bounding box coordinates and confidence
                scores. The format is (x1, y1, x2, y2, conf, class).
            masks (torch.Tensor | None): A tensor of shape (N, H, W) containing segmentation masks.
            probs (torch.Tensor | None): A tensor of shape (num_classes,) containing class probabilities.
            obb (torch.Tensor | None): A tensor of shape (N, 7) or (N, 8) containing oriented bounding box coordinates.
            keypoints (torch.Tensor | None): A tensor of shape (N, K, 3) containing keypoints, where K=17 for persons.
            semantic_mask (torch.Tensor | None): A tensor of shape (H, W) containing class IDs for semantic
                segmentation.
            depth (torch.Tensor | None): A tensor of shape (H, W) containing per-pixel depth values.

        Examples:
            >>> results = model("image.jpg")
            >>> new_boxes = torch.tensor([[100, 100, 200, 200, 0.9, 0]])
            >>> results[0].update(boxes=new_boxes)
        N)rd   r   Ú
clip_boxesr   rU   re   rW   rf   rX   rh   rZ   rg   rY   rI   r]   rL   r^   )r   rU   rW   rX   rZ   rY   r]   r^   s           r   ÚupdatezResults.updateL  sÇ   € ð> ÐÝ�sœ~¨e°T´_ÑEÔEÀtÄÑWÔWˆDŒJØÐÝ˜u d¤oÑ6Ô6ˆDŒJØÐÝ˜u™œˆDŒJØˆ?Ý˜3 ¤Ñ0Ô0ˆDŒHØÐ Ý& y°$´/ÑBÔBˆDŒNØÐ$Ý!-¨m¸T¼_Ñ!MÔ!MˆDÔØÐÝ! %¨¬Ñ9Ô9ˆDŒJˆJˆJð Ðr    Úfnc           
     ó²   — |                       ¦   «         }| j        D ]:}t          | |¦  «        }|€Œt          || t          ||¦  «        |i |¤Ž¦  «         Œ;|S )aì  Apply a function to all non-empty attributes and return a new Results object with modified attributes.

        This method is internally called by methods like .to(), .cuda(), .cpu(), etc.

        Args:
            fn (str): The name of the function to apply.
            *args (Any): Variable length argument list to pass to the function.
            **kwargs (Any): Arbitrary keyword arguments to pass to the function.

        Returns:
            (Results): A new Results object with attributes modified by the applied function.

        Examples:
            >>> results = model("path/to/image.jpg")
            >>> for result in results:
            ...     result_cuda = result.cuda()
            ...     result_cpu = result.cpu()
        )Únewrj   ro   Úsetattr)r   ru   r0   r1   Úrrp   rq   s          r   rm   zResults._applyz  sj   € ð& �HŠH‰JŒJˆØ”ð 	;ð 	;ˆAÝ˜˜aÑ Ô ˆAØˆyØÝ�A�q˜.�' ! R™.œ.¨$Ð9°&Ð9Ð9Ñ:Ô:Ð:Ð:Øˆr    c                ó,   — |                       d¦  «        S )a‹  Return a copy of the Results object with all its tensors moved to CPU memory.

        This method creates a new Results object with all tensor attributes (boxes, masks, probs, keypoints, obb)
        transferred to CPU memory. It's useful for moving data from GPU to CPU for further processing or saving.

        Returns:
            (Results): A new Results object with all tensor attributes on CPU memory.

        Examples:
            >>> results = model("path/to/image.jpg")  # Perform inference
            >>> cpu_result = results[0].cpu()  # Move the first result to CPU
            >>> print(cpu_result.boxes.device)  # Output: cpu
        r'   rl   r$   s    r   r'   zResults.cpu•  s   € ð �{Š{˜5Ñ!Ô!Ð!r    c                ó,   — |                       d¦  «        S )aR  Convert all tensors in the Results object to numpy arrays.

        Returns:
            (Results): A new Results object with all tensors converted to numpy arrays.

        Examples:
            >>> results = model("path/to/image.jpg")
            >>> numpy_result = results[0].numpy()
            >>> type(numpy_result.boxes.data)
            <class 'numpy.ndarray'>

        Notes:
            This method creates a new Results object, leaving the original unchanged. It's useful for
            interoperability with numpy-based libraries or when CPU-based operations are required.
        r)   rl   r$   s    r   r)   zResults.numpy¥  s   € ð  �{Š{˜7Ñ#Ô#Ð#r    c                ó,   — |                       d¦  «        S )aª  Move all tensors in the Results object to GPU memory.

        Returns:
            (Results): A new Results object with all tensors moved to CUDA device.

        Examples:
            >>> results = model("path/to/image.jpg")
            >>> cuda_results = results[0].cuda()  # Move first result to GPU
            >>> for result in results:
            ...     result_cuda = result.cuda()  # Move each result to GPU
        r,   rl   r$   s    r   r,   zResults.cuda·  s   € ð �{Š{˜6Ñ"Ô"Ð"r    c                ó$   —  | j         dg|¢R i |¤ŽS )aß  Move all tensors in the Results object to the specified device and dtype.

        Args:
            *args (Any): Variable length argument list to be passed to torch.Tensor.to().
            **kwargs (Any): Arbitrary keyword arguments to be passed to torch.Tensor.to().

        Returns:
            (Results): A new Results object with all tensors moved to the specified device and dtype.

        Examples:
            >>> results = model("path/to/image.jpg")
            >>> result_cuda = results[0].to("cuda")  # Move first result to GPU
            >>> result_cpu = results[0].to("cpu")  # Move first result to CPU
            >>> result_half = results[0].to(dtype=torch.float16)  # Convert first result to half precision
        r.   rl   r/   s      r   r.   z
Results.toÅ  s&   € ð  ˆtŒ{˜4Ð1 $Ð1Ð1Ð1¨&Ð1Ð1Ð1r    c                ól   — t          | j        | j        | j        | j        ¬¦  «        }| j        |_        |S )aS  Create a new Results object with the same image, path, names, speed, and save directory attributes.

        Returns:
            (Results): A new Results object with copied attributes from the original instance.

        Examples:
            >>> results = model("path/to/image.jpg")
            >>> new_result = results[0].new()
        )rO   rQ   rS   r[   )rN   rO   rQ   rS   r[   ri   )r   Úresults     r   rw   zResults.new×  s2   € õ  $¤-°d´iÀtÄzÐY]ÔYcÐdÑdÔdˆØœ-ˆŒØˆr    Tú	Arial.ttfFé   Úclass©éÿ   r„   r„   ÚconfÚboolÚ
line_widthúfloat | NoneÚ	font_sizeÚfontÚpilÚimgú np.ndarray | torch.Tensor | NoneÚ
kpt_radiusÚkpt_lineÚlabelsÚshowÚsaveÚfilenameú
str | NoneÚ
color_modeÚ	txt_colorútuple[int, int, int]c                ó\
  ‡(‡)— |dv sJ d|› d�¦   «         ‚|€žt          | j        t          j        ¦  «        r| j        d                              ¦   «                              ddd¦  «                             ¦   «         dz                       ¦   «                              ¦   «          	                    ¦   «         }| j
        Š(| j        du}|r| j        n| j        |
}}| j        |}}| j        |cŠ)}|�|s|r|r|                     ¦   «         }t          t!          |€| j        n|¦  «        ||||p‰)duo|‰(¬	¦  «        }|rŠ|rˆt          j        |j        ¦  «        }|r|j        r|d
k    r|j        n7|r|dk    r|j        n(t-          t/          t1          |¦  «        ¦  «        ¦  «        }|                     |d„ |D ¦   «         ¬¦  «         |��5|�r2|r|j        n|j        }t7          t9          t-          |¦  «        t-          |¦  «        ¦  «        ¦  «        D ]ê\  }\  }}t;          |j                             ¦   «         ¦  «        }|r&t?          |j                              ¦   «         ¦  «        nd|j        r&t;          |j                             ¦   «         ¦  «        nd}!} |!€dnd|!› d�‰(|         z   }"|	r|r|"› d| d›�n	|"n|r| d›nd}#| !                    ||#tE          |dk    r|n|!�|!n	|d
k    r|ndd¦  «        ¬¦  «         Œë‰)�a|r_d #                    ˆ(ˆ)fd„‰)j$        D ¦   «         ¦  «        }$tK          | j&        d         dz  ¦  «        }%| '                    |%|%g|$|d¬¦  «         | j(        re|rc| j(        j        }&t          |&t          j        ¦  «        r&|&                     ¦   «          	                    ¦   «         }&| (                    |&d¬¦  «         | j)        rm|rk| j)        j        }tU          |d¦  «        r&|                     ¦   «          	                    ¦   «         ntW          j,        |¦  «        }| -                    |¦  «         | j.        �…t7          t-          | j.                             ¦   «          	                    ¦   «         j        ¦  «        ¦  «        D ]:\  }}'| /                    |'| j&        |||d
k    rtE          |d¦  «        nd¬¦  «         Œ;|r| 0                    | j1        ¦  «         |r1| 2                    |pdtg          | j1        ¦  «        j4        › �¦  «         | 5                    |¦  «        S )a–  Plot detection results on an input BGR image.

        Args:
            conf (bool): Whether to plot detection confidence scores.
            line_width (float | None): Line width of bounding boxes. If None, scaled to image size.
            font_size (float | None): Font size for text. If None, scaled to image size.
            font (str): Font to use for text.
            pil (bool): Whether to return the image as a PIL Image.
            img (np.ndarray | torch.Tensor | None): Image to plot on. Tensor images must be contiguous HWC BGR uint8. If
                None, uses the original image.
            kpt_radius (int): Radius of drawn keypoints.
            kpt_line (bool): Whether to draw lines connecting keypoints.
            labels (bool): Whether to plot labels of bounding boxes.
            boxes (bool): Whether to plot bounding boxes.
            masks (bool): Whether to plot masks.
            probs (bool): Whether to plot classification probabilities.
            show (bool): Whether to display the annotated image.
            save (bool): Whether to save the annotated image.
            filename (str | None): Filename to save image if save is True.
            color_mode (str): Specify the color mode, e.g., 'instance' or 'class'.
            txt_color (tuple[int, int, int]): Text color in BGR format for classification output.

        Returns:
            (np.ndarray | PIL.Image.Image): Annotated image as a NumPy array (BGR) or PIL image (RGB) if `pil=True`.

        Examples:
            >>> results = model("image.jpg")
            >>> for result in results:
            ...     im = result.plot(pil=True)
            ...     im.show()
        >   r‚   Úinstancez/Expected color_mode='instance' or 'class', not ú.Nr   é   r`   r„   )Úexampler™   r‚   c                ó.   — g | ]}t          |d ¦  «        ‘ŒS )T©r   )Ú.0Úxs     r   ú
<listcomp>z Results.plot.<locals>.<listcomp>6  s    € Ð3QÐ3QÐ3QÈµF¸1¸d±O´OÐ3QÐ3QÐ3Qr    rž   Ú zid:ú ú.2fT)Úcolorú
c              3  óR   •K  — | ]!}‰r‰|         n|› d ‰j         |         d›�V — Œ"dS ©r£   r¤   N©r   )rŸ   ÚjrS   Ú
pred_probss     €€r   ú	<genexpr>zResults.plot.<locals>.<genexpr>Q  sI   øè è € ÐmÐmÐXY¨EÐ 8  a¤ °qÐSÐS¸:¼?È1Ô;MÐSÐSÐSÐmÐmÐmÐmÐmÐmr    g¸…ëQ¸ž?)é@   r­   r­   é€   )r–   Ú	box_colorg      à?)Úalphar'   )Úradiusr�   Ú	kpt_colorÚresults_)6r   rO   r   r   ÚdetachÚpermuteÚ
contiguousÚbyter'   r)   rS   rZ   rU   rW   rX   r   r   r+   r   Úis_trackÚidÚclsÚreversedÚranger4   ÚxyxyxyxyÚxyxyÚ	enumerateÚzipr2   ÚitemÚfloatr…   Ú	box_labelr   ÚjoinÚtop5Úroundr   Útextr]   r^   Úhasattrr   ÚasarrayÚ	depth_maprY   Úkptsr‘   rQ   r’   r   Únamer   )*r   r…   r‡   r‰   rŠ   r‹   rŒ   rŽ   r�   r�   rU   rW   rX   r‘   r’   r“   r•   r–   Úis_obbÚ
pred_boxesÚ
show_boxesÚ
pred_masksÚ
show_masksÚ
show_probsÚ	annotatorÚpred_mask_datar8   ÚcoordsÚiÚdÚboxÚcÚd_confr¹   rÌ   ÚlabelrÇ   r    Úsem_maskrp   rS   r«   s*                                           @@r   ÚplotzResults.plotå  s±  øø€ ðf Ð2Ð2Ð2Ð2Ð4sÐfpÐ4sÐ4sÐ4sÑ2Ô2Ð2Øˆ;�: d¤mµU´\ÑBÔBˆ;Ø”= Ô#×*Ò*Ñ,Ô,×4Ò4°Q¸¸1Ñ=Ô=×HÒHÑJÔJÈSÑP×VÒVÑXÔX×\Ò\Ñ^Ô^×dÒdÑfÔfˆCà”
ˆØ” Ð%ˆØ-3Ð!C ¤ ¸¼ÀU�Jˆ
Ø!%¤¨U�Jˆ
Ø!%¤¨UÐˆ
�JØÐ! zÐ!°jÐ!ÀZÐ!Ø#ŸšÑ)Ô)ˆJÝÝ c k�T”]�]°sÑ;Ô;ØØØØÐ:�J dÐ*Ð9¨zØð
ñ 
ô 
ˆ	ð ð 		S˜*ð 		SÝ"œ_¨Z¬_Ñ=Ô=ˆNð ð6Ø",Ô"5ð6Ø:DÈ
Ò:RÐ:Rð ”�ð ð6Ø",°Ò"7Ð"7ð  ”^�^å�e¥C¨
¡O¤OÑ4Ô4Ñ5Ô5ð ð �OŠO˜NÐ3QÐ3QÈSÐ3QÑ3QÔ3QˆOÑRÔRÐRð Ñ! jÑ!Ø,2ÐG�ZÔ(Ð(¸
¼ˆFÝ(­­X°jÑ-AÔ-AÅ8ÈFÑCSÔCSÑ)TÔ)TÑUÔUð ð ‘�‘8�A�sÝ˜œŸ
š
™œÑ%Ô%�Ø59ÐC�U 1¤6§;¢;¡=¤=Ñ1Ô1Ð1¸tÐYZÔYcÐEmÅSÈÌÏÊÉÌÑEUÔEUÐEUÐim˜�Ø ˜j˜˜¨k°B¨k¨k¨k¸UÀ1¼XÑE�ØFLÐu°4ÐA˜DÐ/Ð/ 6Ð/Ð/Ð/Ð/¸T¸TÐfjÐStÐV\ÐSbÐSbÐSbÐpt�Ø×#Ò#ØØÝ à%¨Ò0Ð0ð ˜ð ˜>ð  ˜Rð &¨Ò3Ð3ð ˜Qà!Øñ	ô 	ð $ñ ô ð ð ð  Ð! jÐ!Ø—9’9ÐmÐmÐmÐmÐmÐ]gÔ]lÐmÑmÔmÑmÔmˆDÝ�d”o aÔ(¨4Ñ/Ñ0Ô0ˆAØ�NŠN˜A˜q˜6 4°9ÐHYˆNÑZÔZÐZð Ôð 	9 *ð 	9ØÔ)Ô.ˆHÝ˜(¥E¤LÑ1Ô1ð 2Ø#Ÿ<š<™>œ>×/Ò/Ñ1Ô1�Ø×#Ò# H°CÐ#Ñ8Ô8Ð8ð Œ:ð 	#˜*ð 	#Ø”
”ˆAÝ#*¨1¨eÑ#4Ô#4ÐG�—’‘”—’‘”�½"¼*ÀQ¹-¼-ˆAØ×Ò Ñ"Ô"Ð"ð Œ>Ð%Ý!¥(¨4¬>×+=Ò+=Ñ+?Ô+?×+EÒ+EÑ+GÔ+GÔ+LÑ"MÔ"MÑNÔNð ð ‘��1Ø—’ØØ”OØ%Ø%Ø1;¸zÒ1IÐ1I�f Q¨™oœo˜oÈtð ñ ô ð ð ð ð 	&Ø�NŠN˜4œ9Ñ%Ô%Ð%ð ð 	JØ�NŠN˜8ÐHÐ'Hµ$°t´y±/´/Ô2FÐ'HÐ'HÑIÔIÐIà×Ò Ñ$Ô$Ð$r    c                ó$   —  | j         |ddi|¤Ž dS )a�  Display the image with annotated inference results.

        This method plots the detection results on the original image and displays it. It's a convenient way to
        visualize the model's predictions directly.

        Args:
            *args (Any): Variable length argument list to be passed to the `plot()` method.
            **kwargs (Any): Arbitrary keyword arguments to be passed to the `plot()` method.

        Examples:
            >>> results = model("path/to/image.jpg")
            >>> results[0].show()  # Display the first result
            >>> for result in results:
            ...     result.show()  # Display all results
        r‘   TN)rÝ   r/   s      r   r‘   zResults.showw  s&   € ð  	ˆŒ	�4Ð-˜dÐ- fÐ-Ð-Ð-Ð-Ð-r    c                óØ   — |sdt          | j        ¦  «        j        › �}t          |¦  «                             ¦   «         j                             dd¬¦  «          | j        |d|dœ|¤Ž |S )a¬  Save annotated inference results image to file.

        This method plots the detection results on the original image and saves the annotated image to a file. It
        utilizes the `plot` method to generate the annotated image and then saves it to the specified filename.

        Args:
            filename (str | None): The filename to save the annotated image. If None, a default filename is generated
                based on the original image path.
            *args (Any): Variable length argument list to be passed to the `plot` method.
            **kwargs (Any): Arbitrary keyword arguments to be passed to the `plot` method.

        Returns:
            (str): The filename where the image was saved.

        Examples:
            >>> results = model("path/to/image.jpg")
            >>> for result in results:
            ...     result.save("annotated_image.jpg")
            >>> # Or with custom plot arguments
            >>> for result in results:
            ...     result.save("annotated_image.jpg", conf=False, line_width=2)
            >>> # Directory will be created automatically if it does not exist
            >>> result.save("path/to/annotated_image.jpg")
        r³   T©ÚparentsÚexist_ok)r’   r“   )r   rQ   rÌ   ÚabsoluteÚparentÚmkdirrÝ   )r   r“   r0   r1   s       r   r’   zResults.save‰  su   € ð2 ð 	9Ø8¥$ t¤y¡/¤/Ô"6Ð8Ð8ˆHÝˆX‰Œ×ÒÑ!Ô!Ô(×.Ò.°tÀdÐ.ÑKÔKÐKØˆŒ	�4˜d¨XÐ@Ð@¸Ð@Ð@Ð@Øˆr    c                óª  ‡ — ‰ j         �‰ j         n‰ j        }t          ‰ ¦  «        dk    r‰ j        �dndS ‰ j        �.d                     ˆ fd„‰ j        j        D ¦   «         ¦  «        › d�S |ret          j        |j        t          j	        ¬¦  «         
                    ¦   «         }d                     ˆ fd„t          |¦  «        D ¦   «         ¦  «        S ‰ j        �r‰ j        j        }||dk             }t          |¦  «        rId	t          |                     ¦   «         ¦  «        d
›dt          |                     ¦   «         ¦  «        d
›d�ndS ‰ j        �dS dS )az  Return a log string for each task in the results, detailing detection and classification outcomes.

        This method generates a human-readable string summarizing the detection and classification results. It includes
        the number of detections for each class and the top probabilities for classification tasks.

        Returns:
            (str): A formatted string containing a summary of the results. For detection tasks, it includes the number
                of detections per class. For classification tasks, it includes the top 5 class probabilities.

        Examples:
            >>> results = model("path/to/image.jpg")
            >>> for result in results:
            ...     print(result.verbose())
            2 persons, 1 car, 3 traffic lights,
            dog 0.92, cat 0.78, horse 0.64,

        Notes:
            - If there are no detections, the method returns "(no detections), " for detection tasks.
            - For classification tasks, it returns the top 5 class probabilities and their corresponding class names.
            - The returned string is comma-separated and ends with a comma and a space.
        Nr   r¢   z(no detections), ú, c              3  ó^   •K  — | ]'}‰j         |         › d ‰j        j        |         d›�V — Œ(dS r¨   )rS   rX   r   )rŸ   rª   r   s     €r   r¬   z"Results.verbose.<locals>.<genexpr>Â  sD   øè è € ÐeÐeÐPQ 4¤:¨a¤=Ð KÐ K°4´:´?À1Ô3EÐ KÐ KÐ KÐeÐeÐeÐeÐeÐer    )Údtypec              3  ób   •K  — | ])\  }}|d k    ¯|› d‰j         |         › d|dk    z  › d�V — Œ*dS )r   r£   Úsr›   rç   N)rS   )rŸ   rÖ   Únr   s      €r   r¬   z"Results.verbose.<locals>.<genexpr>Å  sW   øè è € ÐjÐjÁtÀqÈ!ÐdeÐhiÒdiÐdi˜aÐBÐB $¤*¨Q¤-ÐB°¸¸Aº±ÐBÐBÐBÐdiÐdiÐdiÐdiÐjÐjr    zdepth r¤   ú-zm, zdepth (no valid pixels), )rZ   rU   r4   rX   rÄ   rÅ   r   r+   rº   Úint64Úbincountr¿   r^   r   rÂ   ÚminÚmaxr]   )r   rU   Úcountsr×   s   `   r   ÚverbosezResults.verbose¨  sX  ø€ ð, !œHÐ0�”�°d´jˆÝˆt‰9Œ9˜Š>ˆ>ØœÐ/�2�2Ð5HÐHØŒ:Ð!Ø—i’iÐeÐeÐeÐeÐUYÔU_ÔUdÐeÑeÔeÑeÔeÐiÐiÐiÐiØð 	kÝ”_ U¤Yµe´kÐBÑBÔB×KÒKÑMÔMˆFØ—7’7ÐjÐjÐjÐjÍyÐY_ÑO`ÔO`ÐjÑjÔjÑjÔjÐjØŒ:Ð!Ø”
”ˆAØ�!�a’%”ˆAÝLOÐPQÉFÌFÐsÐH�E !§%¢%¡'¤'™NœNÐHÐHÐHµ°q·u²u±w´w±´ÐHÐHÐHÐHÐHÐXsÐsØÔÐ)Ø�2ð *Ð)r    Útxt_fileú
str | PathÚ	save_confc                ó€  ‡ ‡‡— ‰ j         �#t          j        d¦  «         t          |¦  «        S ‰ j        du}|r‰ j        n‰ j        }‰ j        }‰ j        Š‰ j        }g Š‰�ˆˆ ˆfd„‰j	        D ¦   «          �nF|�rC| 
                    ¦   «         }|r|j        n|j                             t          |¦  «        d¦  «                             ¦   «         }|��| 
                    ¦   «         }|j        }|j        rFt%          j        t%          j        |¦  «        t%          j        |j        ¦  «        d         fd¦  «        }|                     t          |¦  «        d¦  «                             ¦   «         }|r|j        nd}	t-          |¦  «        D �]1\  }
}t/          |j                             ¦   «         ¦  «        t5          |j                             ¦   «         ¦  «        |j        r&t/          |j                             ¦   «         ¦  «        nd}}}|g||
         ¢R }|	�G|	|
         }t          |¦  «        dk     rŒ«|g|                     ¦   «                              d¦  «        ¢R }|�|g ||
         ¢R z  }||f|z  |€dn|fz   z  }‰                     d	t          |¦  «        z                       ¦   «         |z  ¦  «         �Œ3‰rrtA          |¦  «        j!         "                    d
d
¬¦  «         tG          |dd¬¦  «        5 }| $                    d„ ‰D ¦   «         ¦  «         ddd¦  «         n# 1 swxY w Y   t          |¦  «        S )a„  Save detection results to a text file.

        Args:
            txt_file (str | Path): Path to the output text file.
            save_conf (bool): Whether to include confidence scores in the output.

        Returns:
            (str): Path to the saved text file.

        Examples:
            >>> from ultralytics import YOLO
            >>> model = YOLO("yolo26n.pt")
            >>> results = model("path/to/image.jpg")
            >>> for result in results:
            ...     result.save_txt("output.txt")

        Notes:
            - The file will contain one line per detection or classification with the following structure:
              - For detections: `class x_center y_center width height [confidence] [track_id]`
              - For classifications: `confidence class_name`
              - For masks and keypoints, the specific formats will vary accordingly.
            - A detection whose mask contour has fewer than 3 points is omitted, since a shorter row is not a
              polygon, and no file is written when no line remains.
            - The function will create the output directory if it does not exist.
            - If save_conf is False, the confidence scores will be excluded from the output.
            - Existing contents of the file will not be overwritten; new results will be appended.
            - This method does not support Semantic Segmentation tasks.
        Nz7Semantic Segmentation task does not support `save_txt`.c                ór   •— g | ]3}‰                      ‰j        |         d ›d‰j        |         › �¦  «        ‘Œ4S )r¤   r£   )Úappendr   rS   )rŸ   rª   rX   r   Útextss     €€€r   r¡   z$Results.save_txt.<locals>.<listcomp>õ  sB   ø€ ÐVÐVÐVÀaˆU�\Š\˜UœZ¨œ]Ð@Ð@Ð@°´¸A´Ð@Ð@ÑAÔAÐVÐVÐVr    éÿÿÿÿ).Nr`   é   r@   z%g Trà   Úazutf-8)Úencodingc              3  ó    K  — | ]	}|d z   V — Œ
dS )r¦   Nr@   )rŸ   rÇ   s     r   r¬   z#Results.save_txt.<locals>.<genexpr>  s&   è è € Ð;Ð;¨T˜T D™[Ð;Ð;Ð;Ð;Ð;Ð;r    )%r]   r   ÚwarningrR   rZ   rU   rW   rX   rY   rÅ   r'   Ú	xyxyxyxynÚxywhnÚreshaper4   ÚtolistÚxynÚhas_visibler   Úcatr+   r…   r¿   r2   rº   rÁ   rÂ   r¸   r¹   Úcopyrù   Úrstripr   rä   rå   ÚopenÚ
writelines)r   rô   rö   rÍ   rU   rW   rË   rÕ   rY   Úsegmentsrª   r×   rÙ   r…   r¹   ÚlineÚsegÚfrX   rú   s   `                 @@r   Úsave_txtzResults.save_txtÍ  sb  øøø€ ð: ÔÐ)ÝŒNÐTÑUÔUÐUÝ�x‘=”=Ð Ø” Ð%ˆØ"Ð2�”�¨¬
ˆØ”
ˆØ”
ˆØŒ~ˆØˆØÐàVÐVÐVÐVÐVÐVÈ5Ì:ÐVÑVÔVÐVÑVØñ 	Bà—I’I‘K”KˆEØ)/Ð@�e”o�o°U´[×IÒIÍ#ÈeÉ*Ì*ÐVXÑYÔY×`Ò`ÑbÔbˆFØÐØ—x’x‘z”z�Ø œH�	ØÔ#ð rÝ %¤	­5¬?¸9Ñ+EÔ+EÅuÄÐW[ÔW`ÑGaÔGaÐbkÔGlÐ*mÐopÑ qÔ q�IØ%×-Ò-­c°$©i¬i¸Ñ<Ô<×CÒCÑEÔE�	Ø$)Ð3�u”y�y¨tˆHÝ! %Ñ(Ô(ð Bñ B‘��1Ý! !¤%§*¢*¡,¤,Ñ/Ô/µ°q´v·{²{±}´}Ñ1EÔ1EÐ[\Ô[eÐGoÅsÈ1Ì4Ï9Ê9É;Ì;ÑGWÔGWÐGWÐko˜�4�Ø�˜F 1œI���ØÐ'Ø" 1œ+�CÝ˜3‘x”x !’|�|Ø ØÐ7 §¢¡
¤
× 2Ò 2°2Ñ 6Ô 6Ð7Ð7�DØÐ#ØÐ,˜i¨œlÐ,Ð,Ñ,�DØ˜˜ )Ñ+°R°Z¨r¨rÀbÀUÑKÑK�Ø—’˜e¥c¨$¡i¤iÑ/×7Ò7Ñ9Ô9¸DÑ@ÑAÔAÐAÑAàð 	<Ý�‰NŒNÔ!×'Ò'°¸tÐ'ÑDÔDÐDÝ�h ¨gÐ6Ñ6Ô6ð <¸!Ø—’Ð;Ð;°UÐ;Ñ;Ô;Ñ;Ô;Ð;ð<ð <ð <ñ <ô <ð <ð <ð <ð <ð <ð <øøøð <ð <ð <ð <õ �8‰}Œ}Ðs   Ë: L&Ì&L*Ì-L*zim.jpgri   Ú	file_namec                óH  — | j         �t          j        d¦  «         dS | j        �t          j        d¦  «         dS | j        �t          j        d¦  «         dS | j        �t          j        d¦  «         dS | j                             ¦   «         D ]“}t          |j	        | j
                             ¦   «         t          |¦  «        | j        t          |j                             ¦   «         ¦  «                 z  t          |¦  «                             d¦  «        z  d¬¦  «         Œ”dS )	a   Save cropped detection images to specified directory.

        This method saves cropped images of detected objects to a specified directory. Each crop is saved in a
        subdirectory named after the object's class, with the filename based on the input file_name.

        Args:
            save_dir (str | Path): Directory path where cropped images will be saved.
            file_name (str | Path): Base filename for the saved cropped images.

        Examples:
            >>> results = model("path/to/image.jpg")
            >>> for result in results:
            ...     result.save_crop(save_dir="path/to/crops", file_name="detection")

        Notes:
            - This method does not support Classify, Oriented Bounding Box (OBB), or Semantic Segmentation tasks.
            - Crops are saved as 'save_dir/class_name/file_name.jpg'.
            - The method will create necessary subdirectories if they don't exist.
            - Original image is copied before cropping to avoid modifying the original.
        Nz+Classify task does not support `save_crop`.z&OBB task does not support `save_crop`.z8Semantic Segmentation task does not support `save_crop`.z(Depth task does not support `save_crop`.z.jpgT)ÚfileÚBGR)rX   r   r   rZ   r]   r^   rU   r'   r   r¾   rO   r  r   rS   r2   rº   rÁ   Úwith_suffix)r   ri   r  r×   s       r   Ú	save_cropzResults.save_crop  s  € ð* Œ:Ð!ÝŒNÐHÑIÔIÐIØˆFØŒ8ÐÝŒNÐCÑDÔDÐDØˆFØÔÐ)ÝŒNÐUÑVÔVÐVØˆFØŒ:Ð!ÝŒNÐEÑFÔFÐFØˆFØ”—’Ñ!Ô!ð 	ð 	ˆAÝØ”Ø”×"Ò"Ñ$Ô$Ý˜(‘^”^ d¤jµ°Q´U·Z²Z±\´\Ñ1BÔ1BÔ&CÑCÅdÈ9ÁoÄo×FaÒFaÐbhÑFiÔFiÑiØð	ñ ô ð ð ð	ð 	r    Ú	normalizeÚdecimalsúlist[dict[str, Any]]c           	     óæ
  — g }| j         �t          | j         j        | j         j                             ¦   «         ¦  «        D ]F\  }}t          |¦  «        }|                     | j        |         |t          ||¦  «        dœ¦  «         ŒG|S | j	        ��	| j	        j
        }t          |t          j        ¦  «        r&|                     ¦   «                              ¦   «         }t!          j        |d¬¦  «        \  }}|j        }	t          |                     ¦   «         |                     ¦   «         ¦  «        D ]f\  }}
t'          | j        ¦  «        dk    r
|dk    rŒ$d}n
|| j        vrŒ1|                     | j        |         |t          |
|	z  |¦  «        dœ¦  «         Œg|S | j        �|S | j        du}|r| j        n| j        }|rX|                     ¦   «         }|r|j        n|j                             t'          |¦  «        dd	¦  «                             ¦   «         }| j        }|�|                     ¦   «         }|r| j        nd
\  }}t9          |¦  «        D �]\  }}t          |j                             ¦   «         ¦  «        t          |j                             ¦   «         |¦  «        }}||         }i }t9          |¦  «        D ]I\  }}t          |d         |z  |¦  «        |d|dz   › �<   t          |d         |z  |¦  «        |d|dz   › �<   ŒJ| j        |         |||dœ}|j         r)t          |j!                             ¦   «         ¦  «        |d<   | j"        r¼| j"        j#        |         dd…df         |z   $                    tJ          ¦  «                             |¦  «                             ¦   «         | j"        j#        |         dd…df         |z   $                    tJ          ¦  «                             |¦  «                             ¦   «         dœ|d<   |��L||         }|j
        d         }t          |t          j        ¦  «        r&|                     ¦   «                              ¦   «         n|}|dd…df         |z   $                    tJ          ¦  «                             |¦  «                             ¦   «         |dd…df         |z   $                    tJ          ¦  «                             |¦  «                             ¦   «         dœ|d<   |j&        rR|dd…d	f          $                    tJ          ¦  «                             |¦  «                             ¦   «         |d         d<   |                     |¦  «         �Œ!|S )a±  Convert inference results to a summarized dictionary with optional normalization for box coordinates.

        This method creates a list of detection dictionaries, each containing information about a single detection or
        classification result. For classification tasks, it returns the top 5 classes and their
        confidences. For detection tasks, it includes class information, bounding box coordinates, and
        optionally mask segments and keypoints.

        Args:
            normalize (bool): Whether to normalize bounding box coordinates by image dimensions.
            decimals (int): Number of decimal places to round the output values to.

        Returns:
            (list[dict[str, Any]]): A list of dictionaries, each containing summarized information for a single
                detection or classification result. The structure of each dictionary varies based on the task type
                (classification or detection) and available information (boxes, masks, keypoints).

        Examples:
            >>> results = model("image.jpg")
            >>> for result in results:
            ...     summary = result.summary()
            ...     print(summary)
        N)rÌ   r‚   Ú
confidenceT)Úreturn_countsr›   r   )rÌ   r‚   Úpixel_ratiorû   r`   )r›   r›   r    Úy)rÌ   r‚   r  rØ   Útrack_id)r    r  r  rY   Úvisible)'rX   rÀ   rÅ   Útop5confr  r2   rù   rS   rÆ   r]   r   r   r   r   r'   r)   r   ÚuniquerE   r4   r^   rZ   rU   r½   r¾   r  rY   r   r¿   rº   rÁ   r…   r¸   r¹   rW   ÚxyÚastyperÂ   r  )r   r  r  ÚresultsÚclass_idr…   Úmaskr"  rò   ÚtotalÚcountrÍ   r   rÕ   rË   ÚhÚwrÖ   ÚrowrØ   r#  rª   Úbr   Úkptrp   s                             r   ÚsummaryzResults.summary>  s   € ð0 ˆØŒ:Ð!å"% d¤j¤o°t´zÔ7J×7QÒ7QÑ7SÔ7SÑ"TÔ"Tð ð ‘�˜$Ý˜x™=œ=�Ø—’à $¤
¨8Ô 4Ø!)Ý&+¨D°(Ñ&;Ô&;ðð ñô ð ð ð ˆNàÔÑ)àÔ%Ô*ˆDÝ˜$¥¤Ñ-Ô-ð *Ø—x’x‘z”z×'Ò'Ñ)Ô)�ÝœY t¸4Ð@Ñ@Ô@‰NˆF�FØ”IˆEÝ#& v§}¢}¡¤¸¿º¹¼Ñ#HÔ#Hð ð ‘�˜%Ý�t”z‘?”? aÒ'Ð'Ø 1’}�}Ø Ø �H�HØ T¤ZÐ/Ð/ØØ—’à $¤
¨8Ô 4Ø!)Ý',¨U°U©]¸HÑ'EÔ'Eðð ñô ð ð ð ˆNàŒ:Ð!àˆNà” Ð%ˆØ!Ð1ˆtŒxˆx t¤zˆØð 	aØ—8’8‘:”:ˆDØ'-Ð<�d”m�m°4´9×EÒEÅcÈ$ÁiÄiÐQSÐUVÑWÔW×^Ò^Ñ`Ô`ˆFØŒ~ˆØÐØ—8’8‘:”:ˆDØ"+Ð7ˆtŒˆ°‰ˆˆ1Ý ‘o”oð 	#ñ 	#‰FˆAˆsÝ  ¤§¢¡¤Ñ0Ô0µ%¸¼¿º¹¼ÈÑ2RÔ2R�dˆHØ˜”)ˆCØˆBÝ! #™œð <ð <‘��1Ý"'¨¨!¬¨q©°(Ñ";Ô";��;�q˜1‘u�;�;‘Ý"'¨¨!¬¨q©°(Ñ";Ô";��;�q˜1‘u�;�;‘�Ø"œj¨Ô2¸XÐUYÐbdÐeÐeˆFØŒ}ð 8Ý%(¨¬¯ª©¬Ñ%7Ô%7��zÑ"ØŒzð àœ*œ-¨Ô*¨1¨1¨1¨a¨4Ô0°1Ñ4×<Ò<½UÑCÔC×IÒIÈ(ÑSÔS×ZÒZÑ\Ô\Øœ*œ-¨Ô*¨1¨1¨1¨a¨4Ô0°1Ñ4×<Ò<½UÑCÔC×IÒIÈ(ÑSÔS×ZÒZÑ\Ô\ð&ð &��zÑ"ð ÑØ˜1”g�Ø”H˜Q”K�Ý'1°!µU´\Ñ'BÔ'BÐI�A—E’E‘G”G—M’M‘O”O�OÈ�à˜A˜A˜A˜q˜Dœ' A™+×-Ò-­eÑ4Ô4×:Ò:¸8ÑDÔD×KÒKÑMÔMØ˜A˜A˜A˜q˜Dœ' A™+×-Ò-­eÑ4Ô4×:Ò:¸8ÑDÔD×KÒKÑMÔMð'ð '��{Ñ#ð ”?ð dØ56°q°q°q¸!°t´W·^²^ÅEÑ5JÔ5J×5PÒ5PÐQYÑ5ZÔ5Z×5aÒ5aÑ5cÔ5c�F˜;Ô'¨	Ñ2Ø�NŠN˜6Ñ"Ô"Ð"Ñ"àˆr    )NNNNNNNN)rO   rP   rQ   rR   rS   rT   rU   rV   rW   rV   rX   rV   rY   rV   rZ   rV   r[   r\   r]   rV   r^   rV   r   r   r:   )NNNNNNN)rU   rV   rW   rV   rX   rV   rZ   rV   rY   rV   r]   rV   r^   rV   )ru   rR   )TNNr€   FNr�   TTTTTFFNr‚   rƒ   )$r…   r†   r‡   rˆ   r‰   rˆ   rŠ   rR   r‹   r†   rŒ   r�   rŽ   r2   r�   r†   r�   r†   rU   r†   rW   r†   rX   r†   r‘   r†   r’   r†   r“   r”   r•   rR   r–   r—   r   rP   ©N)r“   r”   r   rR   )r   rR   )F)rô   rõ   rö   r†   r   rR   )ri   rõ   r  rõ   )Fr�   )r  r†   r  r2   r   r  )r;   r<   r=   r>   r   r9   r5   rt   rm   r'   r)   r,   r.   rw   rÝ   r‘   r’   ró   r  r   r  r/  r@   r    r   rN   rN   Å   s  € € € € € ð/ð /ðl &*Ø%)Ø%)Ø)-Ø#'Ø)-Ø-1Ø%)ð1]ð 1]ð 1]ð 1]ð 1]ðf/ð /ð /ð ð ð ð ð( &*Ø%)Ø%)Ø#'Ø)-Ø-1Ø%)ð,:ð ,:ð ,:ð ,:ð ,:ð\ð ð ð ð6"ð "ð "ð $ð $ð $ð$#ð #ð #ð2ð 2ð 2ð$ð ð ð  Ø#'Ø"&ØØØ04ØØØØØØØØØ#Ø!Ø*9ð%P%ð P%ð P%ð P%ð P%ðd.ð .ð .ð$ð ð ð ð ð>#ð #ð #ð #ðJFð Fð Fð Fð FðP GKÀdÈ8ÁnÄnð 'ð 'ð 'ð 'ð 'ðReð eð eð eð eð eð er    rN   c                  óÌ   ‡ — e Zd ZdZdˆ fd„Zedd	„¦   «         Zedd
„¦   «         Zedd„¦   «         Zedd„¦   «         Z	e
dd„¦   «         Ze
dd„¦   «         Ze
dd„¦   «         Zˆ xZS )rd   a„  A class for managing and manipulating detection boxes.

    This class provides comprehensive functionality for handling detection boxes, including their coordinates,
    confidence scores, class labels, and optional tracking IDs. It supports various box formats and offers methods for
    easy manipulation and conversion between different coordinate systems.

    Attributes:
        data (torch.Tensor | np.ndarray): The raw tensor containing detection boxes and associated data.
        orig_shape (tuple[int, int]): The original image dimensions (height, width).
        is_track (bool): Indicates whether tracking IDs are included in the box data.
        xyxy (torch.Tensor | np.ndarray): Boxes in [x1, y1, x2, y2] format.
        conf (torch.Tensor | np.ndarray): Confidence scores for each box.
        cls (torch.Tensor | np.ndarray): Class labels for each box.
        id (torch.Tensor | None): Tracking IDs for each box (if available).
        xywh (torch.Tensor | np.ndarray): Boxes in [x, y, width, height] format.
        xyxyn (torch.Tensor | np.ndarray): Normalized [x1, y1, x2, y2] boxes relative to orig_shape.
        xywhn (torch.Tensor | np.ndarray): Normalized [x, y, width, height] boxes relative to orig_shape.

    Methods:
        cpu: Return a copy of the object with all tensors on CPU memory.
        numpy: Return a copy of the object with all tensors as numpy arrays.
        cuda: Return a copy of the object with all tensors on GPU memory.
        to: Return a copy of the object with tensors on specified device and dtype.

    Examples:
        >>> import torch
        >>> boxes_data = torch.tensor([[100, 50, 150, 100, 0.9, 0], [200, 150, 300, 250, 0.8, 1]])
        >>> orig_shape = (480, 640)  # height, width
        >>> boxes = Boxes(boxes_data, orig_shape)
        >>> print(boxes.xyxy)
        >>> print(boxes.conf)
        >>> print(boxes.cls)
        >>> print(boxes.xywhn)
    rU   r   r   r   r   r   c                óÚ   •— |j         dk    r|ddd…f         }|j        d         }|dv sJ d|› �¦   «         ‚t          ¦   «                              ||¦  «         |dk    | _        || _        dS )aØ  Initialize the Boxes class with detection box data and the original image shape.

        This class manages detection boxes, providing easy access and manipulation of box coordinates, confidence
        scores, class identifiers, and optional tracking IDs. It supports multiple formats for box coordinates,
        including both absolute and normalized forms.

        Args:
            boxes (torch.Tensor | np.ndarray): A tensor or numpy array with detection boxes of shape (num_boxes, 6) or
                (num_boxes, 7). Columns should contain [x1, y1, x2, y2, (optional) track_id, confidence, class].
            orig_shape (tuple[int, int]): The original image shape as (height, width). Used for normalization.
        r›   Nrû   >   é   é   zexpected 6 or 7 values but got r4  ©Úndimr#   Úsuperr   r¸   r   ©r   rU   r   rì   r&   s       €r   r   zBoxes.__init__Ê  sx   ø€ ð Œ:˜Š?ˆ?Ø˜$   ˜'”NˆEØŒK˜ŒOˆØ�Fˆ{ˆ{ˆ{ÐA¸aÐAÐA‰{Œ{ˆ{Ý‰Œ×Ò˜ 
Ñ+Ô+Ð+Ø˜QšˆŒØ$ˆŒˆˆr    c                ó(   — | j         dd…dd…f         S )a´  Return bounding boxes in [x1, y1, x2, y2] format.

        Returns:
            (torch.Tensor | np.ndarray): A tensor or numpy array of shape (n, 4) containing bounding box coordinates in
                [x1, y1, x2, y2] format, where n is the number of boxes.

        Examples:
            >>> results = model("image.jpg")
            >>> boxes = results[0].boxes
            >>> xyxy = boxes.xyxy
            >>> print(xyxy)
        Né   r©   r$   s    r   r¾   z
Boxes.xyxyÞ  s   € ð Œy˜˜˜˜B˜Q˜B˜ÔÐr    c                ó$   — | j         dd…df         S )aÞ  Return the confidence scores for each detection box.

        Returns:
            (torch.Tensor | np.ndarray): A 1D tensor or array containing confidence scores for each detection, with
                shape (N,) where N is the number of detections.

        Examples:
            >>> boxes = Boxes(torch.tensor([[10, 20, 30, 40, 0.9, 0]]), orig_shape=(100, 100))
            >>> conf_scores = boxes.conf
            >>> print(conf_scores)
            tensor([0.9000])
        Néþÿÿÿr©   r$   s    r   r…   z
Boxes.confî  ó   € ð Œy˜˜˜˜B˜ÔÐr    c                ó$   — | j         dd…df         S )aë  Return the class ID tensor representing category predictions for each bounding box.

        Returns:
            (torch.Tensor | np.ndarray): A tensor or numpy array containing the class IDs for each detection box. The
                shape is (N,), where N is the number of boxes.

        Examples:
            >>> results = model("image.jpg")
            >>> boxes = results[0].boxes
            >>> class_ids = boxes.cls
            >>> print(class_ids)  # tensor([0., 2., 1.])
        Nrû   r©   r$   s    r   rº   z	Boxes.clsþ  r=  r    ú torch.Tensor | np.ndarray | Nonec                ó6   — | j         r| j        dd…df         ndS )a¢  Return the tracking IDs for each detection box if available.

        Returns:
            (torch.Tensor | np.ndarray | None): A tensor or array containing tracking IDs for each box if tracking is
                enabled, otherwise None. Shape is (N,) where N is the number of boxes.

        Examples:
            >>> results = model.track("path/to/video.mp4")
            >>> for result in results:
            ...     boxes = result.boxes
            ...     if boxes.is_track:
            ...         track_ids = boxes.id
            ...         print(f"Tracking IDs: {track_ids}")
            ...     else:
            ...         print("Tracking is not enabled for these boxes.")

        Notes:
            - This property is only available when tracking is enabled (i.e., when `is_track` is True).
            - The tracking IDs are typically used to associate detections across multiple frames in video analysis.
        Néýÿÿÿ©r¸   r   r$   s    r   r¹   zBoxes.id  s%   € ð, $(¤=Ð:ˆtŒy˜˜˜˜B˜ÔÐ°dÐ:r    c                ó4   — t          j        | j        ¦  «        S )a£  Convert bounding boxes from [x1, y1, x2, y2] format to [x, y, width, height] format.

        Returns:
            (torch.Tensor | np.ndarray): Boxes in [x_center, y_center, width, height] format, where x_center, y_center
                are the coordinates of the center point of the bounding box, width, height are the dimensions of the
                bounding box and the shape of the returned tensor is (N, 4), where N is the number of boxes.

        Examples:
            >>> boxes = Boxes(
            ...     torch.tensor([[100, 50, 150, 100, 0.9, 0], [200, 150, 300, 250, 0.8, 1]]), orig_shape=(480, 640)
            ... )
            >>> xywh = boxes.xywh
        )r   Ú	xyxy2xywhr¾   r$   s    r   Úxywhz
Boxes.xywh&  s   € õ Œ}˜TœYÑ'Ô'Ð'r    c                ó$  — t          | j        t          j        ¦  «        r| j                             ¦   «         nt          j        | j        ¦  «        }|dddgfxx         | j        d         z  cc<   |dddgfxx         | j        d         z  cc<   |S )aç  Return normalized bounding box coordinates relative to the original image size.

        This property calculates and returns the bounding box coordinates in [x1, y1, x2, y2] format, normalized to the
        range [0, 1] based on the original image dimensions.

        Returns:
            (torch.Tensor | np.ndarray): Normalized bounding box coordinates with shape (N, 4), where N is the number of
                boxes. Each row contains [x1, y1, x2, y2] values normalized to [0, 1].

        Examples:
            >>> boxes = Boxes(torch.tensor([[100, 50, 300, 400, 0.9, 0]]), orig_shape=(480, 640))
            >>> normalized = boxes.xyxyn
            >>> print(normalized)
            tensor([[0.1562, 0.1042, 0.4688, 0.8333]])
        .r   r`   r›   rü   )r   r¾   r   r   Úcloner   r  r   )r   r¾   s     r   ÚxyxynzBoxes.xyxyn7  s–   € õ" %/¨t¬y½%¼,Ñ$GÔ$GÐ_ˆtŒy�ŠÑ Ô Ð ÍRÌWÐUYÔU^ÑM_ÔM_ˆØˆS�1�a�&ˆ[ÐÐÔ˜Tœ_¨QÔ/Ñ/ÐÐÑØˆS�1�a�&ˆ[ÐÐÔ˜Tœ_¨QÔ/Ñ/ÐÐÑØˆr    c                ó´   — t          j        | j        ¦  «        }|dddgfxx         | j        d         z  cc<   |dddgfxx         | j        d         z  cc<   |S )a4  Return normalized bounding boxes in [x, y, width, height] format.

        This property calculates and returns the normalized bounding box coordinates in the format [x_center, y_center,
        width, height], where all values are relative to the original image dimensions.

        Returns:
            (torch.Tensor | np.ndarray): Normalized bounding boxes with shape (N, 4), where N is the number of boxes.
                Each row contains [x_center, y_center, width, height] values normalized to [0, 1] based on the original
                image dimensions.

        Examples:
            >>> boxes = Boxes(torch.tensor([[100, 50, 150, 100, 0.9, 0]]), orig_shape=(480, 640))
            >>> normalized = boxes.xywhn
            >>> print(normalized)
            tensor([[0.1953, 0.1562, 0.0781, 0.1042]])
        .r   r`   r›   rü   )r   rD  r¾   r   )r   rE  s     r   r  zBoxes.xywhnM  sp   € õ$ Œ}˜TœYÑ'Ô'ˆØˆS�1�a�&ˆ[ÐÐÔ˜Tœ_¨QÔ/Ñ/ÐÐÑØˆS�1�a�&ˆ[ÐÐÔ˜Tœ_¨QÔ/Ñ/ÐÐÑØˆr    ©rU   r   r   r   r   r   ©r   r   ©r   r?  )r;   r<   r=   r>   r   r?   r¾   r…   rº   r¹   r   rE  rH  r  Ú__classcell__©r&   s   @r   rd   rd   ¦  s(  ø€ € € € € ð!ð !ðF%ð %ð %ð %ð %ð %ð( ð ð  ð  ñ „Xð ð ð ð  ð  ñ „Xð ð ð ð  ð  ñ „Xð ð ð;ð ;ð ;ñ „Xð;ð. ð(ð (ð (ñ „_ð(ð  ðð ð ñ „_ðð* ðð ð ñ „_ðð ð ð ð r    rd   c                  óT   ‡ — e Zd ZdZdˆ fd„Zedd
„¦   «         Zedd„¦   «         Zˆ xZS )re   a‚  A class for storing and manipulating detection masks.

    This class extends BaseTensor and provides functionality for handling segmentation masks, including methods for
    converting between pixel and normalized coordinates.

    Attributes:
        data (torch.Tensor | np.ndarray): The raw tensor or array containing mask data.
        orig_shape (tuple[int, int]): Original image shape in (height, width) format.
        xy (list[np.ndarray]): A list of segments in pixel coordinates.
        xyn (list[np.ndarray]): A list of normalized segments.

    Methods:
        cpu: Return a copy of the Masks object with the mask tensor on CPU memory.
        numpy: Return a copy of the Masks object with the mask tensor as a numpy array.
        cuda: Return a copy of the Masks object with the mask tensor on GPU memory.
        to: Return a copy of the Masks object with the mask tensor on specified device and dtype.

    Examples:
        >>> masks_data = torch.rand(1, 160, 160)
        >>> orig_shape = (720, 1280)
        >>> masks = Masks(masks_data, orig_shape)
        >>> pixel_coords = masks.xy
        >>> normalized_coords = masks.xyn
    rW   r   r   r   r   r   c                óz   •— |j         dk    r|ddd…f         }t          ¦   «                              ||¦  «         dS )a>  Initialize the Masks class with detection mask data and the original image shape.

        Args:
            masks (torch.Tensor | np.ndarray): Detection masks with shape (num_masks, height, width).
            orig_shape (tuple[int, int]): The original image shape as (height, width). Used for normalization.
        r`   N)r6  r7  r   )r   rW   r   r&   s      €r   r   zMasks.__init__  sA   ø€ ð Œ:˜Š?ˆ?Ø˜$   ˜'”NˆEÝ‰Œ×Ò˜ 
Ñ+Ô+Ð+Ð+Ð+r    úlist[np.ndarray]c                óN   ‡ — ˆ fd„t          j        ‰ j        ¦  «        D ¦   «         S )aù  Return normalized xy-coordinates of the segmentation masks.

        This property calculates and caches the normalized xy-coordinates of the segmentation masks. The coordinates are
        normalized relative to the original image shape.

        Returns:
            (list[np.ndarray]): A list of numpy arrays, where each array contains the normalized xy-coordinates of a
                single segmentation mask. Each array has shape (N, 2), where N is the number of points in the
                mask contour.

        Examples:
            >>> results = model("image.jpg")
            >>> masks = results[0].masks
            >>> normalized_coords = masks.xyn
            >>> print(normalized_coords[0])  # Normalized coordinates of the first mask
        c                ón   •— g | ]1}t          j        ‰j        j        d d…         |‰j        d¬¦  «        ‘Œ2S )r›   NT©r  ©r   Úscale_coordsr   r#   r   ©rŸ   r    r   s     €r   r¡   zMasks.xyn.<locals>.<listcomp>œ  sM   ø€ ð 
ð 
ð 
àõ Ô˜TœYœ_¨Q¨R¨RÔ0°!°T´_ÐPTÐUÑUÔUð
ð 
ð 
r    ©r   Úmasks2segmentsr   r$   s   `r   r  z	Masks.xynŠ  ó;   ø€ ð$
ð 
ð 
ð 
åÔ'¨¬	Ñ2Ô2ð
ñ 
ô 
ð 	
r    c                óN   ‡ — ˆ fd„t          j        ‰ j        ¦  «        D ¦   «         S )a*  Return the [x, y] pixel coordinates for each segment in the mask tensor.

        This property calculates and returns a list of pixel coordinates for each segmentation mask in the Masks object.
        The coordinates are scaled to match the original image dimensions.

        Returns:
            (list[np.ndarray]): A list of numpy arrays, where each array contains the [x, y] pixel coordinates for a
                single segmentation mask. Each array has shape (N, 2), where N is the number of points in the segment.

        Examples:
            >>> results = model("image.jpg")
            >>> masks = results[0].masks
            >>> xy_coords = masks.xy
            >>> print(len(xy_coords))  # Number of masks
            >>> print(xy_coords[0].shape)  # Shape of first mask's coordinates
        c                ón   •— g | ]1}t          j        ‰j        j        d d…         |‰j        d¬¦  «        ‘Œ2S )r›   NFrT  rU  rW  s     €r   r¡   zMasks.xy.<locals>.<listcomp>³  sM   ø€ ð 
ð 
ð 
àõ Ô˜TœYœ_¨Q¨R¨RÔ0°!°T´_ÐPUÐVÑVÔVð
ð 
ð 
r    rX  r$   s   `r   r#  zMasks.xy¡  rZ  r    )rW   r   r   r   r   r   )r   rQ  )	r;   r<   r=   r>   r   r   r  r#  rM  rN  s   @r   re   re   e  s‡   ø€ € € € € ðð ð2	,ð 	,ð 	,ð 	,ð 	,ð 	,ð ð
ð 
ð 
ñ „_ð
ð, ð
ð 
ð 
ñ „_ð
ð 
ð 
ð 
ð 
r    re   c                  ól   ‡ — e Zd ZdZdˆ fd„Zedd	„¦   «         Zedd
„¦   «         Zedd„¦   «         Zˆ xZ	S )rg   af  A class for storing and manipulating detection keypoints.

    This class encapsulates functionality for handling keypoint data, including coordinate manipulation, normalization,
    and confidence values. It supports keypoint detection results with optional visibility information.

    Attributes:
        data (torch.Tensor): The raw tensor containing keypoint data.
        orig_shape (tuple[int, int]): The original image dimensions (height, width).
        has_visible (bool): Indicates whether visibility information is available for keypoints.
        xy (torch.Tensor): Keypoint coordinates in [x, y] format.
        xyn (torch.Tensor): Normalized keypoint coordinates in [x, y] format, relative to orig_shape.
        conf (torch.Tensor | None): Confidence values for each keypoint, if available.

    Methods:
        cpu: Return a copy of the keypoints tensor on CPU memory.
        numpy: Return a copy of the keypoints tensor as a numpy array.
        cuda: Return a copy of the keypoints tensor on GPU memory.
        to: Return a copy of the keypoints tensor with specified device and dtype.

    Examples:
        >>> import torch
        >>> from ultralytics.engine.results import Keypoints
        >>> keypoints_data = torch.rand(1, 17, 3)  # 1 detection, 17 keypoints, (x, y, conf)
        >>> orig_shape = (480, 640)  # Original image shape (height, width)
        >>> keypoints = Keypoints(keypoints_data, orig_shape)
        >>> print(keypoints.xy.shape)  # Access xy coordinates
        >>> print(keypoints.conf)  # Access confidence values
        >>> keypoints_cpu = keypoints.cpu()  # Move keypoints to CPU
    rY   r   r   r   r   r   c                ó°   •— |j         dk    r|ddd…f         }t          ¦   «                              ||¦  «         | j        j        d         dk    | _        dS )aA  Initialize the Keypoints object with detection keypoints and original image dimensions.

        This method processes the input keypoints tensor, handling both 2D and 3D formats.

        Args:
            keypoints (torch.Tensor | np.ndarray): A tensor or array containing keypoint data. Shape can be either:
                - (num_objects, num_keypoints, 2) for x, y coordinates only
                - (num_objects, num_keypoints, 3) for x, y coordinates and confidence scores
            orig_shape (tuple[int, int]): The original image dimensions (height, width).
        r`   Nrû   rü   )r6  r7  r   r   r#   r  )r   rY   r   r&   s      €r   r   zKeypoints.__init__Ø  sZ   ø€ ð Œ>˜QÒÐØ! $¨¨¨ 'Ô*ˆIÝ‰Œ×Ò˜ JÑ/Ô/Ð/Øœ9œ?¨2Ô.°!Ò3ˆÔÐÐr    c                ó$   — | j         ddd…f         S )a  Return x, y coordinates of keypoints.

        Returns:
            (torch.Tensor | np.ndarray): A tensor or array containing the x, y coordinates of keypoints with shape (N,
                K, 2), where N is the number of detections and K is the number of keypoints per detection.

        Examples:
            >>> results = model("image.jpg")
            >>> keypoints = results[0].keypoints
            >>> xy = keypoints.xy
            >>> print(xy.shape)  # (N, K, 2)
            >>> print(xy[0])  # x, y coordinates of keypoints for first detection

        Notes:
            - The returned coordinates are in pixel units relative to the original image dimensions.
            - This property uses LRU caching to improve performance on repeated access.
        .Nr`   r©   r$   s    r   r#  zKeypoints.xyè  s   € ð& Œy˜˜b˜q˜b˜Ô!Ð!r    c                ó  — t          | j        t          j        ¦  «        r| j                             ¦   «         nt          j        | j        ¦  «        }|dxx         | j        d         z  cc<   |dxx         | j        d         z  cc<   |S )av  Return normalized coordinates (x, y) of keypoints relative to the original image size.

        Returns:
            (torch.Tensor | np.ndarray): A tensor or array of shape (N, K, 2) containing normalized keypoint
                coordinates, where N is the number of instances, K is the number of keypoints, and the last dimension
                contains [x, y] values in the range [0, 1].

        Examples:
            >>> keypoints = Keypoints(torch.rand(1, 17, 2), orig_shape=(480, 640))
            >>> normalized_kpts = keypoints.xyn
            >>> print(normalized_kpts.shape)
            torch.Size([1, 17, 2])
        ©.r   r›   ©.r›   r   )r   r#  r   r   rG  r   r  r   )r   r#  s     r   r  zKeypoints.xyný  su   € õ !+¨4¬7µE´LÑ AÔ AÐWˆTŒW�]Š]‰_Œ_ˆ_ÅrÄwÈtÌwÑGWÔGWˆØ
ˆ6ˆ
ˆ
Œ
�d”o aÔ(Ñ(ˆ
ˆ
‰
Ø
ˆ6ˆ
ˆ
Œ
�d”o aÔ(Ñ(ˆ
ˆ
‰
Øˆ	r    r?  c                ó.   — | j         r| j        d         ndS )a;  Return confidence values for each keypoint.

        Returns:
            (torch.Tensor | np.ndarray | None): A tensor or array containing confidence scores for each keypoint if
                available, otherwise None. Shape is (num_detections, num_keypoints) for batched data or (num_keypoints,)
                for single detection.

        Examples:
            >>> keypoints = Keypoints(torch.rand(1, 17, 3), orig_shape=(640, 640))  # 1 detection, 17 keypoints
            >>> conf = keypoints.conf
            >>> print(conf.shape)  # torch.Size([1, 17])
        ).r`   N)r  r   r$   s    r   r…   zKeypoints.conf  s   € ð %)Ô$4Ð>ˆtŒy˜Ô Ð ¸$Ð>r    )rY   r   r   r   r   r   rK  rL  )
r;   r<   r=   r>   r   r   r#  r  r…   rM  rN  s   @r   rg   rg   ¹  s§   ø€ € € € € ðð ð<4ð 4ð 4ð 4ð 4ð 4ð  ð"ð "ð "ñ „_ð"ð( ðð ð ñ „_ðð& ð?ð ?ð ?ñ „_ð?ð ?ð ?ð ?ð ?r    rg   c                  ó†   ‡ — e Zd ZdZddˆ fd	„Zedd„¦   «         Zedd„¦   «         Zedd„¦   «         Zedd„¦   «         Z	ˆ xZ
S )rf   aq  A class for storing and manipulating classification probabilities.

    This class extends BaseTensor and provides methods for accessing and manipulating classification probabilities,
    including top-1 and top-5 predictions.

    Attributes:
        data (torch.Tensor | np.ndarray): The raw tensor or array containing classification probabilities.
        orig_shape (tuple[int, int] | None): The original image shape as (height, width). Not used in this class.
        top1 (int): Index of the class with the highest probability.
        top5 (list[int]): Indices of the top 5 classes by probability.
        top1conf (torch.Tensor | np.ndarray): Confidence score of the top 1 class.
        top5conf (torch.Tensor | np.ndarray): Confidence scores of the top 5 classes.

    Methods:
        cpu: Return a copy of the probabilities tensor on CPU memory.
        numpy: Return a copy of the probabilities tensor as a numpy array.
        cuda: Return a copy of the probabilities tensor on GPU memory.
        to: Return a copy of the probabilities tensor with specified device and dtype.

    Examples:
        >>> probs = torch.tensor([0.1, 0.3, 0.6])
        >>> p = Probs(probs)
        >>> print(p.top1)
        2
        >>> print(p.top5)
        [2, 1, 0]
        >>> print(p.top1conf)
        tensor(0.6000)
        >>> print(p.top5conf)
        tensor([0.6000, 0.3000, 0.1000])
    NrX   r   r   útuple[int, int] | Noner   r   c                óL   •— t          ¦   «                              ||¦  «         dS )a   Initialize the Probs class with classification probabilities.

        This class stores and manages classification probabilities, providing easy access to top predictions and their
        confidences.

        Args:
            probs (torch.Tensor | np.ndarray): A 1D tensor or array of classification probabilities.
            orig_shape (tuple[int, int] | None): The original image shape as (height, width). Not used in this class but
                kept for consistency with other result classes.
        N)r7  r   )r   rX   r   r&   s      €r   r   zProbs.__init__C  s%   ø€ õ 	‰Œ×Ò˜ 
Ñ+Ô+Ð+Ð+Ð+r    r2   c                óN   — t          | j                             ¦   «         ¦  «        S )a  Return the index of the class with the highest probability.

        Returns:
            (int): Index of the class with the highest probability.

        Examples:
            >>> probs = Probs(torch.tensor([0.1, 0.3, 0.6]))
            >>> probs.top1
            2
        )r2   r   Úargmaxr$   s    r   Útop1z
Probs.top1P  s    € õ �4”9×#Ò#Ñ%Ô%Ñ&Ô&Ð&r    ú	list[int]c                ól   — | j                               d¦  «        dd…                              ¦   «         S )a\  Return the indices of the top 5 class probabilities.

        Returns:
            (list[int]): A list containing the indices of the top 5 class probabilities, sorted in descending order.

        Examples:
            >>> probs = Probs(torch.tensor([0.1, 0.2, 0.3, 0.4, 0.5]))
            >>> print(probs.top5)
            [4, 3, 2, 1, 0]
        r   Nr�   )r   Úargsortr  r$   s    r   rÅ   z
Probs.top5^  s1   € ð ”�
×#Ò# AÑ&Ô& r¨ rÔ*×1Ò1Ñ3Ô3Ð3r    c                ó&   — | j         | j                 S )a¢  Return the confidence score of the highest probability class.

        This property retrieves the confidence score (probability) of the class with the highest predicted probability
        from the classification results.

        Returns:
            (torch.Tensor | np.ndarray): A tensor containing the confidence score of the top 1 class.

        Examples:
            >>> results = model("image.jpg")  # classify an image
            >>> probs = results[0].probs  # get classification probabilities
            >>> top1_confidence = probs.top1conf  # get confidence of top 1 class
            >>> print(f"Top 1 class confidence: {top1_confidence.item():.4f}")
        )r   ri  r$   s    r   Útop1confzProbs.top1confl  s   € ð  Œy˜œÔ#Ð#r    c                ó&   — | j         | j                 S )aù  Return confidence scores for the top 5 classification predictions.

        This property retrieves the confidence scores corresponding to the top 5 class probabilities predicted by the
        model. It provides a quick way to access the most likely class predictions along with their associated
        confidence levels.

        Returns:
            (torch.Tensor | np.ndarray): A tensor or array containing the confidence scores for the top 5 predicted
                classes, sorted in descending order of probability.

        Examples:
            >>> results = model("image.jpg")
            >>> probs = results[0].probs
            >>> top5_conf = probs.top5conf
            >>> print(top5_conf)  # Prints confidence scores for top 5 classes
        )r   rÅ   r$   s    r   r!  zProbs.top5conf~  s   € ð$ Œy˜œÔ#Ð#r    r0  )rX   r   r   re  r   r   r:   )r   rj  rK  )r;   r<   r=   r>   r   r   ri  rÅ   rn  r!  rM  rN  s   @r   rf   rf   "  sÍ   ø€ € € € € ðð ð@,ð ,ð ,ð ,ð ,ð ,ð ,ð ð'ð 'ð 'ñ „_ð'ð ð4ð 4ð 4ñ „_ð4ð ð$ð $ð $ñ „_ð$ð" ð$ð $ð $ñ „_ð$ð $ð $ð $ð $r    rf   c                  óÌ   ‡ — e Zd ZdZdˆ fd„Zedd	„¦   «         Zedd
„¦   «         Zedd„¦   «         Zedd„¦   «         Z	e
dd„¦   «         Ze
dd„¦   «         Ze
dd„¦   «         Zˆ xZS )rh   a  A class for storing and manipulating Oriented Bounding Boxes (OBB).

    This class provides functionality to handle oriented bounding boxes, including conversion between different formats,
    normalization, and access to various properties of the boxes. It supports both tracking and non-tracking scenarios.

    Attributes:
        data (torch.Tensor): The raw OBB tensor containing box coordinates and associated data.
        orig_shape (tuple[int, int]): Original image size as (height, width).
        is_track (bool): Indicates whether tracking IDs are included in the box data.
        xywhr (torch.Tensor | np.ndarray): Boxes in [x_center, y_center, width, height, rotation] format.
        conf (torch.Tensor | np.ndarray): Confidence scores for each box.
        cls (torch.Tensor | np.ndarray): Class labels for each box.
        id (torch.Tensor | np.ndarray): Tracking IDs for each box, if available.
        xyxyxyxy (torch.Tensor | np.ndarray): Boxes in 8-point [x1, y1, x2, y2, x3, y3, x4, y4] format.
        xyxyxyxyn (torch.Tensor | np.ndarray): Normalized 8-point coordinates relative to orig_shape.
        xyxy (torch.Tensor | np.ndarray): Axis-aligned bounding boxes in [x1, y1, x2, y2] format.

    Methods:
        cpu: Return a copy of the OBB object with all tensors on CPU memory.
        numpy: Return a copy of the OBB object with all tensors as numpy arrays.
        cuda: Return a copy of the OBB object with all tensors on GPU memory.
        to: Return a copy of the OBB object with tensors on specified device and dtype.

    Examples:
        >>> boxes = torch.tensor([[100, 50, 150, 100, 30, 0.9, 0]])  # xywhr, conf, cls
        >>> obb = OBB(boxes, orig_shape=(480, 640))
        >>> print(obb.xyxyxyxy)
        >>> print(obb.conf)
        >>> print(obb.cls)
    rU   r   r   r   r   r   c                óÚ   •— |j         dk    r|ddd…f         }|j        d         }|dv sJ d|› �¦   «         ‚t          ¦   «                              ||¦  «         |dk    | _        || _        dS )aH  Initialize an OBB (Oriented Bounding Box) instance with oriented bounding box data and original image shape.

        This class stores and manipulates Oriented Bounding Boxes (OBB) for object detection tasks. It provides various
        properties and methods to access and transform the OBB data.

        Args:
            boxes (torch.Tensor | np.ndarray): A tensor or numpy array containing the detection boxes, with shape
                (num_boxes, 7) or (num_boxes, 8). The last two columns contain confidence and class values. If present,
                the third last column contains track IDs, and the fifth column contains rotation.
            orig_shape (tuple[int, int]): Original image size, in the format (height, width).

        Raises:
            AssertionError: If the number of values per box is not 7 or 8.
        r›   Nrû   >   r4  é   zexpected 7 or 8 values but got rr  r5  r8  s       €r   r   zOBB.__init__³  sx   ø€ ð Œ:˜Š?ˆ?Ø˜$   ˜'”NˆEØŒK˜ŒOˆØ�Fˆ{ˆ{ˆ{ÐA¸aÐAÐA‰{Œ{ˆ{Ý‰Œ×Ò˜ 
Ñ+Ô+Ð+Ø˜QšˆŒØ$ˆŒˆˆr    c                ó(   — | j         dd…dd…f         S )a]  Return boxes in [x_center, y_center, width, height, rotation] format.

        Returns:
            (torch.Tensor | np.ndarray): A tensor or numpy array containing the oriented bounding boxes with format
                [x_center, y_center, width, height, rotation]. The shape is (N, 5) where N is the number of boxes.

        Examples:
            >>> results = model("image.jpg")
            >>> obb = results[0].obb
            >>> xywhr = obb.xywhr
            >>> print(xywhr.shape)
            torch.Size([3, 5])

        Notes:
            Predictions are not canonicalized to the long-edge convention that training labels use, so width may be
            smaller than height with the rotation measured from the short edge. Use `xyxyxyxy` when only the geometry
            matters, or `ops.xyxyxyxy2xywhr(obb.xyxyxyxy)` for the canonical form.
        Nr�   r©   r$   s    r   Úxywhrz	OBB.xywhrÊ  s   € ð( Œy˜˜˜˜B˜Q˜B˜ÔÐr    c                ó$   — | j         dd…df         S )a†  Return the confidence scores for Oriented Bounding Boxes (OBBs).

        This property retrieves the confidence values associated with each OBB detection. The confidence score
        represents the model's certainty in the detection.

        Returns:
            (torch.Tensor | np.ndarray): A tensor or numpy array of shape (N,) containing confidence scores for N
                detections, where each score is in the range [0, 1].

        Examples:
            >>> results = model("image.jpg")
            >>> obb_result = results[0].obb
            >>> confidence_scores = obb_result.conf
            >>> print(confidence_scores)
        Nr<  r©   r$   s    r   r…   zOBB.confà  s   € ð" Œy˜˜˜˜B˜ÔÐr    c                ó$   — | j         dd…df         S )aâ  Return the class values of the oriented bounding boxes.

        Returns:
            (torch.Tensor | np.ndarray): A tensor or numpy array containing the class values for each oriented bounding
                box. The shape is (N,), where N is the number of boxes.

        Examples:
            >>> results = model("image.jpg")
            >>> result = results[0]
            >>> obb = result.obb
            >>> class_values = obb.cls
            >>> print(class_values)
        Nrû   r©   r$   s    r   rº   zOBB.clsó  s   € ð Œy˜˜˜˜B˜ÔÐr    r?  c                ó6   — | j         r| j        dd…df         ndS )aŒ  Return the tracking IDs of the oriented bounding boxes (if available).

        Returns:
            (torch.Tensor | np.ndarray | None): A tensor or numpy array containing the tracking IDs for each oriented
                bounding box. Returns None if tracking IDs are not available.

        Examples:
            >>> results = model.track("path/to/video.mp4")  # Run inference with tracking
            >>> for result in results:
            ...     if result.obb is not None:
            ...         track_ids = result.obb.id
            ...         if track_ids is not None:
            ...             print(f"Tracking IDs: {track_ids}")
        NrA  rB  r$   s    r   r¹   zOBB.id  s%   € ð  $(¤=Ð:ˆtŒy˜˜˜˜B˜ÔÐ°dÐ:r    c                ó4   — t          j        | j        ¦  «        S )a­  Convert OBB format to 8-point (xyxyxyxy) coordinate format for rotated bounding boxes.

        Returns:
            (torch.Tensor | np.ndarray): Rotated bounding boxes in xyxyxyxy format with shape (N, 4, 2), where N is the
                number of boxes. The 4 points (x, y) are wound counter-clockwise as rendered, starting from the corner
                at +w/2, +h/2 in the box frame, so which image corner comes first follows the rotation.

        Examples:
            >>> obb = OBB(torch.tensor([[100, 100, 50, 30, 0.5, 0.9, 0]]), orig_shape=(640, 640))
            >>> xyxyxyxy = obb.xyxyxyxy
            >>> print(xyxyxyxy.shape)
            torch.Size([1, 4, 2])
        )r   Úxywhr2xyxyxyxyrt  r$   s    r   r½   zOBB.xyxyxyxy  s   € õ Ô! $¤*Ñ-Ô-Ð-r    c                ó  — t          | j        t          j        ¦  «        r| j                             ¦   «         nt          j        | j        ¦  «        }|dxx         | j        d         z  cc<   |dxx         | j        d         z  cc<   |S )aY  Convert rotated bounding boxes to normalized xyxyxyxy format.

        Returns:
            (torch.Tensor | np.ndarray): Normalized rotated bounding boxes in xyxyxyxy format with shape (N, 4, 2),
                where N is the number of boxes. Each box is represented by 4 points (x, y), normalized relative to the
                original image dimensions.

        Examples:
            >>> obb = OBB(torch.rand(10, 7), orig_shape=(640, 480))  # 10 random OBBs
            >>> normalized_boxes = obb.xyxyxyxyn
            >>> print(normalized_boxes.shape)
            torch.Size([10, 4, 2])
        ra  r›   rb  r   )r   r½   r   r   rG  r   r  r   )r   r  s     r   r  zOBB.xyxyxyxyn'  s‹   € õ .8¸¼ÅuÄ|Ñ-TÔ-TÐp�D”M×'Ò'Ñ)Ô)Ð)ÕZ\ÔZaÐbfÔboÑZpÔZpˆ	Ø�&ÐÐÔ˜Tœ_¨QÔ/Ñ/ÐÐÑØ�&ÐÐÔ˜Tœ_¨QÔ/Ñ/ÐÐÑØÐr    c                óþ  — | j         d         }| j         d         }t          |t          j        ¦  «        ret          j        |                     d¦  «        |                     d¦  «        |                     d¦  «        |                     d¦  «        gd¦  «        ndt          j        |                     d¦  «        |                     d¦  «        | 	                    d¦  «        | 	                    d¦  «        gd¦  «        S )a  Convert oriented bounding boxes (OBB) to axis-aligned bounding boxes in xyxy format.

        This property calculates the minimal enclosing rectangle for each oriented bounding box and returns it in xyxy
        format (x1, y1, x2, y2). This is useful for operations that require axis-aligned bounding boxes, such as IoU
        calculation with non-rotated boxes.

        Returns:
            (torch.Tensor | np.ndarray): Axis-aligned bounding boxes in xyxy format with shape (N, 4), where N is the
                number of boxes. Each row contains [x1, y1, x2, y2] coordinates.

        Examples:
            >>> import torch
            >>> from ultralytics import YOLO
            >>> model = YOLO("yolo26n-obb.pt")
            >>> results = model("path/to/image.jpg")
            >>> for result in results:
            ...     obb = result.obb
            ...     if obb is not None:
            ...         xyxy_boxes = obb.xyxy
            ...         print(xyxy_boxes.shape)  # (N, 4)

        Notes:
            - This method approximates the OBB by its minimal enclosing rectangle.
            - The returned format is compatible with standard object detection metrics and visualization tools.
            - The property uses caching to improve performance for repeated access.
        ra  rb  r›   rû   )
r½   r   r   r   ÚstackÚaminÚamaxr   rð   rñ   )r   r    r  s      r   r¾   zOBB.xyxy;  sº   € ð8 ŒM˜&Ô!ˆØŒM˜&Ô!ˆõ ˜!�Uœ\Ñ*Ô*ðH�EŒK˜Ÿš ™œ A§F¢F¨1¡I¤I¨q¯vªv°a©y¬y¸!¿&º&À¹)¼)ÐDÀbÑIÔIÐIå”˜1Ÿ5š5 ™8œ8 Q§U¢U¨1¡X¤X¨q¯uªu°Q©x¬x¸¿º¸q¹¼ÐBÀBÑGÔGð	
r    rJ  rK  rL  )r;   r<   r=   r>   r   r?   rt  r…   rº   r¹   r   r½   r  r¾   rM  rN  s   @r   rh   rh   “  s'  ø€ € € € € ðð ð>%ð %ð %ð %ð %ð %ð. ð ð  ð  ñ „Xð ð* ð ð  ð  ñ „Xð ð$ ð ð  ð  ñ „Xð ð  ð;ð ;ð ;ñ „Xð;ð" ð.ð .ð .ñ „_ð.ð  ðð ð ñ „_ðð& ð!
ð !
ð !
ñ „_ð!
ð !
ð !
ð !
ð !
r    rh   )!r>   Ú
__future__r   r  r   Ú	functoolsr   Úpathlibr   Útypingr   r)   r   r   Úultralytics.utilsr   r	   r
   r   Úultralytics.utils.plottingr   r   r   r   rB   rI   rL   rN   rd   re   rg   rf   rh   r@   r    r   ú<module>r…     sÄ  ððð ð #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ð Ð Ø %Ð %Ð %Ð %Ð %Ð %Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à Ð Ð Ð Ø €€€à GÐ GÐ GÐ GÐ GÐ GÐ GÐ GÐ GÐ GÐ GÐ GØ FÐ FÐ FÐ FÐ FÐ FÐ FÐ FÐ FÐ FðV?ð V?ð V?ð V?ð V?�ñ V?ô V?ð V?ðrVð Vð Vð Vð V˜ñ Vô Vð Vð9ð 9ð 9ð 9ð 9Ð%ñ 9ô 9ð 9ðDð Dð Dð Dð DÐ!ñ Dô Dð Dð^ð ^ð ^ð ^ð ^ˆk˜?ñ ^ô ^ð ^ðB|ð |ð |ð |ð |ˆJñ |ô |ð |ð~Q
ð Q
ð Q
ð Q
ð Q
ˆJñ Q
ô Q
ð Q
ðhf?ð f?ð f?ð f?ð f?�
ñ f?ô f?ð f?ðRn$ð n$ð n$ð n$ð n$ˆJñ n$ô n$ð n$ðbJ
ð J
ð J
ð J
ð J
ˆ*ñ J
ô J
ð J
ð J
ð J
r    