
    /jAY                        d dl mZ d dlZd dlmZ d dlmZ d dlZd dl	Z	d dl
mZ d dlmZmZm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mZmZ d d
lmZ  G d de          Z dS )    )annotationsN)Path)Any)build_dataloaderbuild_yolo_dataset	converter)BaseValidator)LOGGERRANKnmsops)check_requirements)ConfusionMatrix
DetMetricsbox_iou)plot_imagesc                       e Zd ZdZdDdE fdZdFd
ZdGdZdHdZdIdZdJdZ	dKdZ
dLdZdMdZdMdZdNdZdMdZdOd ZdPdQd&ZdRd*ZdSd,Z	 dTdUd.ZdVd6ZdWd8ZdXd9ZdYd;Z	 	 dZd[dCZ xZS )\DetectionValidatoray  A class extending the BaseValidator class for validation based on a detection model.

    This class implements validation functionality specific to object detection tasks, including metrics calculation,
    prediction processing, and visualization of results.

    Attributes:
        is_coco (bool): Whether the dataset is COCO.
        is_lvis (bool): Whether the dataset is LVIS.
        class_map (list[int]): Mapping from model class indices to dataset class indices.
        metrics (DetMetrics): Object detection metrics calculator.
        iouv (torch.Tensor): IoU thresholds for mAP calculation.
        niou (int): Number of IoU thresholds.
        lb (list[Any]): List for storing ground truth labels for hybrid saving.
        jdict (list[dict[str, Any]]): List for storing JSON detection results.
        stats (dict[str, list[torch.Tensor]]): Dictionary for storing statistics during validation.

    Examples:
        >>> from ultralytics.models.yolo.detect import DetectionValidator
        >>> args = dict(model="yolo26n.pt", data="coco8.yaml")
        >>> validator = DetectionValidator(args=args)
        >>> validator()
    N
_callbacksdict | NonereturnNonec                *   t                                          ||||           d| _        d| _        d| _        d| j        _        t          j        ddd          | _	        | j	        
                                | _        t                      | _        dS )a  Initialize detection validator with necessary variables and settings.

        Args:
            dataloader (torch.utils.data.DataLoader, optional): DataLoader to use for validation.
            save_dir (Path, optional): Directory to save results.
            args (dict[str, Any], optional): Arguments for the validator.
            _callbacks (dict, optional): Dictionary of callback functions.
        FNdetectg      ?gffffff?
   )super__init__is_cocois_lvis	class_mapargstasktorchlinspaceiouvnumelniour   metrics)self
dataloadersave_dirr!   r   	__class__s        g/home/longshao/multi-rider-rag/.venv/lib/python3.11/site-packages/ultralytics/models/yolo/detect/val.pyr   zDetectionValidator.__init__-   sx     	XtZ@@@!	N3b11	IOO%%	!||    batchdict[str, Any]c                T   |                                 D ]L\  }}t          |t          j                  r-|                    | j        | j        j        dk              ||<   M| j        j        r|d                                         n|d         	                                dz  |d<   |S )zPreprocess batch of images for YOLO validation.

        Args:
            batch (dict[str, Any]): Batch containing images and annotations.

        Returns:
            (dict[str, Any]): Preprocessed batch.
        cuda)non_blockingimg   )
