+
    åûjÄ4  ã                   óN   € ^ RI HtHtHt ^ RIt^ RIHtHt ^RIH	t	 RR R llt
R# )é    )ÚDictÚListÚTupleN)ÚKORNIA_CHECKÚKORNIA_CHECK_SAME_SIZE)Úmean_iou_bboxc                ó¢  € V ^8„  d   QhR\         \        P                  ,          R\         \        P                  ,          R\         \        P                  ,          R\         \        P                  ,          R\         \        P                  ,          R\        R\        R\
        \        P                  \        \        \        3,          3,          /# )	é   Ú
pred_boxesÚpred_labelsÚpred_scoresÚgt_boxesÚ	gt_labelsÚ	n_classesÚ	thresholdÚreturn)r   ÚtorchÚTensorÚintÚfloatr   r   )Úformats   "ÚaC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\metrics\mean_average_precision.pyÚ__annotate__r      s¦   € ÷ Pñ PÜ”U—\‘\Õ"ðPä”e—l‘lÕ#ðPô ”e—l‘lÕ#ðPô ”5—<‘<Õ ð	Pô
 ”E—L‘LÕ!ðPô ðPô ðPô Œ5�<‰<œœc¤5˜jÕ)Ð)Õ*ñPó    c                ó(  aa6€ \        \        V 4      \        V4      u;8H  ;'       d=    \        V4      u;8H  ;'       d&    \        V4      u;8H  ;'       d    \        V4      8H  Mu R\        V 4       R\        V4       R\        V4       R\        V4       R\        V4       2
4       . p\        \        W44      4       FA  w  pw  rš\	        WšRV R2R7       VP                  V.V
P                  ^ 4      ,          4       KC  	  \        P                  ! V^ 4      p\        P                  ! V^ 4      p\        P                  ! W{P                  \        P                  R	7      p. p\        \        WV4      4       FX  w  pw  ršpR
V
3RV33 F  w  o6p\	        V	VRS6 RV R2R7       K  	  VP                  V.V
P                  ^ 4      ,          4       KZ  	  \        P                  ! V ^ 4      p\        P                  ! V^ 4      p\        P                  ! V^ 4      p\        P                  ! VVP                  \        P                  R	7      p\        P                  ! VP                  4       '       d   VP                  M\        P                  VP                  4       '       d   VP                  M\        P                  4      pR
V3RV33 F‰  w  o6p
\        \!        V
^ 8¬  V
S8  ,          P#                  4       4      VV63R l4       V
P                  4       '       g   KS  \        \!        WªP%                  4       8H  P#                  4       4      S6 R24       K‹  	  \        P&                  ! S^,
          VP                  VR	7      p\)        ^S4       EFs  pWÜV8H  ,          pW¼V8H  ,          pVP                  ^ 4      ^ 8X  d   RVV^,
          &   K>  \        P&                  ! VP                  ^ 4      \        P*                  VP                  R7      pVVV8H  ,          pVVV8H  ,          pVVV8H  ,          pVP                  ^ 4      pV^ 8X  d   K¼  \        P,                  ! V^ RR7      w  ppVV,          pVV,          p\        P&                  ! V3VVP                  R7      p \        P&                  ! V3VVP                  R7      p!\)        V4       EF  p"VV",          P/                  ^ 4      p#VV",          p$VVV$8H  ,          p%V%P                  ^ 4      ^ 8X  d   ^V!V"&   KN  \1        V#V%4      p&\        P2                  ! V&P5                  ^ 4      ^ R7      w  p'p(\        P                  ! \)        VP                  ^ 4      4      VP                  \        P                  R	7      VV$8H  ,          V(,          p)V'P7                  4       V8”  d$   VV),          ^ 8X  d   ^V V"&   ^VV)&   EK  ^V!V"&   EK  ^V!V"&   EK  	  \        P8                  ! V ^ R7      p*\        P8                  ! V!^ R7      p+V*V*V+,           R,           ,          p,V*VP                  ^ 4      ,          p-\)        ^4       Uu. uF  qˆ^
