Ë
    ¼Ó^jî¨  ã                  ó¸  — d dl mZ d dlmZ d dlmZ d dlZd dlm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 d d	lmZmZ d d
lmZ dd„Zdej@                  f	 	 	 	 	 	 	 dd„Z!ej@                  f	 	 	 	 	 	 	 dd„Z" ee"dd¬«      	 	 	 	 	 	 dd„«       Z#e G d„ d«      «       Z$ eejJ                  dd¬«       ed¬«       G d„ d«      «       «       Z&y)é    )Úannotations)ÚCallable)Ú	dataclassN)Ú
TargetModeÚ
deprecatedÚdeprecated_classÚvoid)ÚORIENTED_BOX_COORDINATES)ÚDetectionDataset)Ú
Detections)Úbox_iou_batchÚoriented_box_iou_batch)ÚMetricTargetc                ó@   — | t         j                  k(  rt        d«      ‚y )NzBMetricTarget.MASKS is not currently supported for ConfusionMatrix.)r   ÚMASKSÚ
ValueError©Úmetric_targets    úh/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/supervision/metrics/detection.pyÚ_assert_supported_targetr      s%   € Øœ×*Ñ*Ò*ÜØPó
ð 	
ð +ó    Fc                ó  — t        |«       | j                  €t        d«      ‚|t        j                  k(  �r)| j
                  j                  t        «      }|€Gt        | «      dkD  rt        dt        › d�«      ‚t        j                  dt        j                  ¬«      }nÍt        j                  |t        j                  ¬«      }|j                  dk(  r$|j                  d	d d
k(  r|j                  dd«      }|j                   t        | «      dz  k7  r;t        dt        › dt        | «      dz  › dt        | «      › d|j                   › d�	«      ‚|j                  dd«      }n| j"                  }|t        j$                  | j                  j'                  t        j                  «      d	«      g}|rF| j(                  €t        d«      ‚|j+                  t        j$                  | j(                  d	«      «       t        j,                  |d	¬«      }|S )a©
  
    Convert Supervision Detections to a numpy tensor for metric computation.

    Args:
        detections: Detections/Targets in the format of sv.Detections.
        with_confidence: Whether to include confidence as the last column.
        metric_target: The type of detection data to use.
            Supports `MetricTarget.BOXES` and
            `MetricTarget.ORIENTED_BOUNDING_BOXES`.

    Returns:
        Detections as a float32 numpy array. Shape depends on `metric_target`
        and `with_confidence`:

        | `metric_target`                        | `with_confidence` | shape     |
        |----------------------------------------|-------------------|-----------|
        | `MetricTarget.BOXES`                   | `False`           | `(N, 5)`  |
        | `MetricTarget.BOXES`                   | `True`            | `(N, 6)`  |
        | `MetricTarget.ORIENTED_BOUNDING_BOXES` | `False`           | `(N, 9)`  |
        | `MetricTarget.ORIENTED_BOUNDING_BOXES` | `True`            | `(N, 10)` |

        Column layout:

        - `BOXES`: ``[x_min, y_min, x_max, y_max, class_id [, confidence]]``
        - `ORIENTED_BOUNDING_BOXES`:
          ``[x1, y1, x2, y2, x3, y3, x4, y4, class_id [, confidence]]``

    Raises:
        ValueError: If `metric_target` is `MetricTarget.MASKS`.
        ValueError: If `detections.class_id` is `None`.
        ValueError: If `with_confidence=True` and `detections.confidence` is `None`.
        ValueError: If `metric_target` is `MetricTarget.ORIENTED_BOUNDING_BOXES`
            and `detections.data` does not contain `ORIENTED_BOX_COORDINATES`,
            or if the stored array does not have exactly `N * 8` elements.

    Examples:
        ```pycon
        >>> import numpy as np
        >>> import supervision as sv
        >>> from supervision.metrics.core import MetricTarget
        >>> from supervision.config import ORIENTED_BOX_COORDINATES
        >>> detections = sv.Detections(
        ...     xyxy=np.array([[0, 0, 10, 10]], dtype=np.float32),
        ...     class_id=np.array([0]),
        ...     confidence=np.array([0.9]),
        ... )
        >>> tensor = detections_to_tensor(detections, with_confidence=True)
        >>> tensor.shape
        (1, 6)
        >>> obb_coords = np.array([[0, 0, 10, 0, 10, 10, 0, 10]], dtype=np.float32)
        >>> det_obb = sv.Detections(
        ...     xyxy=np.array([[0, 0, 10, 10]], dtype=np.float32),
        ...     class_id=np.array([0]),
        ...     data={ORIENTED_BOX_COORDINATES: obb_coords},
        ... )
        >>> tensor_obb = detections_to_tensor(
        ...     det_obb, metric_target=MetricTarget.ORIENTED_BOUNDING_BOXES
        ... )
        >>> tensor_obb.shape
        (1, 9)

        ```
    NzCConfusionMatrix can only be calculated for Detections with class_idr   z'ORIENTED_BOUNDING_BOXES requested, but z  is missing from detections.data)r   é   ©Údtypeé   é   )é   é   éÿÿÿÿr   z	Expected z to contain z elements (N=z& detections x 8 coordinates), but got z>. Each OBB must be stored as [x1, y1, x2, y2, x3, y3, x4, y4].zEConfusionMatrix can only be calculated for Detections with confidence©Úaxis)r   Úclass_idr   r   ÚORIENTED_BOUNDING_BOXESÚdataÚgetr
   ÚlenÚnpÚemptyÚfloat32ÚasarrayÚndimÚshapeÚreshapeÚsizeÚxyxyÚexpand_dimsÚastypeÚ
