+
    åûj=(  ã                   ó^   € ^ RI t ^ RIHt ^RIHt RR R lltR R ltR R	 ltRR
 R lltR# )é    N)Úis_compiling)Úconfusion_matrixc          
      ó�   € V ^8„  d   QhR\         P                  R\         P                  R\        R\        R\         P                  /# )é   ÚpredÚtargetÚnum_classesÚepsÚreturn)ÚtorchÚTensorÚintÚfloat)Úformats   "ÚSC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\metrics\mean_iou.pyÚ__annotate__r      s>   € ÷ /7ñ /7”5—<‘<ð /7¬¯©ð /7ÄCð /7Ìeð /7Ô_d×_kÑ_kñ /7ó    c                óô   € \        WV4      p\        P                  ! V^R7      p\        P                  ! V^R7      p\        P                  ! VRRR7      pWV,           V,
          pWs,           Wƒ,           ,          # )aò  Compute the IoU of every class in every sample from label maps.

``iou = mean_iou(pred, target, num_classes)`` takes class labels of shape ``(B, *)`` and returns float32 IoUs in
:math:`[0, 1]` with shape ``(B, K)``. Despite the name, nothing is averaged.

Convention:
    - The labels follow :func:`~kornia.metrics.confusion_matrix`, whose counts the IoU is computed from. To
      average, take the mean over :math:`B` for the mean of per-image IoUs; for the IoU of a whole dataset, sum
      the confusion matrices over all images and take the IoU of the sum.
    - ``eps`` is added to the numerator and the denominator, so a class absent from both maps scores 1 (NaN with
      ``eps=0``), and a class only predicted or only in the target scores about 0. Exclude absent classes before
      averaging over :math:`K`: a larger ``num_classes`` can only raise the average.
      :ref:`Losses and metrics <losses-metrics-conventions>` compares this absent-class rule with the losses,
      :func:`~kornia.metrics.mean_average_precision` and scikit-learn.

Args:
    pred: predicted class labels in :math:`[0, K)`, with shape ``(B, *)``.
    target: ground-truth class labels in :math:`[0, K)`, with the shape of ``pred``.
    num_classes: the number of classes :math:`K`, at least 2.
    eps: the value added to the numerator and the denominator of every IoU.

Returns:
    the IoU of every class, with shape ``(B, K)``.

See Also:
    - :func:`~kornia.metrics.confusion_matrix`: the per-sample counts the IoU is computed from.
    - :func:`~kornia.metrics.mean_iou_bbox`: the IoU of boxes, not label maps.

Example:
    >>> logits = torch.tensor([[0, 1, 0]])
    >>> target = torch.tensor([[0, 1, 0]])
    >>> mean_iou(logits, target, num_classes=3)
    tensor([[1., 1., 1.]])

©Údim)Údim1Údim2éþÿÿÿéÿÿÿÿ)r   r   ÚsumÚdiagonal)	r   r   r	   r
   Úconf_matÚsum_over_rowÚsum_over_colÚconf_mat_diagÚdenominators	   &&&&     r   Úmean_iour"      se   € ôJ .¨d¸KÓH€Hô —9’9˜X¨1Ô-€LÜ—9’9˜X¨1Ô-€LÜ—N’N 8°"¸2Ô>€MØÕ-°Õ=€Kð Õ KÕ$5Õ6Ð6r   c                ód   € V ^8„  d   QhR\         P                  R\        R\         P                  /# )r   ÚboxesÚ
box_formatr   ©r   r   Ústr)r   s   "r   r   r   K   s.   € ÷ kñ k¤%§,¡,ð k¼Cð kÄEÇLÁLñ kr   c                óâ  € VR8X  d   V # VR8X  dP   V R,          V R,          V R	,          V R
,          3w  r#rEW$,           pW5,           p\         P                  ! W#Wg.^R7      # VR8X  d|   V R,          V R,          V R	,          V R
,          3w  r‰rEW„^,          ,
          p
W•^,          ,
          pW„^,          ,           pW•^,          ,           p\         P                  ! W«Wg.^R7      # \        RV R24      h)zîConvert bounding boxes from various formats to xyxy format.

Args:
    boxes: tensor of bounding boxes in shape (N, 4).
    box_format: box format - one of 'xyxy', 'xywh', or 'cxcywh'.

Returns:
    boxes in xyxy format (x1, y1, x2, y2).
