§
    >²¸js  ã                   óÀ  — d dl mZ d dlZd dlmZ dej        ej                 de	ej        ej
                 df         dee	eef                  fd„Z	 ddej        ej                 d	ej        ej                 dej        ej                 d
ej        ej                 dej        ej                 dz  de	ej        ej                 ej        ej                 f         fd„ZdS )é    )ÚIteratorNÚiouÚmatched_indices.Úreturnc              #   óœ  K  — |d         }|d         }| |         }t          j        | d¬¦  «        }t          ¦   «         }t          ¦   «         }t          ||                              ¦   «         ||                              ¦   «         ¦  «        D ]=\  }}	||vr4|	|vr0|                     |¦  «         |                     |	¦  «         ||	fV — Œ>dS )a  Yield (target_idx, pred_idx) pairs in greedy highest-IoU-first one-to-one order.

    Candidate pairs are sorted by descending IoU and assigned one-to-one: a pair
    is accepted only when neither the target nor the prediction has been matched.

    Examples:
        ```pycon
        >>> import numpy as np
        >>> iou = np.array([[1.0, 0.667], [0.333, 0.538]], dtype=np.float32)
        >>> matched_indices = np.where(iou >= 0.5)
        >>> list(_greedy_match(iou, matched_indices))
        [(0, 0), (1, 1)]

        ```
    r   é   Ústable)ÚkindN)ÚnpÚargsortÚsetÚzipÚtolistÚadd)
r   r   Ú
target_idxÚpred_idxÚ
iou_valuesÚorderÚmatched_targetsÚmatched_predsÚtÚps
             úr/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/supervision/metrics/utils/matching.pyÚ_greedy_matchr      sá   è è € ð& ! Ô#€JØ˜qÔ!€HØ�_Ô%€JÝŒJ˜
�{¨Ð2Ñ2Ô2€EÝ #¡¤€OÝ!™eœe€MÝ�J˜uÔ%×,Ò,Ñ.Ô.°¸´×0FÒ0FÑ0HÔ0HÑIÔIð ð ‰ˆˆ1Ø�OÐ#Ð#¨°Ð(>Ð(>Ø×Ò Ñ"Ô"Ð"Ø×Ò˜aÑ Ô Ð Ø�Q�$ˆJˆJˆJøð	ð ó    Úpredictions_classesÚtarget_classesÚiou_thresholdsÚtarget_scored_maskc                 ó  — | j         d         }|j         d         }t          j        ||ft          ¬¦  «        }t          j        ||fdt          j        ¬¦  «        }|dd…df         | k    }	t          |¦  «        D ]ƒ\  }
}||k    |	z  }|€|g}n||dd…df         z  ||dd…df          z  g}|D ]M}|dd…|
f         dk     }t          j        ||z  ¦  «        }t          ||¦  «        D ]\  }}d|||
f<   ||||
f<   ŒŒNŒ„||fS )aë  Match predictions to targets and retain target indices per IoU threshold.

    When ``target_scored_mask`` is provided, scored targets are matched first and
    only predictions left unmatched may then match unscored (ignored) targets.
    This mirrors COCO evaluation, where detections prefer non-ignored ground
    truth, so an out-of-bucket target can never steal a prediction from an
    in-bucket one.

    Examples:
        ```pycon
        >>> import numpy as np
        >>> predictions_classes = np.array([0], dtype=np.int32)
        >>> target_classes = np.array([0], dtype=np.int32)
        >>> iou = np.array([[1.0]], dtype=np.float32)
        >>> thresholds = np.array([0.5], dtype=np.float32)
        >>> correct, matched = _match_detection_batch_with_target_indices(
        ...     predictions_classes,
        ...     target_classes,
        ...     iou,
        ...     thresholds,
        ... )
        >>> correct.tolist(), matched.tolist()
        ([[True]], [[0]])

        ```
    r   )ÚdtypeéÿÿÿÿNT)	Úshaper   ÚzerosÚboolÚfullÚint32Ú	enumerateÚwherer   )r   r   r   r   r   Únum_predictionsÚnum_iou_levelsÚcorrectr   Úcorrect_classÚiÚ	iou_levelÚcandidate_pairsÚmatch_roundsÚround_pairsÚunmatched_predictionsr   r   Úprediction_idxs                      r   Ú*_match_detection_batch_with_target_indicesr5   '   s{  € ðB *Ô/°Ô2€OØ#Ô)¨!Ô,€NÝŒh˜¨Ð8ÅÐEÑEÔE€GÝ”g˜°Ð?ÀÍ2Ì8ÐTÑTÔT€OØ" 1 1 1 d 7Ô+Ð/BÒB€Må! .Ñ1Ô1ð @ð @‰ˆˆ9Ø )Ò+¨}Ñ<ˆØÐ%Ø+Ð,ˆLˆLð  Ð"4°Q°Q°Q¸°WÔ"=Ñ=ØÐ#5°a°a°a¸°gÔ#>Ð">Ñ>ðˆLð
 (ð 	@ð 	@ˆKØ$3°A°A°A°q°DÔ$9¸AÒ$=Ð!Ý œh {Ð5JÑ'JÑKÔKˆOå.;¸CÀÑ.QÔ.Qð @ð @Ñ*�
˜NØ-1�˜¨Ð)Ñ*Ø5?� °Ð 1Ñ2Ð2ð@ð		@ð �OÐ#Ð#r   )N)Úcollections.abcr   Únumpyr   Únumpy.typingÚtypingÚnptÚNDArrayÚfloat32ÚtupleÚintpÚintr   r'   Úbool_r5   © r   r   ú<module>rB      s;  ðØ $Ð $Ð $Ð $Ð $Ð $à Ð Ð Ð Ø Ð Ð Ð Ð Ð ðØ	Œ�R”ZÔ	 ðà˜3œ; r¤wÔ/°Ð4Ô5ðð ˆe�C˜�HŒoÔðð ð ð ðJ 8<ð9$ð 9$Øœ R¤XÔ.ð9$à”K ¤Ô)ð9$ð 
Œ�R”ZÔ	 ð9$ð ”K ¤
Ô+ð	9$ð
 œ B¤HÔ-°Ñ4ð9$ð ˆ3Œ;�r”xÔ  #¤+¨b¬hÔ"7Ð7Ô8ð9$ð 9$ð 9$ð 9$ð 9$ð 9$r   