confidenceÚappendÚconcatenate)Ú
detectionsÚwith_confidencer   ÚobbÚbox_dataÚobb_arrÚarrays_to_concatÚresults           r   Údetections_to_tensorr=      sÞ  € ôH ˜]Ô+à×ÑÐ"ÜØQó
ð 	
ð œ×<Ñ<Ó<Ø�o‰o×!Ñ!Ô":Ó;ˆØˆ;Ü�:‹ Ò"Ü Ø=Ü/Ð0Ð0PðRóð ô —x‘x ¬b¯j©jÔ9‰Hä—j‘j ¬B¯J©JÔ7ˆGà�|‰|˜qÒ  W§]¡]°1°2Ð%6¸&Ò%@Ø!Ÿ/™/¨"¨aÓ0�Ø�|‰|œs :›°Ñ2Ò2Ü ØÔ 8Ð9¸Ü˜:“¨Ñ*Ð+ð ,Ü˜j›/Ð*ð +Ø&Ÿ|™|˜nð -SðSóð ð —‘ r¨1Ó-‰Hà—?‘?ˆð 	Ü
�‰�z×*Ñ*×1Ñ1´"·*±*Ó=¸qÓAðÐñ
 Ø× Ñ Ð(ÜØWóð ð 	×Ñ¤§¡¨z×/DÑ/DÀaÓ HÔIä&(§n¡nÐ5EÈAÔ&N€FØ€Mr   c           	     óŒ  — t        | «      t        |«      k7  r$t        dt        | «      › dt        |«      › d�«      ‚t        | «      dkD  rût        | d   t        j                  «      rt        |d   t        j                  «      s*t        dt        | d   «      › dt        |d   «      › d�«      ‚|t        j                  k(  rdnd	}|t        j                  k(  rd
nd}| d   j                  d   |k7  rt        d|› d| d   j                  › d�«      ‚|d   j                  d   |k7  rt        d|› d|d   j                  › d�«      ‚yy)z8
    Checks for shape consistency of input tensors.
    zNumber of predictions (z) andtargets (z) must be equal.r   z;Predictions and targets must be lists of numpy arrays. Got z and ú	 instead.é
   é   é	   é   r   z Predictions must have shape (N, ú). Got úTargets must have shape (N, N)	r'   r   Ú
isinstancer(   ÚndarrayÚtyper   r$   r-   )ÚpredictionsÚtargetsr   Úexpected_pred_colsÚexpected_target_colss        r   Ú_validate_input_tensorsrM   ’   s‹  € ô ˆ;Óœ3˜w›<Ò'ÜØ%¤c¨+Ó&6Ð%7ð 8Ü˜G›�~Ð%5ð7ó
ð 	
ô ˆ;Ó˜!ÒÜ˜+ a™.¬"¯*©*Ô5¼ZØ�A‰JœŸ
™
ô>
ô ðÜ˜K¨™NÓ+Ð,¨E´$°w¸q±zÓ2BÐ1CÀ9ðNóð ð  ¤<×#GÑ#GÒG‰BÈQð 	ð ¤,×"FÑ"FÒF‰AÈAð 	ð �q‰>×Ñ Ñ"Ð&8Ò8ÜØ2Ð3EÐ2Fð GØ" 1‘~×+Ñ+Ð,¨Ið7óð ð �1‰:×Ñ˜AÑÐ"6Ò6ÜØ.Ð/CÐ.Dð EØ˜q‘z×'Ñ'Ð(¨	ð3óð ð 7ð+ r   z0.29.0z0.32.0)ÚtargetÚdeprecated_inÚ	remove_inc                ó   — t        | |«       y ©N)r	   ©rI   rJ   s     r   Úvalidate_input_tensorsrT   »   s   € ô 	ˆ�gÕr   c                  óÄ  — e Zd ZU dZded<   ded<   ded<   ded<   ej                  Zd	ed
<   dd„ZdZ	e
ddej                  f	 	 	 	 	 	 	 	 	 	 	 	 	 dd„«       Ze
ddej                  f	 	 	 	 	 	 	 	 	 	 	 	 	 dd„«       Zeej                  f	 	 	 	 	 	 	 	 	 	 	 	 	 dd„«       Ze	 	 	 	 dd„«       Ze
ddej                  f	 	 	 	 	 	 	 	 	 	 	 dd„«       Z	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 dd„Zy)ÚConfusionMatrixu¯  
    Confusion matrix for object detection tasks.

    Attributes:
        matrix: An 2D `np.ndarray` of shape `(len(classes) + 1, len(classes) + 1)`
            containing the number of `TP`, `FP`, `FN` and `TN` for each class.
        classes: Model class names.
        conf_threshold: Detection confidence threshold between `0` and `1`.
            Detections with lower confidence will be excluded from the matrix.
        iou_threshold: Detection IoU threshold between `0` and `1`.
            Detections with lower IoU will be classified as `FP`.
        metric_target: The type of detection data used for IoU computation.
            Informational metadata set by `from_detections` and `from_tensors`.
            Excluded from `__eq__` comparisons â€” two `ConfusionMatrix` instances
            with identical `matrix`, `classes`, `conf_threshold`, and
            `iou_threshold` compare as equal regardless of `metric_target`.
    únpt.NDArray[np.int32]Úmatrixú	list[str]ÚclassesÚfloatÚconf_thresholdÚiou_thresholdr   r   c                ó$  — t        |t        «      st        S t        j                  | j
                  |j
                  «      xrO | j                  |j                  k(  xr4 | j                  |j                  k(  xr | j                  |j                  k(  S rR   )	rF   rV   ÚNotImplementedr(   Úarray_equalrX   rZ   r\   r]   )ÚselfÚothers     r   Ú__eq__zConfusionMatrix.__eq__á   sv   € Ü˜%¤Ô1Ü!Ð!ä�N‰N˜4Ÿ;™;¨¯©Ó5ò :Ø—‘ §¡Ñ-ò:à×#Ñ# u×';Ñ';Ñ;ò:ð ×"Ñ" e×&9Ñ&9Ñ9ð		
r   Ng333333Ó?ç      à?c                óÔ   — g }g }t        ||«      D ]?  \  }	}
|j                  t        |	d|¬«      «       |j                  t        |
d|¬«      «       ŒA | j                  ||||||¬«      S )a�  
        Calculate confusion matrix based on predicted and ground-truth detections.

        Args:
            targets: Detections objects from ground-truth.
            predictions: Detections objects predicted by the model.
            classes: Model class names.
            conf_threshold: Detection confidence threshold between `0` and `1`.
                Detections with lower confidence will be excluded.
            iou_threshold: Detection IoU threshold between `0` and `1`.
                Detections with lower IoU will be classified as `FP`.
            metric_target: The type of detection data to use.
                Supports `MetricTarget.BOXES` (default) and
                `MetricTarget.ORIENTED_BOUNDING_BOXES`. When using
                `MetricTarget.ORIENTED_BOUNDING_BOXES`, each `Detections`
                object must include OBB coordinates in
                `detections.data[ORIENTED_BOX_COORDINATES]` as a float32
                array of shape `(N, 8)` (flat) or `(N, 4, 2)` (as stored by
                `from_ultralytics`); both are normalised to `(N, 8)` internally.
                `MetricTarget.MASKS` is not supported.

        Returns:
            New instance of ConfusionMatrix.

        Examples:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> targets = [
            ...     sv.Detections(
            ...         xyxy=np.array([[0, 0, 10, 10], [50, 50, 60, 60]]),
            ...         class_id=np.array([0, 0])
            ...     )
            ... ]
            >>> predictions = [
            ...     sv.Detections(
            ...         xyxy=np.array([[0, 0, 10, 10], [100, 100, 110, 110]]),
            ...         class_id=np.array([0, 0]),
            ...         confidence=np.array([0.9, 0.8])
            ...     )
            ... ]
            >>> confusion_matrix = sv.ConfusionMatrix.from_detections(
            ...     predictions=predictions,
            ...     targets=targets,
            ...     classes=['person']
            ... )
            >>> confusion_matrix.matrix
            array([[1., 1.],
                   [1., 0.]])

            ```
        T)r7   r   F©rI   rJ   rZ   r\   r]   r   ©Úzipr4   r=   Úfrom_tensors)ÚclsrI   rJ   rZ   r\   r]   r   Úprediction_tensorsÚtarget_tensorsÚ
predictionrN   s              r   Úfrom_detectionszConfusionMatrix.from_detectionsí   s“   € ð|  ÐØˆÜ"% k°7Ó";ò 
	ÑˆJ˜Ø×%Ñ%Ü$Ø°ÀMôôð
 ×!Ñ!Ü$Ø¨EÀôõð
	ð ×ÑØ*Ø"ØØ)Ø'Ø'ð  ó 
ð 	
r   c           
     óú   — t        |«       t        |||¬«       t        |«      }t        j                  |dz   |dz   f«      }t        ||«      D ]  \  }	}
|| j                  |
|	||||¬«      z  }Œ!  | |||||¬«      S )a 
  
        Calculate confusion matrix based on predicted and ground-truth detections.

        Args:
            predictions: Each element of the list describes a single
                image and has `shape = (M, 6)` or `shape = (M, 10)` depending on
                `metric_target`.
                If `MetricTarget.BOXES`, each row is in
                `(x_min, y_min, x_max, y_max, class, conf)` format.
                If `MetricTarget.ORIENTED_BOUNDING_BOXES`, each row is in
                `(x1, y1, x2, y2, x3, y3, x4, y4, class, conf)` format.
            targets: Each element of the list describes a single
                image and has `shape = (N, 5)` or `shape = (N, 9)` depending on
                `metric_target`.
                If `MetricTarget.BOXES`, each row is in
                `(x_min, y_min, x_max, y_max, class)` format.
                If `MetricTarget.ORIENTED_BOUNDING_BOXES`, each row is in
                `(x1, y1, x2, y2, x3, y3, x4, y4, class)` format.
            classes: Model class names.
            conf_threshold: Detection confidence threshold between `0` and `1`.
                Detections with lower confidence will be excluded.
            iou_threshold: Detection iou threshold between `0` and `1`.
                Detections with lower iou will be classified as `FP`.
            metric_target: The type of detection data to use.
                Determines expected tensor shapes (see Args above for column
                layouts). `MetricTarget.MASKS` is not supported.

        Returns:
            New instance of ConfusionMatrix.

        Examples:
            ```pycon
            >>> import supervision as sv
            >>> import numpy as np
            >>> targets = [
            ...     np.array([
            ...         [0.0, 0.0, 3.0, 3.0, 0],
            ...         [2.0, 2.0, 5.0, 5.0, 0],
            ...         [6.0, 1.0, 8.0, 3.0, 1],
            ...     ])
            ... ]
            >>> predictions = [
            ...     np.array([
            ...         [0.0, 0.0, 3.0, 3.0, 0, 0.9],
            ...         [0.1, 0.1, 3.0, 3.0, 0, 0.9],
            ...         [6.0, 1.0, 8.0, 3.0, 1, 0.8],
            ...     ])
            ... ]
            >>> confusion_matrix = sv.ConfusionMatrix.from_tensors(
            ...     predictions=predictions,
            ...     targets=targets,
            ...     classes=['person', 'dog']
            ... )
            >>> confusion_matrix.matrix
            array([[1., 0., 1.],
                   [0., 1., 0.],
                   [1., 0., 0.]])

            ```
        r   r   )rI   rJ   Únum_classesr\   r]   r   )rX   rZ   r\   r]   r   )r   rM   r'   r(   Úzerosrh   Úevaluate_detection_batch)rj   rI   rJ   rZ   r\   r]   r   rp   rX   Ú
true_batchÚdetection_batchs              r   ri   zConfusionMatrix.from_tensorsA  s¤   € ôL 	! Ô/Ü ¨WÀMÕRä˜'“lˆÜ—‘˜;¨™?¨K¸!©OÐ<Ó=ˆÜ+.¨w¸Ó+Dò 	Ñ'ˆJ˜Ø�c×2Ñ2Ø+Ø"Ø'Ø-Ø+Ø+ð 3ó ñ ‰Fð	ñ ØØØ)Ø'Ø'ô
ð 	
r   c           
     ó6  — t        |«       |t        j                  k(  rdnd}|t        j                  k(  rdnd}| j                  dk7  s| j                  d   |k7  rt        d|› d| j                  › d	�«      ‚|j                  dk7  s|j                  d   |k7  rt        d
|› d|j                  › d	�«      ‚t        j                  |dz   |dz   f«      }|t        j                  k(  rdnd}	|	}
|	dz   }| dd…|f   }| ||k\     }t        |«      dk(  rDt        j                  |dd…|
f   t        j                  ¬«      }|D ]  }|||fxx   dz  cc<   Œ |S t        |«      dk(  rDt        j                  |dd…|
f   t        j                  ¬«      }|D ]  }|||fxx   dz  cc<   Œ |S t        j                  |dd…|
f   t        j                  ¬«      }t        j                  |dd…|
f   t        j                  ¬«      }|dd…d|	…f   }|dd…d|	…f   }|t        j                  k(  rt        ||¬«      }nt        ||¬«      }||kD  }t        j                  |«      \  }}|j                  dk(  rg }nr|||f   }||   }||   }||k(  }t        j                  | | f«      }|D �cg c]8  }t!        ||   «      t!        ||   «      t#        ||   «      t%        ||   «      f‘Œ: }}t'        «       }t'        «       } |D ]L  \  }!}"}#}$|!|vsŒ|"| vsŒ||!   }||"   }|||fxx   dz  cc<   |j)                  |!«       | j)                  |"«       ŒN t+        |«      D ]  \  }!}|!|vsŒ|||fxx   dz  cc<   Œ t+        |«      D ]  \  }"}|"| vsŒ|||fxx   dz  cc<   Œ |S c c}w )ad  
        Calculate confusion matrix for a batch of detections for a single image.

        Args:
            predictions: Batch prediction. Describes a single image and
                has `shape = (M, 6)` or `shape = (M, 10)` depending on
                `metric_target`.
                If `MetricTarget.BOXES`, each row is in
                `(x_min, y_min, x_max, y_max, class, conf)` format.
                If `MetricTarget.ORIENTED_BOUNDING_BOXES`, each row is in
                `(x1, y1, x2, y2, x3, y3, x4, y4, class, conf)` format.
            targets: Batch target labels. Describes a single image and
                has `shape = (N, 5)` or `shape = (N, 9)` depending on
                `metric_target`.
                If `MetricTarget.BOXES`, each row is in
                `(x_min, y_min, x_max, y_max, class)` format.
                If `MetricTarget.ORIENTED_BOUNDING_BOXES`, each row is in
                `(x1, y1, x2, y2, x3, y3, x4, y4, class)` format.
            num_classes: Number of classes.
            conf_threshold: Detection confidence threshold between `0` and `1`.
                Detections with lower confidence will be excluded.
            iou_threshold: Detection iou threshold between `0` and `1`.
                Detections with lower iou will be classified as `FP`.
            metric_target: The type of detection data to use.
                Determines IoU function (`box_iou_batch` vs
                `oriented_box_iou_batch`) and coordinate column count.
                `MetricTarget.MASKS` is not supported.

        Returns:
            Confusion matrix based on a single image.
        r@   rA   rB   rC   r   r   z Predictions must have shape (M, rD   r?   rE   r   r   Nr   r   )Ú
boxes_trueÚboxes_detection)r   r   r$   r,   r-   r   r(   rq   r'   ÚarrayÚint16r   r   Únonzeror/   ÚlexsortÚintr[   ÚboolÚsetÚaddÚ	enumerate)%rI   rJ   rp   r\   r]   r   rK   rL   Úresult_matrixÚ
coords_dimÚclass_id_idxÚconf_idxr3   Údetection_batch_filteredÚtrue_classesÚgt_classÚdetection_classesÚ	det_classÚ
true_boxesÚdetection_boxesÚ	iou_batchÚiou_maskÚ
gt_indicesÚdet_indicesÚvalid_matchesÚiousÚgt_match_classesÚdet_match_classesÚclass_matchesÚsort_indicesÚidxÚmatched_gt_idxÚmatched_det_idxÚgt_idxÚdet_idxÚiouÚclass_matchs%                                        r   rr   z(ConfusionMatrix.evaluate_detection_batch�  sK  € ôP 	! Ô/ð  ¤<×#GÑ#GÒG‰BÈQð 	ð ¤,×"FÑ"FÒF‰AÈAð 	ð ×Ñ˜qÒ  K×$5Ñ$5°aÑ$8Ð<NÒ$NÜØ2Ð3EÐ2Fð GØ"×(Ñ(Ð)¨ð4óð ð �<‰<˜1Ò §¡¨aÑ 0Ð4HÒ HÜØ.Ð/CÐ.Dð EØ—}‘}�o Yð0óð ô
 Ÿ™ +°¡/°;À±?Ð!CÓDˆð (¬<×+OÑ+OÒO‘QÐUVˆ
Ø!ˆØ ‘>ˆà ¢ H Ñ-ˆ
Ø#.¨z¸^Ñ/KÑ#LÐ äÐ'Ó(¨AÒ-äŸ8™8 GªA¨|¨OÑ$<ÄBÇHÁHÔMˆLØ(ò :�Ø˜h¨Ð3Ó4¸Ñ9Ô4ð:à Ð äˆw‹<˜1Òä "§¡Ø(ª¨L¨Ñ9ÄÇÁô!Ðð /ò ;�	Ø˜k¨9Ð4Ó5¸Ñ:Ô5ð;à Ð ä—x‘x ª¨<¨Ñ 8ÄÇÁÔIˆÜŸH™HØ$¢Q¨ _Ñ5¼R¿X¹Xô
Ðð šQ   ˜^Ñ,ˆ
Ø2²1°k°z°k°>ÑBˆð œL×@Ñ@Ò@Ü.Ø%°ô‰Iô &Ø%°ôˆIð ˜}Ñ,ˆÜ"$§*¡*¨XÓ"6Ñˆ
�Kð �?‰?˜aÒØ‰Mà˜Z¨Ð4Ñ5ˆDØ+¨JÑ7ÐØ 1°+Ñ >ÐØ,Ð0AÑAˆMô Ÿ:™:¨ u¨}¨nÐ&=Ó>ˆLð (öð ô ˜
 3™Ó(Ü˜ CÑ(Ó)Ü˜$˜s™)Ó$Ü˜ sÑ+Ó,ò	ðˆMð ô ›ˆÜ›%ˆà1>ò 		-Ñ-ˆF�G˜S +Ø˜^Ò+°¸Ò0Nà'¨Ñ/�Ø-¨gÑ6�	ð ˜h¨	Ð1Ó2°aÑ7Ó2Ø×"Ñ" 6Ô*Ø×#Ñ# GÕ,ð		-ô !*¨,Ó 7ò 	:ÑˆF�HØ˜^Ò+Ø˜h¨Ð3Ó4¸Ñ9Ô4ð	:ô
 #,Ð,=Ó">ò 	;ÑˆG�YØ˜oÒ-Ø˜k¨9Ð4Ó5¸Ñ:Ô5ð	;ð ÐùòGs   Ê"=Nc                ó>  — | j                   d   dkD  rˆ| | dd…df   j                  «       ddd…      } | t        j                  | dd…df   d¬«      d      } | | dd…df   j                  «       ddd…      } | t        j                  | dd…df   d¬«      d      } | }|S )z›
        Deduplicate matches. If there are multiple matches for the same true or
        predicted box, only the one with the highest IoU is kept.
        r   Nr   r    r   T©Úreturn_index)r-   Úargsortr(   Úunique)Úmatchesr<   s     r   Ú_drop_extra_matchesz#ConfusionMatrix._drop_extra_matches@  s«   € ð �=‰=˜Ñ˜aÒØ˜g¢a¨ d™m×3Ñ3Ó5±d¸°dÑ;Ñ<ˆGØœbŸi™i¨²°1°©ÀDÔIÈ!ÑLÑMˆGØ˜g¢a¨ d™m×3Ñ3Ó5±d¸°dÑ;Ñ<ˆGØœbŸi™i¨²°1°©ÀDÔIÈ!ÑLÑMˆGØ*1ˆØˆr   c                ó¶   — g g }}|D ]0  \  }}	}
 ||	«      }|j                  |«       |j                  |
«       Œ2 | j                  |||j                  |||¬«      S )ao  
        Calculate confusion matrix from dataset and callback function.

        Args:
            dataset: Object detection dataset used for evaluation.
            callback: Function that takes an image as input and returns a
                Detections object.
            conf_threshold: Detection confidence threshold between `0` and `1`.
                Detections with lower confidence will be excluded.
            iou_threshold: Detection IoU threshold between `0` and `1`.
                Detections with lower IoU will be classified as `FP`.
            metric_target: The type of detection data to use.
                Supports `MetricTarget.BOXES` and
                `MetricTarget.ORIENTED_BOUNDING_BOXES`. Passed through to
                `from_detections`. `MetricTarget.MASKS` is not supported.

        Returns:
            New instance of ConfusionMatrix.

        Example:
            ```python
            import supervision as sv
            from ultralytics import YOLO

            dataset = sv.DetectionDataset.from_yolo(...)

            model = YOLO(...)
            def callback(image: np.ndarray) -> sv.Detections:
                result = model(image)[0]
                return sv.Detections.from_ultralytics(result)

            confusion_matrix = sv.ConfusionMatrix.benchmark(
                dataset = dataset,
                callback = callback
            )

            print(confusion_matrix.matrix)
            # np.array([
            #     [0., 0., 0., 0.],
            #     [0., 1., 0., 1.],
            #     [0., 1., 1., 0.],
            #     [1., 1., 0., 0.]
            # ])
            ```
        rf   )r4   rn   rZ   )rj   ÚdatasetÚcallbackr\   r]   r   rI   rJ   Ú_ÚimageÚ
annotationÚpredictions_batchs               r   Ú	benchmarkzConfusionMatrix.benchmarkP  sy   € ðl  " 2�WˆØ$+ò 	'Ñ ˆAˆu�jÙ (¨£ÐØ×ÑÐ0Ô1Ø�N‰N˜:Õ&ð	'ð ×"Ñ"Ø#ØØ—O‘OØ)Ø'Ø'ð #ó 
ð 	
r   c                ó¢  — | j                   j                  «       }|r)d}||j                  d«      j                  dd«      |z   z  }t        j
                  ||dk  <   t        j                  |dd¬«      \  }}	|�|n| j                  }
|
d	uxr dt        |
«      cxk  xr d
k  nc }|rg |
¢d‘}g |
¢d‘}t        |«      }nd	}d	}t        |«      }|	j                  |d¬«      }|	j                  j                  ||	¬«      }|j                  j                  dt	        j                  |«      ¬«       |€d}nd}|	j!                  t	        j"                  d||«      |¬«       |	j%                  t	        j"                  d||«      |¬«       t        j&                  |	j)                  «       ddd¬«       |dk  rdnd}|	j+                  dd|¬«       |dk  r“t-        |j.                  d   «      D ]x  }t-        |j.                  d   «      D ][  }|||f   }t	        j0                  |«      rŒ |	j3                  |||r|d›n|d›dd|d t	        j                  |«      z  k  rd!nd¬"«       Œ] Œz |r|	j5                  |d#¬$«       |	j7                  d%«       |	j9                  d&«       |	j;                  d«       |r#|j=                  |d'|j?                  «       d¬(«       |S ))a  
        Create confusion matrix plot and save it at selected location.

        Args:
            save_path: Path to save the plot. If not provided,
                plot will be displayed.
            title: Title of the plot.
            classes: List of classes to be displayed on the plot.
                If not provided, all classes will be displayed.
            normalize: If True, normalize the confusion matrix.
            fig_size: Size of the plot.

        Returns:
            Confusion matrix plot.
        g:Œ0âŽyE>r   r   r    g{®Gázt?TÚwhite)ÚfigsizeÚtight_layoutÚ	facecolorNéc   ÚFNÚFPÚBlues)Úcmap)Úax)ÚvminÚvmaxr   )ÚlabelséZ   ÚrightÚdefault)ÚrotationÚhaÚrotation_modeé2   r@   r   Úboth)r"   ÚwhichÚ	labelsizeé   z.2fz.0fÚcenterrd   Úblack)r¾   ÚvaÚcoloré   )ÚfontsizeÚ	PredictedÚTrueéú   )Údpir°   Útransparent) rX   ÚcopyÚsumr.   r(   ÚnanÚpltÚsubplotsrZ   r'   ÚimshowÚfigureÚcolorbarÚmappableÚset_climÚnanmaxÚ
set_xticksÚarangeÚ
set_yticksÚsetpÚget_xticklabelsÚtick_paramsÚranger-   ÚisnanÚtextÚ	set_titleÚ
set_xlabelÚ
set_ylabelÚset_facecolorÚsavefigÚget_facecolor)ra   Ú	save_pathÚtitlerZ   Ú	normalizeÚfig_sizerx   ÚepsÚfigr¶   Úclass_namesÚuse_labels_for_ticksÚx_tick_labelsÚy_tick_labelsÚ	num_ticksÚimÚcbarÚtick_intervalrÃ   ÚiÚjÚn_predss                         r   ÚplotzConfusionMatrix.plot”  s±  € ð0 —‘× Ñ Ó"ˆáØˆCØ˜UŸY™Y q›\×1Ñ1°!°RÓ8¸3Ñ>Ñ?ˆEä!Ÿv™vˆˆe�e‰mÑä—,‘, x¸dÈgÔV‰ˆˆRà!(Ð!4‘g¸$¿,¹,ˆØ*°$Ð6ÒV¸AÄÀKÓ@PÖ<UÐSUÔ<UÐÙØ0˜kÐ0¨4Ð0ˆMØ0˜kÐ0¨4Ð0ˆMÜ˜MÓ*‰Ià ˆMØ ˆMÜ˜E›
ˆIØ�Y‰Y�u 7ˆYÓ+ˆà�y‰y×!Ñ! "¨Ð!Ó,ˆØ�‰×Ñ A¬B¯I©I°eÓ,<ÐÔ=àÐ Ø‰MàˆMØ
�‰”b—i‘i  9¨mÓ<À]ˆÔSØ
�‰”b—i‘i  9¨mÓ<À]ˆÔSä�‰�×#Ñ#Ó%°°wÈiÕXà# bš.‘B¨aˆ	Ø
�‰˜F¨&¸IˆÔFà�rŠ>Ü˜5Ÿ;™; q™>Ó*ò �Ü˜uŸ{™{¨1™~Ó.ò �AØ# A q D™k�GÜŸ8™8 GÕ,ØŸ™ØØÙ09˜w s™mÀ'È#ÀØ'Ø'à&¨¬r¯y©y¸Ó/?Ñ)?Ò?ñ #*à!(ð  õ 	ñðñ Ø�L‰L˜¨ˆLÔ,à
�‰�kÔ"Ø
�‰�fÔØ
×Ñ˜Ô!ÙØ�K‰KØ˜s¨c×.?Ñ.?Ó.AÈtð ô ð ˆ
r   )rb   ÚobjectÚreturnr}   )rI   úlist[Detections]rJ   rþ   rZ   rY   r\   r[   r]   r[   r   r   rý   rV   )rI   úlist[npt.NDArray[np.float32]]rJ   rÿ   rZ   rY   r\   r[   r]   r[   r   r   rý   rV   )rI   únpt.NDArray[np.float32]rJ   r   rp   r|   r\   r[   r]   r[   r   r   rý   rW   )r¢   r   rý   r   )r¥   r   r¦   ú-Callable[[npt.NDArray[np.uint8]], Detections]r\   r[   r]   r[   r   r   rý   rV   )NNNF)é   r@   )rê   ú
str | Nonerë   r  rZ   zlist[str] | Nonerì   r}   rí   ztuple[int, int]rý   zmatplotlib.figure.Figure)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r   ÚBOXESr   rc   Ú__hash__Úclassmethodrn   ri   Ústaticmethodrr   r£   r«   rû   © r   r   rV   rV   Ç   sp  … ñð$ "Ó!ØÓØÓØÓØ".×"4Ñ"4€M�<Ó4ó
ð €Hàð !$Ø"Ø&2×&8Ñ&8ðQ
à%ðQ
ð "ðQ
ð ð	Q
ð
 ðQ
ð ðQ
ð $ðQ
ð 
òQ
ó ðQ
ðf ð !$Ø"Ø&2×&8Ñ&8ðY
à2ðY
ð /ðY
ð ð	Y
ð
 ðY
ð ðY
ð $ðY
ð 
òY
ó ðY
ðv ð '3×&8Ñ&8ð`Ø,ð`à(ð`ð ð`ð ð	`ð
 ð`ð $ð`ð 