items
isinstancer#   Tensortodevicetyper!   halffloat)r)   r/   kvs       r-   
preprocesszDetectionValidator.preprocess?   s     KKMM 	V 	VDAq!U\** V44$+:Jf:T4UUa/3y~We))+++5<CUCUCWCW[^^er.   modeltorch.nn.Modulec                   | j                             | j        j        d          }t	          |t
                    oGd|v oC|                    t          j         d          p!|                    t          j         d          | _	        t	          |t
                    od|v o| j	         | _
        | j	        rt          j                    n1t          t          dt          |j                  dz                       | _        | j        xj        | j        j        o| j	        s| j
        o| j         z  c_        |j        | _        t          |j                  | _        t-          |dd          | _        d	| _        g | _        |j        | j        _        t7          |j        | j        j        o| j        j        
          | _        dS )zInitialize evaluation metrics for YOLO detection validation.

        Args:
            model (torch.nn.Module): Model to validate.
         cocozval2017.txtztest-dev2017.txtlvis   end2endFr   )namessave_matchesN)datagetr!   splitr7   strendswithossepr   r   r   coco80_to_coco91_classlistrangelenrI   r    	save_jsonvaltrainingncgetattrrH   seenjdictr(   r   plots	visualizeconfusion_matrix)r)   rA   rW   s      r-   init_metricszDetectionValidator.init_metricsN   s    immDIOR00sC   d#d44455bFaFaFa9b9b 	
 "#s++R#RdlBR?C|u9;;;QUV[\]_bchcn_o_ors_sVtVtQuQu	ty}e$,2N$,eX\XeTee[
ek""ui77	
"[ /ekPTPYP_Pwdhdmdw x x xr.   rN   c                    ddz  S )zBReturn a formatted string summarizing class metrics of YOLO model.z%22s%11s%11s%11s%11s%11s%11s)ClassImages	InstanceszBox(PRmAP50z	mAP50-95) r)   s    r-   get_desczDetectionValidator.get_desce   s    #'kkkr.   predstorch.Tensorlist[dict[str, torch.Tensor]]c                   t          j        || j        j        | j        j        | j        j        dk    rdn| j        d| j        j        p| j        j        | j        j	        | j
        | j        j        dk    	  	        }d |D             S )aE  Apply Non-maximum suppression to prediction outputs.

        Args:
            preds (torch.Tensor): Raw predictions from the model.

        Returns:
            (list[dict[str, torch.Tensor]]): Processed predictions after NMS, where each dict contains 'bboxes', 'conf',
                'cls', and 'extra' tensors.
        r   r   Tobb)rY   multi_labelagnosticmax_detrH   rotatedc           	     t    g | ]5}|d d d df         |d d df         |d d df         |d d dd f         d6S )N         )bboxesconfclsextrarg   .0xs     r-   
<listcomp>z2DetectionValidator.postprocess.<locals>.<listcomp>~   sd    jjj]^1QQQU8Qqqq!tWQqqq!tWqQRQRQRTUTVTVQVxXXjjjr.   )r   non_max_suppressionr!   rx   iour"   rY   
single_clsagnostic_nmsrq   rH   )r)   rj   outputss      r-   postprocesszDetectionValidator.postprocessi   s     )INIMINh..qqDGY)CTY-CI%LINe+

 

 

 kjbijjjjr.   siintc                   |d         |k    }|d         |                              d          }|d         |         }|d         |         }|d         j        dd         }|d	         |         }|j        d
         r8t          j        |          t	          j        || j                  g d         z  }||||||d         |         dS )a3  Prepare a batch of images and annotations for validation.

        Args:
            si (int): Sample index within the batch.
            batch (dict[str, Any]): Batch data containing images and annotations.

        Returns:
            (dict[str, Any]): Prepared batch with processed annotations.
        	batch_idxry   rw   	ori_shaper4      N	ratio_padr   )r:   )rG   r   rG   r   im_file)ry   rw   r   imgszr   r   )squeezeshaper   	xywh2xyxyr#   tensorr:   )	r)   r   r/   idxry   bboxr   r   r   s	            r-   _prepare_batchz!DetectionValidator._prepare_batch   s     K B&El3''++Xs#+&r*	e"122&+&r*	9Q< 	_=&&eDK)P)P)PQ]Q]Q])^^D""Y'+
 
 	