ÚxyxyÚxywhr   ÚcxcywhzUnsupported box format: z-. Must be one of 'xyxy', 'xywh', or 'cxcywh'.)ºNNN:r   é   N)r,   :r-   r   N)r,   :r   é   N)r,   :r.   é   N)r   ÚcatÚ
ValueError)r$   r%   ÚxÚyÚwÚhÚx2Úy2ÚcxÚcyÚx1Úy1s   &&          r   Ú_convert_boxes_to_xyxyr<   K   sà   € ð �VÔØˆØ�VÔà˜6•] E¨&¥M°5¸µ=À%ÈÅ-ÐO‰
ˆˆaØ�UˆØ�UˆÜ�yŠy˜! ˜¨QÔ/Ð/Ø�XÔà˜V•} e¨F¥m°U¸6µ]ÀEÈ&ÅMÐQ‰ˆ�Ø�a•%�ZˆØ�a•%�ZˆØ�a•%�ZˆØ�a•%�ZˆÜ�yŠy˜" "Ð)¨qÔ1Ð1Ü
Ð/°
¨|Ð;hÐiÓ
jÐjr   c                óX   € V ^8„  d   QhR\         P                  R\         P                  /# )r   r$   r   )r   r   )r   s   "r   r   r   h   s&   € ÷ Kñ K¤%§,¡,ð K´5·<±<ñ Kr   c                óp   € V P                  4       '       d   V # V P                  \        P                  4      # )zVReturn integer and bool boxes as float32; floating point boxes are returned unchanged.)Úis_floating_pointÚtor   Úfloat32)r$   s   &r   Ú_promote_integer_boxesrB   h   s(   € à×+Ñ+×-Ò-ˆ5ÐJ°5·8±8¼E¿M¹MÓ3JÐJr   c                ó„   € V ^8„  d   QhR\         P                  R\         P                  R\        R\         P                  /# )r   Úboxes_1Úboxes_2r%   r   r&   )r   s   "r   r   r   m   sC   € ÷ d\ñ d\œ5Ÿ<™<ð d\´%·,±,ð d\ÌCð d\Ô]b×]iÑ]iñ d\r   c                óÎ  € \        V 4      p \        V4      p\        P                  ! V P                  VP                  4      pV P                  \        P                  \        P
                  39   d   V P                  4       p VP                  \        P                  \        P
                  39   d   VP                  4       p\        W4      p\        W4      p\        P                  P                  4       '       g   \        4       '       gÏ   VR,          VR,          ,
          ^ 8„  P                  4       '       d/   VR,          VR,          ,
          ^ 8„  P                  4       '       g   \        R4      hVR,          VR,          ,
          ^ 8„  P                  4       '       d/   VR,          VR,          ,
          ^ 8„  P                  4       '       g   \        R4      h\        P                  ! VR,          P                  ^4      VR,          P                  ^ 4      4      p\        P                  ! VR	,          P                  ^4      VR	,          P                  ^ 4      4      p\        P                   ! Wv,
          ^ R7      pVR
,          VR,          ,          p	VR,          VR,          ,
          VR,          VR,          ,
          ,          p
VR,          VR,          ,
          VR,          VR,          ,
          ,          pV
P                  ^4      VP                  ^ 4      ,           V	,
          pWœ,          pV\        P                  \        P
                  39   d   VP#                  V4      # T# )a
  Compute the IoU of every pair of boxes from two sets.

``iou = mean_iou_bbox(boxes_1, boxes_2)`` takes boxes of shape ``(B1, 4)`` and ``(B2, 4)`` and returns the IoU of
each box of the first set with each box of the second, as fractions in :math:`[0, 1]`. Despite the name, nothing
is averaged.

Convention:
    - Boxes are exclusive in every ``box_format``: the area of ``(x1, y1, x2, y2)`` is
      :math:`(x_2 - x_1)(y_2 - y_1)`, with no ``+ 1``, as in :func:`~kornia.geometry.bbox.nms`. A box with a
      non-positive width or height raises ``AssertionError``, unless the call captures a graph
      (``torch.compile`` or ``torch.export``), which skips the check and gives such a box an IoU of 0 or NaN. A
      :class:`~kornia.geometry.boxes.Boxes` gives the same IoU through ``to_tensor('xyxy')``, not through its
      inclusive ``'xyxy_plus'`` export.
    - Swapping the two sets transposes the result.

Args:
    boxes_1: the first set of boxes, with shape ``(B1, 4)``.
    boxes_2: the second set of boxes, with shape ``(B2, 4)``.
    box_format: ``'xyxy'`` for ``(x1, y1, x2, y2)`` with the top-left and bottom-right corners, ``'xywh'`` for
        ``(x, y, w, h)`` with the top-left corner, or ``'cxcywh'`` for ``(cx, cy, w, h)`` with the center.

Returns:
    the IoU matrix with shape ``(B1, B2)``.