ò`ó ð`ðD ðØ(ðà	 òó ðð ð
 !$Ø"Ø&2×&8Ñ&8ðA
à!ðA
ð @ðA
ð ð	A
ð
 ðA
ð $ðA
ð 
òA
ó ðA
ðJ !%Ø Ø$(ØØ$,ðWàðWð ðWð "ð	Wð
 ðWð "ðWð 
"ôWr   rV   z0.27.0z0.31.0T)Úfrozenc                  ó   — e Zd ZU dZded<   ded<   ded<   ded<   e	 	 	 	 	 	 dd„«       Ze	 	 	 	 	 	 dd	„«       Ze	 	 	 	 	 	 dd
„«       Ze		 	 	 	 	 	 dd„«       Z
e		 	 	 	 	 	 	 	 dd„«       Ze		 d	 	 	 	 	 	 	 	 	 	 	 dd„«       Zy)ÚMeanAveragePrecisiona4  
    !!! deprecated "Deprecated"
        `MeanAveragePrecision` is **deprecated** and will be removed in
        `supervision-0.31.0`.

        The deprecated implementation provides results that are inconsistent with
        `pycocotools`. Please use
        `supervision.metrics.mean_average_precision.MeanAveragePrecision` instead,
        which matches the results of `pycocotools` and is now the recommended approach.

    Mean Average Precision for object detection tasks.

    Attributes:
        map50_95: Mean Average Precision (mAP) calculated over IoU thresholds
            ranging from `0.50` to `0.95` with a step size of `0.05`.
        map50: Mean Average Precision (mAP) calculated specifically at
            an IoU threshold of `0.50`.
        map75: Mean Average Precision (mAP) calculated specifically at
            an IoU threshold of `0.75`.
        per_class_ap50_95: Average Precision (AP) values calculated over
            IoU thresholds ranging from `0.50` to `0.95` with a step size of `0.05`,
            provided for each individual class.
    r[   Úmap50_95Úmap50Úmap75únpt.NDArray[np.float64]Úper_class_ap50_95c                óÈ   — g }g }t        ||«      D ]=  \  }}|j                  t        |d¬«      «       |j                  t        |d¬«      «       Œ? | j                  ||¬«      S )ah  
        Calculate mean average precision based on predicted and ground-truth detections.

        Args:
            targets: Detections objects from ground-truth.
            predictions: Detections objects predicted by the model.
        Returns:
            New instance of ConfusionMatrix.

        Examples:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> targets = [
            ...     sv.Detections(
            ...         xyxy=np.array([[0, 0, 10, 10]]),
            ...         class_id=np.array([0])
            ...     )
            ... ]
            >>> predictions = [
            ...     sv.Detections(
            ...         xyxy=np.array([[0, 0, 10, 10]]),
            ...         class_id=np.array([0]),
            ...         confidence=np.array([0.9])
            ...     )
            ... ]
            >>> mAP = sv.MeanAveragePrecision.from_detections(
            ...     predictions=predictions,
            ...     targets=targets,
            ... )
            >>> round(float(mAP.map50), 2)
            0.99

            ```
        T)r7   FrS   rg   )rj   rI   rJ   rk   rl   rm   rN   s          r   rn   z$MeanAveragePrecision.from_detections  s}   € ðR  ÐØˆÜ"% k°7Ó";ò 	WÑˆJ˜Ø×%Ñ%Ü$ ZÀÔFôð ×!Ñ!Ô"6°vÈuÔ"UÕVð		Wð
 ×ÑØ*Ø"ð  ó 
ð 	
r   c                óš   — g g }}|D ]0  \  }}} ||«      }|j                  |«       |j                  |«       Œ2 | j                  ||¬«      S )aÀ  
        Calculate mean average precision from dataset and callback function.

        Args:
            dataset: Object detection dataset used for evaluation.
            callback: Function that takes
                an image as input and returns Detections object.
        Returns:
            New instance of MeanAveragePrecision.

        Example:
            ```python
            import supervision as sv
            from ultralytics import YOLO

            dataset = sv.DetectionDataset.from_yolo(...)

            model = YOLO(...)
            def callback(image: np.ndarray) -> sv.Detections:
                result = model(image)[0]
                return sv.Detections.from_ultralytics(result)

            mean_average_precision = sv.MeanAveragePrecision.benchmark(
                dataset = dataset,
                callback = callback
            )

            print(mean_average_precision.map50_95)
            # 0.433
            ```
        rS   )r4   rn   )	rj   r¥   r¦   rI   rJ   r§   r¨   r©   rª   s	            r   r«   zMeanAveragePrecision.benchmarkG  si   € ðJ  " 2�WˆØ$+ò 	'Ñ ˆAˆu�jÙ (¨£ÐØ×ÑÐ0Ô1Ø�N‰N˜:Õ&ð	'ð ×"Ñ"Ø#Øð #ó 
ð 	
r   c           	     óH  — t        ||«       t        j                  ddd«      }g }t        ||«      D ]Ê  \  }}|j                  d   dk(  rf|j                  d   rV|j                  t        j                  d|j                  ft        ¬«      gt        j                  d«      ¢|dd…df   ‘­«       Œ~|j                  d   sŒŽ| j                  |||«      }|j                  ||dd…d	f   |dd…df   |dd…df   f«       ŒÌ |rwt        |Ž D �cg c]  }t        j                  |d«      ‘Œ }	} | j                  |	Ž }
|
dd…df   j                  «       }|
dd…d	f   j                  «       }|
j                  «       }nd
\  }}}t        j                  g «      }
 | ||||
¬«      S c c}w )aY  
        Calculate Mean Average Precision based on predicted and ground-truth
            detections at different threshold.

        Args:
            predictions: Each element of the list describes
                a single image and has `shape = (M, 6)` where `M` is
                the number of detected objects. Each row is expected to be
                in `(x_min, y_min, x_max, y_max, class, conf)` format.
            targets: Each element of the list describes a single
                image and has `shape = (N, 5)` where `N` is the
                number of ground-truth objects. Each row is expected to be in
                `(x_min, y_min, x_max, y_max, class)` format.
        Returns:
            New instance of MeanAveragePrecision.

        Examples:
            ```pycon
            >>> import supervision as sv
            >>> import numpy as np
            >>> targets = [
            ...     np.array([
            ...         [0.0, 0.0, 3.0, 3.0, 0],
            ...         [2.0, 2.0, 5.0, 5.0, 0],
            ...         [6.0, 1.0, 8.0, 3.0, 1],
            ...     ])
            ... ]
            >>> predictions = [
            ...     np.array([
            ...         [0.0, 0.0, 3.0, 3.0, 0, 0.9],
            ...         [0.1, 0.1, 3.0, 3.0, 0, 0.9],
            ...         [6.0, 1.0, 8.0, 3.0, 1, 0.8],
            ...     ])
            ... ]
            >>> mAP = sv.MeanAveragePrecision.from_tensors(
            ...     predictions=predictions,
            ...     targets=targets,
            ... )
            >>> round(float(mAP.map50), 2)
            0.81

            ```
        rd   gffffffî?r@   r   r   )r   r   Nr   rC   )r   r   r   )r  r  r  r  )rM   r(   Úlinspacerh   r-   r4   rq   r/   r}   Ú_match_detection_batchr5   Ú_average_precisions_per_classÚmeanrx   )rj   rI   rJ   Úiou_thresholdsÚstatsÚ	true_objsÚpredicted_objsr¢   ÚitemsÚconcatenated_statsÚaverage_precisionsr  r  r  s                 r   ri   z!MeanAveragePrecision.from_tensorsv  sÁ  € ôb 	  ¨WÔ5ÜŸ™ S¨$°Ó3ˆØˆô *-¨W°kÓ)Bò 	Ñ%ˆI�~Ø×#Ñ# AÑ&¨!Ò+Ø—?‘? 1Ò%Ø—L‘LäŸH™H a¨×)<Ñ)<Ð%=ÄTÔJðäŸX™X fÓ-ðð &¢a¨ d™Oñôð à�‰˜qÓ!Ø×4Ñ4Ø" I¨~ó�ð —‘àØ&¢q¨! tÑ,Ø&¢q¨! tÑ,Ø!¢! Q $™ð	õð!	ñ4 ÜHKÈUÈÖ!T¸u¤"§.¡.°¸Õ":Ð!TÐÐ!TØ!B ×!BÑ!BÐDVÐ!WÐØ&¢q¨! tÑ,×1Ñ1Ó3ˆEØ&¢q¨! tÑ,×1Ñ1Ó3ˆEØ)×.Ñ.Ó0‰Hà%,Ñ"ˆE�5˜(Ü!#§¡¨"£ÐáØØØØ0ô	
ð 	
ùò "Us   ÄFc                óö  — t        j                  dg| dgf«      }t        j                  dg|dgf«      }t        j                  t         j                  j	                  t        j                  |«      «      «      }t        j
                  ddd«      }t        j                  |||«      }t        t         d«      r!t        j                  ||«      }t        |«      S  t        t         d«      ||«      }t        |«      S )a  
        Compute the average precision using 101-point interpolation (COCO), given
            the recall and precision curves.

        Args:
            recall: The recall curve.
            precision: The precision curve.

        Returns:
            Average precision.
        g        g      ð?r   r   ée   Ú	trapezoidÚtrapz)r(   r5   ÚflipÚmaximumÚ
accumulater  ÚinterpÚhasattrr&  Úgetattrr[   )ÚrecallÚ	precisionÚextended_recallÚextended_precisionÚmax_accumulated_precisionÚinterpolated_recall_levelsÚinterpolated_precisionÚaverage_precisions           r   Úcompute_average_precisionz.MeanAveragePrecision.compute_average_precision×  sç   € ô  Ÿ.™.¨3¨%°¸#¸Ð)?Ó@ˆÜŸ^™^¨c¨U°IÀ¸uÐ,EÓFÐÜ$&§G¡GÜ�J‰J×!Ñ!¤"§'¡'Ð*<Ó"=Ó>ó%
Ð!ô &(§[¡[°°A°sÓ%;Ð"Ü!#§¡Ø&¨Ð9Ró"
Ðô
 ”2�{Ô#Ü "§¡Ø&Ð(Bó!Ðô Ð&Ó'Ð'ð	 !5¤¬¨GÓ 4Ø&Ð(Bó!Ðô Ð&Ó'Ð'r   c                ó  — | j                   d   |j                   d   }}t        j                  ||ft        ¬«      }t	        |dd…dd…f   | dd…dd…f   «      }|dd…dd…f   | dd…df   k(  }t        |«      D �]  \  }}	t        j                  ||	k\  |z  «      }
|
d   j                   d   sŒ5t        j                  |
d¬«      }||
   dd…df   }t        j                  ||g«      }|
d   j                   d   dkD  rh||dd…df   j                  «       ddd	…      }|t        j                  |dd…df   d
¬«      d      }|t        j                  |dd…df   d
¬«      d      }d
||dd…df   j                  t        «      |f<   �Œ |}|S )a   
        Match predictions with target labels based on IoU levels.

        Args:
            predictions: Batch prediction. Describes a single image and
                has `shape = (M, 6)` where `M` is the number of detected objects.
                Each row is expected to be in
                `(x_min, y_min, x_max, y_max, class, conf)` format.
            targets: Batch target labels. Describes a single image and
                has `shape = (N, 5)` where `N` is the number of ground-truth objects.
                Each row is expected to be in
                `(x_min, y_min, x_max, y_max, class)` format.
            iou_thresholds: Array contains different IoU thresholds.

        Returns:
            Matched prediction with target labels result.
        r   r   Nr   rC   r   r!   r   r    Trž   )r-   r(   rq   r}   r   r€   ÚwhereÚstackÚhstackr    r¡   r2   r|   )rI   rJ   r  Únum_predictionsÚnum_iou_levelsÚcorrectr›   Úcorrect_classrø   Ú	iou_levelÚmatched_indicesÚcombined_indicesÚ
iou_valuesr¢   r<   s                  r   r  z+MeanAveragePrecision._match_detection_batchý  s¨  € ð. +6×*;Ñ*;¸AÑ*>À×@TÑ@TÐUVÑ@W˜ˆÜ—(‘(˜O¨^Ð<ÄDÔIˆÜ˜G¢A r¨ r E™N¨Kº¸2¸A¸2¸Ñ,>Ó?ˆØ¢ 1 Q 3 ™¨;²q¸!°tÑ+<Ñ<ˆä% nÓ5ó 	=‰LˆAˆyÜ Ÿh™h¨¨yÑ(8¸MÑ'IÓJˆOà˜qÑ!×'Ñ'¨Ó*Ü#%§8¡8¨OÀ!Ô#DÐ Ø  Ñ1²!°T°'Ñ:�
ÜŸ)™)Ð%5°zÐ$BÓC�à" 1Ñ%×+Ñ+¨AÑ.°Ò2Ø% gªa°¨d¡m×&;Ñ&;Ó&=¹dÀ¸dÑ&CÑD�GØ%¤b§i¡i°º¸1¸±ÈDÔ&QÐRSÑ&TÑU�GØ%¤b§i¡i°º¸1¸±ÈDÔ&QÐRSÑ&TÑU�Gà8<�˜¢ 1 ™×,Ñ,¬SÓ1°1Ð4Ó5ð	=ð )0ˆØˆr   c                óv  — t        j                  | «      }| |   } ||   }t        j                  |d¬«      \  }}|j                  d   }t        j                  || j                  d   ft         j
                  ¬«      }	t        |«      D ]«  \  }
}||k(  }||
   }|j                  «       }|dk(  s|dk(  rŒ+d| |   z
  j                  d«      }| |   j                  d«      }|||z   z  }|||z   z  }t        | j                  d   «      D ]+  }t        j                  |dd…|f   |dd…|f   «      |	|
|f<   Œ- Œ­ |	}|S )a  
        Compute the average precision, given the recall and precision curves.
        Source: https://github.com/rafaelpadilla/Object-Detection-Metrics.

        Args:
            matches: True positives.
            prediction_confidence: Objectness value from 0-1.
            prediction_class_ids: Predicted object classes.
            true_class_ids: True object classes.
            eps: Small value to prevent division by zero.

        Returns:
            Average precision for different IoU levels.
        T)Úreturn_countsr   r   r   N)r(   r    r¡   r-   rq   Úfloat64r€   rÑ   Úcumsumrá   r  r6  )r¢   Úprediction_confidenceÚprediction_class_idsÚtrue_class_idsrî   Úsorted_indicesÚunique_classesÚclass_countsrp   r#  Ú	class_idxr#   Úis_classÚ
total_trueÚtotal_predictionÚfalse_positivesÚtrue_positivesr.  r/  Úiou_level_idxr<   s                        r   r  z2MeanAveragePrecision._average_precisions_per_class*  sn  € ô, Ÿ™Ð%:Ð$:Ó;ˆØ˜.Ñ)ˆØ3°NÑCÐä')§y¡y°ÈtÔ'TÑ$ˆ˜Ø$×*Ñ*¨1Ñ-ˆä68·h±hØ˜'Ÿ-™-¨Ñ*Ð+´2·:±:ô7
Ðô $-¨^Ó#<ò 	ÑˆI�xØ+¨xÑ7ˆHØ% iÑ0ˆJØ'Ÿ|™|›~Ðà 1Ò$¨
°aªØà  7¨8Ñ#4Ñ4×<Ñ<¸QÓ?ˆOØ$ XÑ.×5Ñ5°aÓ8ˆNØ# z°CÑ'7Ñ8ˆFØ&¨.¸?Ñ*JÑKˆIä!& w§}¡}°QÑ'7Ó!8ò �ä(×BÑBØšq -Ð/Ñ0°)ºA¸}Ð<LÑ2Móð # 9¨mÐ#;Ò<ñð	ð( +=ˆØˆr   N)rI   rþ   rJ   rþ   rý   r  )r¥   r   r¦   r  rý   r  )rI   rÿ   rJ   rÿ   rý   r  )r.  r  r/  r  rý   r[   )rI   r   rJ   r   r  r   rý   únpt.NDArray[np.bool_])g¼‰Ø—²Òœ<)r¢   rT  rG  r   rH  rW   rI  rW   rî   r[   rý   r  )r  r  r  r  r  r  rn   r«   ri   r  r6  r  r  r  r   r   r  r  î  sn  … ñð0 ƒOØƒLØƒLØ.Ó.àð2
à%ð2
ð "ð2
ð 
ò	2
ó ð2
ðh ð,
à!ð,
ð @ð,
ð 
ò	,
ó ð,
ð\ ð^
à2ð^
ð /ð^
ð 
ò	^
ó ð^
ð@ ð#(Ø'ð#(à*ð#(ð 
ò#(ó ð#(ðJ ð*Ø,ð*à(ð*ð 0ð*ð 
ò	*ó ð*ðX ð ð5Ø&ð5à6ð5ð 4ð5ð .ð	5ð
 ð5ð 
!ò5ó ñ5r   r  )r   r   rý   ÚNone)r6   r   r7   r}   r   r   rý   r   )rI   rÿ   rJ   rÿ   r   r   rý   rU  )rI   rÿ   rJ   rÿ   rý   rU  )'Ú
__future__r   Úcollections.abcr   Údataclassesr   Ú
matplotlibÚmatplotlib.pyplotÚpyplotrÓ   Únumpyr(   Únumpy.typingÚtypingÚnptÚ	deprecater   r   r   r	   Úsupervision.configr
   Úsupervision.dataset.corer   Úsupervision.detection.corer   Ú'supervision.detection.utils.iou_and_nmsr   r   Úsupervision.metrics.corer   r   r	  r=   rM   rT   rV   ÚNOTIFYr  r  r   r   ú<module>rg     sB  ðÝ "å $Ý !ã Ý Û Ý ß DÓ Då 7Ý 5Ý 1÷õ 2ó
ð "Ø".×"4Ñ"4ðrØðràðrð  ðrð ó	rðp #/×"4Ñ"4ð&Ø.ð&à*ð&ð  ð&ð 
ó	&ñR Ø"ØØôð
Ø.ðà*ðð 
òóð
ð ÷cð có ðcñL Ø×ÑØØôñ
 �$Ô÷lð ló óñlr   