r.   preddict[str, torch.Tensor]c                >    | j         j        r|dxx         dz  cc<   |S )a  Prepare predictions for evaluation against ground truth.

        Args:
            pred (dict[str, torch.Tensor]): Post-processed predictions from the model.

        Returns:
            (dict[str, torch.Tensor]): Prepared predictions in native space.
        ry   r   )r!   r   )r)   r   s     r-   _prepare_predz DetectionValidator._prepare_pred   s,     9 	KKK1KKKr.   c                   t          |          D ]m\  }}| xj        dz  c_        |                     ||          }|                     |          }|d                                                                         }|d         j        d         dk    }| j                            i | 	                    ||          |t          j        |          |rt          j        d          n+|d                                                                         |rt          j        d          n+|d                                                                         d           | j        j        rf| j                            ||| j        j                   | j        j        r3| j                            |d         |         |d         | j                   |r| j        j        s| j        j        r|                     ||          }	| j        j        r|                     |	|           | j        j        rN|                     |	| j        j        |d	         | j        d
z  t7          |d                   j         dz             odS )zUpdate metrics with new predictions and ground truth.

        Args:
            preds (list[dict[str, torch.Tensor]]): List of predictions from the model.
            batch (dict[str, Any]): Batch data containing ground truth.
        rG   ry   r   rx   )
target_cls
target_imgrx   pred_cls)rx   r4   r   r   labelsz.txtN)	enumerater[   r   r   cpunumpyr   r(   update_stats_process_batchnpuniquezerosr!   r]   r_   process_batchrx   r^   plot_matchesr+   rV   save_txtscale_predspred_to_jsonsave_one_txt	save_confr   stem)
r)   rj   r/   r   r   pbatchprednry   no_predpredn_scaleds
             r-   update_metricsz!DetectionValidator.update_metrics   sw    "%(( $	 $	HBIINII((U33F&&t,,E-##%%++--CEl(+q0GL%%))%88"%"$)C..+2SBHQKKKf8I8I8K8K8Q8Q8S8S/6 VE%L<L<L<N<N<T<T<V<V     y k%33E6	3WWW9& k)66uU|B7GPYIZ\`\ijjj  y" ?di&8 ?#//v>>y" 8!!,777y! !! I';'MH,$vi7H2I2I2N/T/T/TT	  ?$	 $	r.   c                    | j         j        r,dD ])}| j                            | j        || j                   *| j        | j        _        | j        | j        _        | j        | j        _        dS )z8Set final values for metrics speed and confusion matrix.)TF)r+   	normalizeon_plotN)r!   r]   r_   plotr+   r   speedr(   )r)   r   s     r-   finalize_metricsz#DetectionValidator.finalize_metrics   sr    9? 	n( n n	%**DMY`d`l*mmmm!Z(,(=% $r.   c                   t           dk    rdgt          j                    z  }t          j        | j        j        |d           d | j        j                                        D             }|D ](}|D ]#}||                             ||                    $)dgt          j                    z  }t          j        | j        |d           g | _        |D ]}| j                            |           || j        _        t          | j
        j                  | _        dS t           dk    r_t          j        | j        j        dd           t          j        | j        dd           g | _        | j                                         dS dS )zGather stats from all GPUs.r   N)dstc                    i | ]}|g S rg   rg   )r|   keys     r-   