,          NK  	  p.p\        P&                  ! \        V.4      VP                  VR	7      p/\        V.4       FB  w  pp0V-V08¬  p1V1P;                  4       '       d   V,V1,          P3                  4       V/V&   K=  RV/V&   KD  	  V/P=                  4       VV^,
          &   EKv  	  VV^ 8¬  ,          p2V2P?                  4       '       d   V2P=                  4       MVPA                  R4      p3\        VPC                  4       4       UU4u/ uF  w  pp4V^,           \E        V44      bK  	  p5pp4V3V53# u upi u up4pi )a|  Compute the PASCAL VOC mean average precision (mAP) of detections over a set of images.

``mAP, ap = mean_average_precision(pred_boxes, pred_labels, pred_scores, gt_boxes, gt_labels, n_classes)`` takes
one tensor per image in each list. It returns the mean over the scored classes of their 11-point interpolated AP
as a 0-d tensor, and a dict of the per-class APs. Both are fractions in :math:`[0, 1]`, or ``-1.0`` where there
is no object to score.

Convention:
    - The call raises when the five lists differ in length, when the boxes, labels and scores of an image differ
      in their number of rows, or when a label lies outside ``[0, n_classes)`` or is not a whole number: a
      floating-point label such as ``1.0`` counts as class 1, and ``1.5`` raises. Boxes are exclusive ``xyxy``,
      the default format of :func:`~kornia.metrics.mean_iou_bbox`, which computes the overlaps.
    - Class 0 is background: its objects and detections are never scored, and ``n_classes`` counts it, so the
      classes ``1`` to ``n_classes - 1`` are scored.
    - The detections of a class are ranked by score over all images at once, so the AP is not a mean of
      per-image APs. In that order, a detection takes the object of its image and class that it overlaps most;
      it is a true positive when that IoU is strictly greater than ``threshold`` and the object is not taken
      yet, and a false positive otherwise. A class with objects and no detection has AP 0.
    - A class without objects in any image has no AP: its entry is ``-1.0`` and it stays out of the mean, so
      neither a larger ``n_classes`` nor detections of such a class change the mAP. Without any foreground
      object the mAP is ``-1.0`` too.
    - The AP is the 11-point interpolated AP of PASCAL VOC2007: the mean, over the recall levels
      ``0, 0.1, ..., 1``, of the highest precision at a recall of at least that level.
    - The mAP takes the floating dtype of the boxes: integer boxes count as float32, and predicted and
      ground-truth boxes of different dtypes give the promotion of those two floating dtypes (float32 when one
      set is integer and the other float16). :ref:`Losses and metrics <losses-metrics-conventions>` compares the
      match rule with the VOC devkit and COCO.

Args:
    pred_boxes: per-image predicted boxes, each with shape ``(N, 4)``.
    pred_labels: per-image predicted class labels, each with shape ``(N,)``.
    pred_scores: per-image confidence scores, each with shape ``(N,)``.
    gt_boxes: per-image ground-truth boxes, each with shape ``(M, 4)``.
    gt_labels: per-image ground-truth class labels, each with shape ``(M,)``.
    n_classes: the number of classes, background (class 0) included.
    threshold: the IoU a detection must exceed to be a true positive.

Returns:
    the mAP and a dict mapping each foreground class id, 1 to ``n_classes - 1``, to its AP.

See Also:
    - :func:`~kornia.metrics.mean_iou_bbox`: the pairwise box IoU the matching uses, as a matrix.

Examples:
    >>> boxes, labels, scores = torch.tensor([[100, 50, 150, 100.]]), torch.tensor([1]), torch.tensor([.7])
    >>> gt_boxes, gt_labels = torch.tensor([[100, 50, 150, 100.]]), torch.tensor([1])
    >>> mean_average_precision([boxes], [labels], [scores], [gt_boxes], [gt_labels], 2)
    (tensor(1.), {1: 1.0})