.. note::
    Integer (and bool) boxes are computed in ``float32``, so the result is ``float32`` and widths, areas and the
    union do not wrap around in a narrow integer dtype such as ``uint8``, ``int8`` or ``int16``.

See Also:
    - :func:`~kornia.metrics.mean_iou`: the IoU of label maps, not boxes.
    - :func:`~kornia.metrics.mean_average_precision`: scores detections with this IoU.

Example:
    >>> # XYXY format
    >>> boxes_1 = torch.tensor([[40, 40, 60, 60], [30, 40, 50, 60]])
    >>> boxes_2 = torch.tensor([[40, 50, 60, 70], [30, 40, 40, 50]])
    >>> mean_iou_bbox(boxes_1, boxes_2)
    tensor([[0.3333, 0.0000],
            [0.1429, 0.2500]])
    >>> # XYWH format
    >>> boxes_1_xywh = torch.tensor([[40, 40, 20, 20], [30, 40, 20, 20]])
    >>> boxes_2_xywh = torch.tensor([[40, 50, 20, 20], [30, 40, 10, 10]])
    >>> mean_iou_bbox(boxes_1_xywh, boxes_2_xywh, box_format='xywh')
    tensor([[0.3333, 0.0000],
            [0.1429, 0.2500]])
    >>> # CXCYWH format
    >>> boxes_1_cxcywh = torch.tensor([[50, 50, 20, 20], [40, 50, 20, 20]])
    >>> boxes_2_cxcywh = torch.tensor([[50, 60, 20, 20], [35, 45, 10, 10]])
    >>> mean_iou_bbox(boxes_1_cxcywh, boxes_2_cxcywh, box_format='cxcywh')
    tensor([[0.3333, 0.0000],
            [0.1429, 0.2500]])

z0Boxes_1 contains invalid boxes after conversion.z0Boxes_2 contains invalid boxes after conversion.)Úmin)r,   r   )r,   r   )r,   r.   )r,   r-   )r,   :Nr   N)r,   :r   NN)r,   r,   r   )r,   r,   r-   )rB   r   Úpromote_typesÚdtypeÚfloat16Úbfloat16r   r<   ÚjitÚis_scriptingr   ÚallÚAssertionErrorÚmaxÚ	unsqueezerG   Úclampr@   )rD   rE   r%   Úoutput_dtypeÚboxes_1_xyxyÚboxes_2_xyxyÚlower_boundsÚupper_boundsÚintersection_dimsÚintersectionÚareas_set_1Úareas_set_2ÚunionÚious   &&&           r   Úmean_iou_bboxr^   m   s�  € ôr % WÓ-€GÜ$ WÓ-€Gä×&Ò& w§}¡}°g·m±mÓD€Lð ‡}�}œŸ™¬¯©Ð7Ô7Ø—-‘-“/ˆØ‡}�}œŸ™¬¯©Ð7Ô7Ø—-‘-“/ˆô *¨'Ó>€LÜ)¨'Ó>€Lô ‡y�y×Ñ×Ò¤|§~¢~à˜4Õ  <°Õ#5Õ5¸Ñ:×?Ñ?×AÒAØ˜tÕ$ |°DÕ'9Õ9¸QÑ>×CÑC×EÒEä Ð!SÓTÐTà˜4Õ  <°Õ#5Õ5¸Ñ:×?Ñ?×AÒAØ˜tÕ$ |°DÕ'9Õ9¸QÑ>×CÑC×EÒEä Ð!SÓTÐTô —9’9˜\¨%Õ0×:Ñ:¸1Ó=¸|ÈEÕ?R×?\Ñ?\Ð]^Ó?_Ó`€LÜ—9’9˜\¨%Õ0×:Ñ:¸1Ó=¸|ÈEÕ?R×?\Ñ?\Ð]^Ó?_Ó`€LÜŸš LÕ$?ÀQÔGÐØ$ WÕ-Ð0AÀ'Õ0JÕJ€Lð   Õ%¨°TÕ(:Õ:¸|ÈDÕ?QÐT`ÐaeÕTfÕ?fÕg€KØ Õ%¨°TÕ(:Õ:¸|ÈDÕ?QÐT`ÐaeÕTfÕ?fÕg€Kð ×!Ñ! !Ó$ {×'<Ñ'<¸QÓ'?Õ?À,ÕN€Eà
Õ
€CØ#/´E·M±MÄ5Ç>Á>Ð3RÔ#Rˆ3�6‰6�,ÓÐ[ÐX[Ð[r   )g�íµ ÷Æ°>)r)   )r   Úkornia.core.utilsr   r   r"   r<   rB   r^   © r   r   Ú<module>ra      s0   ðó$ å *å .÷/7õdkõ:K÷
d\ñ d\r   