<dictcomp>z3DetectionValidator.gather_stats.<locals>.<dictcomp>   s    IIICIIIr.   )r   distget_world_sizegather_objectr(   statskeysextendr\   rU   r*   datasetr[   clear_stats)r)   gathered_statsmerged_stats
stats_dictr   gathered_jdictr\   s          r-   gather_statszDetectionValidator.gather_stats   s   199"Vd&9&;&;;Nt|1>qIIIIIIt|/A/F/F/H/HIIIL, > >
' > >C %,,Z_====>"Vd&9&;&;;Ntz>qAAAADJ' ) )
!!%((((!-DLDO344DIIIAXXt|14Q????tz4Q7777DJL$$&&&&&	 Xr.   c                    | j                             | j        | j        j        | j                   | j                                          | j         j        S )zCalculate and return metrics statistics.

        Returns:
            (dict[str, Any]): Dictionary containing metrics results.
        )r+   r   r   )r(   processr+   r!   r]   r   r   results_dictrh   s    r-   	get_statszDetectionValidator.get_stats   sJ     	dm$)/SWS_```  """|((r.   c                   ddt          | j        j                  z  z   }t          j        |d| j        | j        j                                        g| j                                        R z             | j        j                                        dk    r"t          j	        d| j
        j         d           | j
        j        r| j        s| j        dk    rt          | j        j                  rt!          | j        j                  D ]m\  }}t          j        || j        |         | j        j        |         | j        j        |         g| j                            |          R z             fdS dS dS dS dS )	z0Print training/validation set metrics per class.z%22s%11i%11iz%11.3gallr   zno labels found in z+ set, cannot compute metrics without labelsrG   N)rU   r(   r   r
   infor[   nt_per_classsummean_resultswarningr!   r"   verboserX   rY   r   r   ap_class_indexrI   nt_per_imageclass_result)r)   pfics       r-   print_resultsz DetectionValidator.print_results   s    8c$,2C.D.D#DDB%DL,E,I,I,K,KjdlNgNgNiNijjjkkk<$((**a//Nllllmmm 9 
	T] 
	tw{{s4<K]G^G^{!$,"=>> 	 	1
11!41!4 22155	    
	 
	 
	 
	{{{{	 	r.   dict[str, np.ndarray]c                   |d         j         d         dk    s|d         j         d         dk    r5dt          j        |d         j         d         | j        ft                    iS t          |d         |d                   }d|                     |d         |d         |                                                                          iS )a  Return correct prediction matrix.

        Args:
            preds (dict[str, torch.Tensor]): Dictionary containing prediction data with 'bboxes' and 'cls' keys.
            batch (dict[str, Any]): Batch dictionary containing ground truth data with 'bboxes' and 'cls' keys.

        Returns:
            (dict[str, np.ndarray]): Dictionary containing 'tp' key with correct prediction matrix of shape (N, 10) for
                10 IoU levels.
        ry   r   tpdtyperw   )	r   r   r   r'   boolr   match_predictionsr   r   )r)   rj   r/   r   s       r-   r   z!DetectionValidator._process_batch  s     <a A%%u);A)>!)C)C"(E%L$6q$949#ETRRRSSeHouX77d,,U5\5<MMQQSSYY[[\\r.   rW   img_pathmode
int | Nonetorch.utils.data.Datasetc                J    t          | j        ||| j        || j                  S )ac  Build YOLO Dataset.

        Args:
            img_path (str): Path to the folder containing images.
            mode (str): `train` mode or `val` mode, users are able to customize different augmentations for each mode.
            batch (int, optional): Size of batches, this is for `rect`.

        Returns:
            (Dataset): YOLO dataset.
        )r   stride)r   r!   rK   r   )r)   r   r   r/   s       r-   build_datasetz DetectionValidator.build_dataset"  s'     "$)Xudid[_[fggggr.   dataset_path
batch_sizetorch.utils.data.DataLoaderc           	         |                      ||d          }t          ||| j        j        dd| j        j        | j                  S )zConstruct and return dataloader.

        Args:
            dataset_path (str): Path to the dataset.
            batch_size (int): Size of each batch.

        Returns:
            (torch.utils.data.DataLoader): DataLoader for validation.
        rW   )r/   r   Fr   )shufflerank	drop_last
pin_memory)r   r   r!   workerscompilerX   )r)   r   r   r   s       r-   get_dataloaderz!DetectionValidator.get_dataloader/  sV     $$\%$PPIi'}
 
 
 	
r.   nic                f    t          ||d         | j        d| dz  | j        | j                   dS )zPlot validation image samples.

        Args:
            batch (dict[str, Any]): Batch containing images and annotations.
            ni (int): Batch index.
        r   	val_batchz_labels.jpg)r   pathsfnamerI   r   N)r   r+   rI   r   )r)   r/   r   s      r-   plot_val_samplesz#DetectionValidator.plot_val_samplesD  sP     		"-"=b"="="==*L	
 	
 	
 	
 	
 	
r.   rq   c           	        sdS t                    D ]%\  }}t          j        |d                   |z  |d<   &d                                         }p| j        j        fd|D             }t          j        |d                   |d<   t          |d         ||d         | j	        d	| d
z  | j
        | j                   dS )ai  Plot predicted bounding boxes on input images and save the result.

        Args:
            batch (dict[str, Any]): Batch containing images and annotations.
            preds (list[dict[str, torch.Tensor]]): List of predictions from the model.
            ni (int): Batch index.
            max_det (int | None): Maximum number of detections to plot.
        Nrx   r   r   c                Z    i | ]&t          j        fd D             d          'S )c                0    g | ]}|         d          S Nrg   )r|   r}   r>   rq   s     r-   r~   zBDetectionValidator.plot_predictions.<locals>.<dictcomp>.<listcomp>d  s%    &E&E&E!qtHWH~&E&E&Er.   r   dim)r#   cat)r|   r>   rq   rj   s    @r-   r   z7DetectionValidator.plot_predictions.<locals>.<dictcomp>d  sD    \\\RSEI&E&E&E&E&Eu&E&E&E1MMM\\\r.   rw   r4   r   r   z	_pred.jpg)imagesr   r   r   rI   r   )r   r#   	ones_liker   r!   rq   r   	xyxy2xywhr   r+   rI   r   )	r)   r/   rj   r   rq   r   r   r   batched_predss	     ` `    r-   plot_predictionsz#DetectionValidator.plot_predictionsS  s      	F '' 	B 	BGAt %V = = ADQx}}.TY.\\\\\W[\\\"%-h0G"H"Hh< 	"-";b";";";;*L	
 	
 	
 	
 	
 	
r.   r   r   r   r   tuple[int, int]filer   c                Z   ddl m}  |t          j        |d         |d         ft          j                  d| j        t          j        |d         |d                             d          |d	                             d          gd
                    	                    ||           dS )a  Save YOLO detections to a txt file in normalized coordinates in a specific format.

        Args:
            predn (dict[str, torch.Tensor]): Dictionary containing predictions with keys 'bboxes', 'conf', and 'cls'.
            save_conf (bool): Whether to save confidence scores.
            shape (tuple[int, int]): Shape of the original image (height, width).
            file (Path): File path to save the detections.
        r   )ResultsrG   r   Nrw   rx   r   ry   r  )pathrI   boxes)r   )
ultralytics.engine.resultsr  r   r   uint8rI   r#   r  	unsqueezer   )r)   r   r   r   r  r  s         r-   r   zDetectionValidator.save_one_txto  s     	766666HeAha):::*)U8_eFm.E.Eb.I.I5QV<KaKabdKeKeflmnnn		
 	
 	

 (49(
-
-
-
-
-r.   r   c                d   t          |d                   }|j        }|                                rt          |          n|}t	          j        |d                   }|ddddfxx         |ddddf         dz  z  cc<   t          |                                |d                                         |d                                                   D ][\  }}}	| j        	                    ||j
        | j        t          |	                   d |D             t          |d          d	           \dS )
a  Serialize YOLO predictions to COCO json format.

        Args:
            predn (dict[str, torch.Tensor]): Predictions dictionary containing 'bboxes', 'conf', and 'cls' keys with
                bounding box coordinates, confidence scores, and class predictions.
            pbatch (dict[str, Any]): Batch dictionary containing 'imgsz', 'ori_shape', 'ratio_pad', and 'im_file'.

        Examples:
             >>> result = {
             ...     "image_id": 42,
             ...     "file_name": "42.jpg",
             ...     "category_id": 18,
             ...     "bbox": [258.15, 41.29, 348.26, 243.78],
             ...     "score": 0.236,
             ... }
        r   rw   Nr   rx   ry   c                .    g | ]}t          |d           S )   )roundr{   s     r-   r~   z3DetectionValidator.pred_to_json.<locals>.<listcomp>  s     444QU1a[[444r.   ru   )image_id	file_namecategory_idr   score)r   r   	isnumericr   r   r  ziptolistr\   appendnamer    r  )
r)   r   r   r  r   r  boxbsr   s
             r-   r   zDetectionValidator.pred_to_json  s4   " F9%&&y $ 0 0:3t999dmE(O,,AAArrE


c!!!QRR%j1n$


3::<<v)=)=)?)?uATATAVAVWW 		 		GAq!J (!%#'>#a&&#944!444"1a[[    		 		r.   c           	         i |dt          j        |d         |d                                         |d         |d                   iS )z.Scales predictions to the original image size.rw   r   r   r   )r   )r   scale_boxesclone)r)   r   r   s      r-   r   zDetectionValidator.scale_preds  s^    

cowh%%''{# -	  
 
 	
r.   r   c                    | j         dz  }| j        d         dz  | j        rdnd| j        j         dz  }|                     |||          S )a  Evaluate YOLO output in JSON format and return performance statistics.

        Args:
            stats (dict[str, Any]): Current statistics dictionary.

        Returns:
            (dict[str, Any]): Updated statistics dictionary with COCO/LVIS evaluation results.
        zpredictions.jsonr  r   zinstances_val2017.jsonlvis_v1_z.json)r+   rK   r   r!   rM   coco_evaluate)r)   r   	pred_json	anno_jsons       r-   	eval_jsonzDetectionValidator.eval_json  sh     M$66	If+/<^''=^	=^=^=^` 	
 !!%I>>>r.   r   Boxr)  r*  	iou_typesstr | list[str]suffixc                l   | j         j        r| j        s| j        rt	          | j                  rt          j        d| d| d           	 ||fD ]#}|                                sJ | d            $t          |t                    r|gn|}t          |t                    r|gn|}t          d           ddlm}m}  ||          }	|	                    |          }