Reference:
    Adapted from https://github.com/sgrvinod/a-PyTorch-Tutorial-to-Object-Detection/blob/master/utils.py#L271.

zDThe five per-image lists must have the same length. Got: pred_boxes z, pred_labels z, pred_scores z, gt_boxes z, gt_labels zJgt_boxes and gt_labels must have one row per object in every image (image ú).)Úmsg)ÚdeviceÚdtyper   r   zpred_boxes and z7 must have one row per detection in every image (image r   c                  ó   <€ S R S  R2# )z& must satisfy 0 <= label < n_classes (r   © )r   Únames   €€r   Ú<lambda>Ú(mean_average_precision.<locals>.<lambda>†   s   ø€ �t�fÐBÀ9À+ÈRÑPr   z$ must contain integer-valued labels.)r   r   T)ÚdimÚ
descending)r%   g»½×Ùß|Û=g        g      ð¿)#r   ÚlenÚ	enumerateÚzipr   ÚextendÚsizer   ÚcatÚtensorr   ÚlongÚpromote_typesÚis_floating_pointr   Úfloat32ÚboolÚallÚroundÚzerosÚrangeÚuint8ÚsortÚ	unsqueezer   ÚmaxÚsqueezeÚitemÚcumsumÚanyÚmeanÚnumelÚ
new_tensorÚtolistr   )7r   r   r   r   r   r   r   Ú	gt_imagesÚiÚboxesÚlabelsÚ	_gt_boxesÚ
_gt_labelsÚ
_gt_imagesÚpred_imagesÚscoresÚotherÚ_pred_boxesÚ_pred_labelsÚ_pred_scoresÚ_pred_imagesÚap_dtypeÚaverage_precisionsÚcÚgt_class_imagesÚgt_class_boxesÚgt_class_boxes_detectedÚpred_class_imagesÚpred_class_boxesÚpred_class_scoresÚn_class_detectionsÚsort_indÚgt_positivesÚfalse_positivesÚdÚthis_detection_boxÚ
this_imageÚobject_boxesÚoverlapsÚmax_overlapÚindÚoriginal_indÚcumul_gt_positivesÚcumul_false_positivesÚcumul_precisionÚcumul_recallÚrecall_thresholdsÚ
precisionsÚtÚrecalls_above_tÚdefined_precisionsÚmean_apÚvÚap_dictr"   s7   &&&&&f&                                               @r   Úmean_average_precisionrr      sÎ  ù€ ô~ ÜˆJ‹œ3˜{Ó+×bÔb¬s°;Ó/?×bÔbÄ3ÀxÃ=×bÔbÔTWÐXaÓTbÔbð	Ü˜*“oÐ& n´S¸Ó5EÐ4FÀnÔUXÐYdÓUeÐTfð gÜ˜“M�? ,¬s°9«~Ð.>ð	@ôð €IÜ'¬¨HÓ(@ÖAÑˆ‰?ˆEÜØÐ!kÐlmÐknÐnpÐqõ	
ð 	×Ñ˜!˜˜vŸ{™{¨1›~Õ-Ö.ñ	 Bô —	’	˜( AÓ&€IÜ—’˜9 aÓ(€JÜ—’˜i×0@Ñ0@ÌÏ
É
ÔS€Jð €KÜ&/´°JÈ[Ó0YÖ&ZÑ"ˆÑ"ˆE˜6Ø*¨FÐ3°mÀVÐ5LÓM‰KˆD�%Ü"Ø�u O°D°6Ð9pÐqrÐpsÐsuÐ"v÷ñ Nð 	×Ñ˜A˜3 §¡¨Q£Õ/Ö0ñ '[ô —)’)˜J¨Ó*€KÜ—9’9˜[¨!Ó,€LÜ—9’9˜[¨!Ó,€LÜ—<’< °K×4FÑ4FÌeÏjÉjÔY€Lô ×"Ò"Ø(×:Ñ:×<Ò<ˆ×ÒÄ%Ç-Á-Ø$×6Ñ6×8Ò8ˆ	�Š¼e¿m¹mó€Hð (¨Ð6¸ÀjÐ8QÓR‰ˆˆfÜÜ�6˜Q‘; 6¨IÑ#5Õ6×;Ñ;Ó=Ó>ÝPô	
ð ×#Ñ#×%Ô%Üœ˜v¯©«Ñ7×<Ñ<Ó>Ó?ÀDÀ6ÐImÐAnÖoñ Sô Ÿš i°!¥m¸[×=OÑ=OÐW_Ô`ÐÜ�1�i× ˆà$°1¡_Õ5ˆØ"°¡?Õ3ˆà×Ñ Ó" aÔ'Ø(,Ð˜q 1�uÑ%Ùô #(§+¢+Ø×!Ñ! !Ó$¬U¯[©[À×AWÑAWô#
Ðð
 )¨¸Ñ):Õ;ÐØ& |°qÑ'8Õ9ÐØ(¨¸Ñ):Õ;ÐØ-×2Ñ2°1Ó5ÐØ Ô"Ùô ',§j¢jÐ1BÈÐVZÔ&[Ñ#Ð˜8Ø-¨hÕ7ÐØ+¨HÕ5Ðô —{’{Ð$6Ð#8ÀÐQa×QhÑQhÔiˆÜŸ+š+Ð'9Ð&;À8ÐTd×TkÑTkÔlˆÜÐ)×*ˆAØ!1°!Õ!4×!>Ñ!>¸qÓ!AÐØ*¨1Õ-ˆJð *¨/¸ZÑ*GÕHˆLà× Ñ  Ó# qÔ(Ø%&� Ñ"Ùô %Ð%7¸ÓFˆHÜ$Ÿyšy¨×)9Ñ)9¸!Ó)<À!ÔDÑˆK˜ô !Ÿ<š<Ü�n×)Ñ)¨!Ó,Ó-Ð6M×6TÑ6TÔ\a×\fÑ\fôà Ñ+õ-à-0õ2ˆLð ×ÑÓ! IÔ-à*¨<Õ8¸AÔ=Ø&'�L ‘OØ<=Ð+¨LÔ9ð *+�O AÔ&ð &'� Ô"ñC +ôH #Ÿ\š\¨,¸AÔ>ÐÜ %§¢¨_À!Ô DÐØ,ØÐ!6Õ6¸Õ>õ
ˆð *¨O×,@Ñ,@ÀÓ,CÕCˆô
 .3°2¬YÓ7©Y¨ ŸV˜V©YÐÐ7Ü—[’[¤#Ð&7Ó"8À)×BRÑBRÐZbÔcˆ
ÜÐ/Ö0‰DˆAˆqØ*¨aÑ/ˆOØ×"Ñ"×$Ò$Ø /°Õ @× DÑ DÓ F�
˜1“à #�
˜1“ñ 1ð %/§O¡OÓ$5Ð˜1˜q�5Ô!ñk !ðp ,Ð,>À!Ñ,CÕDÐØ+=×+CÑ+C×+EÒ+EÐ ×%Ñ%Ô'ÐK]×KhÑKhÐimÓKn€Gô ,5Ð5G×5NÑ5NÓ5PÔ+QÔRÑ+Q¡4 1 aˆq�1�u”e˜A“hŠÑ+Q€GÑRà�GÐÐùò# 8ùó Ss   Ù^	Ý#^)g      à?)Útypingr   r   r   r   Úkornia.core.checkr   r   Úmean_iour   rr   r!   r   r   Ú<module>rv      s"   ð÷$ %Ñ $ã ç Bå #÷Pñ Pr   