t!          |          D ]\  }} ||	|
|| j        t          j                  }d	 | j        j        j        D             |j        _        |                                 |                                 |                                 |j        d
         |d||         d          d<   |j        d         |d||         d          d<   |j        d         |d<   |j        d         |d<   |j        d         |d<   d|j        d         z  d|j        d
         z  z   |d<   | j        r`|j        d         |d||         d          d<   |j        d         |d||         d          d<   |j        d         |d||         d          d<   | j        r|d         |d<   n.# t4          $ r!}t          j        d|            Y d }~nd }~ww xY w|S )!am  Evaluate COCO/LVIS metrics using faster-coco-eval library.

        Performs evaluation using the faster-coco-eval library to compute mAP metrics for object detection. Updates the
        provided stats dictionary with computed metrics including mAP50, mAP50-95, and LVIS-specific metrics if
        applicable.

        Args:
            stats (dict[str, Any]): Dictionary to store computed metrics and statistics.
            pred_json (str | Path): Path to JSON file containing predictions in COCO format.
            anno_json (str | Path): Path to JSON file containing ground truth annotations in COCO format.
            iou_types (str | list[str]): IoU type(s) for evaluation. Can be single string or list of strings. Common
                values include "bbox", "segm", "keypoints". Defaults to "bbox".
            suffix (str | list[str]): Suffix to append to metric names in stats dictionary. Should correspond to
                iou_types if multiple types provided. Defaults to "Box".

        Returns:
            (dict[str, Any]): Updated stats dictionary containing the computed COCO/LVIS evaluation metrics.
        z'
Evaluating faster-coco-eval mAP using z and z...z file not foundzfaster-coco-eval>=1.6.7r   )COCOCOCOeval_faster)iouType
lvis_styleprint_functionc                P    g | ]#}t          t          |          j                  $S rg   )r   r   r   r{   s     r-   r~   z4DetectionValidator.coco_evaluate.<locals>.<listcomp>  s(    (e(e(eqT!WW\):):(e(e(er.   AP_50zmetrics/mAP50()AP_allzmetrics/mAP50-95(AP_smallzmetrics/mAP_small(B)	AP_mediumzmetrics/mAP_medium(B)AP_largezmetrics/mAP_large(B)g?g?fitnessAPrzmetrics/APr(APczmetrics/APc(APfzmetrics/APf(zmetrics/mAP50-95(B)z faster-coco-eval unable to run: N)r!   rV   r   r   rU   r\   r
   r   is_filer7   rN   r   faster_coco_evalr1  r2  loadResr   r*   r   im_filesparamsimgIdsevaluate
accumulate	summarizestats_as_dict	Exceptionr   )r)   r   r)  r*  r-  r/  r}   r1  r2  annor   r   iou_typerW   es                  r-   r(  z DetectionValidator.coco_evaluate  sH   4 9 '	GDL '	GDL '	Gc$*oo '	GKa9aaS\aaabbb%G"I- > >A99;;==1(=(=(===;=+5i+E+ETYKK9	%/%<%<H&&"#<===BBBBBBBBtI||I..#,Y#7#7 Y YKAx)/dH^d^i  C )f(eDOD[Dd(e(e(eCJ%LLNNNNN$$$MMOOO ?B>OPW>XE:6!9Q<:::;ADARS[A\E=fQil===>474Ej4QE01585F{5SE12474Ej4QE01'*S->x-H'H3QTQbcjQkKk'kE)$| Y@C@QRW@X<VAYq\<<<=@C@QRW@X<VAYq\<<<=@C@QRW@X<VAYq\<<<=< D',-B'CE)$ G G GE!EEFFFFFFFFGs   H7J 
J1J,,J1)NNNN)r   r   r   r   )r/   r0   r   r0   )rA   rB   r   r   )r   rN   )rj   rk   r   rl   )r   r   r/   r0   r   r0   )r   r   r   r   )rj   rl   r/   r0   r   r   )r   r   )r   r0   )rj   r   r/   r0   r   r   )rW   N)r   rN   r   rN   r/   r   r   r   )r   rN   r   r   r   r   )r/   r0   r   r   r   r   r  )
r/   r0   rj   rl   r   r   rq   r   r   r   )
r   r   r   r   r   r
  r  r   r   r   )r   r   r   r0   r   r   )r   r   r   r0   r   r   )r   r0   r   r0   )r   r,  )r   r0   r)  rN   r*  rN   r-  r.  r/  r.  r   r0   )__name__
__module____qualname____doc__r   r@   r`   ri   r   r   r   r   r   r   r   r   r   r   r   r   r	  r   r   r   r+  r(  __classcell__)r,   s   @r-   r   r      s.        .$ $ $ $ $ $ $$   y y y y.l l l lk k k k.
 
 
 
6   + + + +Z. . . .' ' ' ',) ) ) )   (] ] ] ] h h h h h
 
 
 
*
 
 
 
  ko
 
 
 
 
8. . . .$   B

 

 

 

? ? ? ?, &,"'B B B B B B B B Br.   r   )!
__future__r   rP   pathlibr   typingr   r   r   r#   torch.distributeddistributedr   ultralytics.datar   r   r   ultralytics.engine.validatorr	   ultralytics.utilsr
   r   r   r   ultralytics.utils.checksr   ultralytics.utils.metricsr   r   r   ultralytics.utils.plottingr   r   rg   r.   r-   <module>r_     sA   # " " " " " 				                              L L L L L L L L L L 6 6 6 6 6 6 4 4 4 4 4 4 4 4 4 4 4 4 7 7 7 7 7 7 J J J J J J J J J J 2 2 2 2 2 2l l l l l l l l l lr.   