o
    Whv                  	   @   s,  d Z ddlZddlZddlZddlZddlZddlZddlmZ ddl	Z
ddlZddlZddlmZmZ ddlmZmZ ddlmZ ddlmZmZmZmZmZmZmZ ddlmZm Z m!Z!m"Z"m#Z# dd	l$m%Z% dd
l&m'Z' ddl(m)Z)m*Z* ed ddddddddf	ddZ+G dd dZ,G dd dZ-dS )a  
Benchmark a YOLO model formats for speed and accuracy.

Usage:
    from ultralytics.utils.benchmarks import ProfileModels, benchmark
    ProfileModels(['yolo11n.yaml', 'yolov8s.yaml']).profile()
    benchmark(model='yolo11n.pt', imgsz=160)

Format                  | `format=argument`         | Model
---                     | ---                       | ---
PyTorch                 | -                         | yolo11n.pt
TorchScript             | `torchscript`             | yolo11n.torchscript
ONNX                    | `onnx`                    | yolo11n.onnx
OpenVINO                | `openvino`                | yolo11n_openvino_model/
TensorRT                | `engine`                  | yolo11n.engine
CoreML                  | `coreml`                  | yolo11n.mlpackage
TensorFlow SavedModel   | `saved_model`             | yolo11n_saved_model/
TensorFlow GraphDef     | `pb`                      | yolo11n.pb
TensorFlow Lite         | `tflite`                  | yolo11n.tflite
TensorFlow Edge TPU     | `edgetpu`                 | yolo11n_edgetpu.tflite
TensorFlow.js           | `tfjs`                    | yolo11n_web_model/
PaddlePaddle            | `paddle`                  | yolo11n_paddle_model/
MNN                     | `mnn`                     | yolo11n.mnn
NCNN                    | `ncnn`                    | yolo11n_ncnn_model/
RKNN                    | `rknn`                    | yolo11n_rknn_model/
    NPath)YOLO	YOLOWorld)	TASK2DATATASK2METRIC)export_formats)ARM64ASSETSLINUXLOGGERMACOSTQDMWEIGHTS_DIR)IS_PYTHON_3_13check_imgszcheck_requirements
check_yolois_rockchip)safe_download)	file_size)get_cpu_infoselect_devicez
yolo11n.pt   FcpuMbP? c	           #         s  t |}t|tr|d |d ksJ d	 ddldjj_djj_t|dd	}t| t	t
fr5t| } t| jjd
 dd}	|pEt| j }t| j }
g }t }| }|rmtt d }||v smJ d| d| dttt   D ]\}\}}}}}}d\}}z|r||krW qv|dkr| jdksJ dn|dkrtrtrJ dn|dv rtstrtrJ d|dv rtrJ d|dv rt| trJ d|dkrt| trJ d| jdksJ d|	rJ dtstsJ d |d!krt| trJ d"|d#krt| trJ d$|d%kr:|	rJ t| tr%J d&| jd'ks/J d(d)|  v s:J d*|d+kr_t| trIJ d,|	rPJ d-tsWJ d.t r_J d/d0|jv rl|slJ d1d2|jv ry|syJ d3|d4kr| j p| j!p| j"}| }n| j#||||||dd5}t|| jd6}|t	|v sJ d7d8}| jd9ks|dksJ d:|d;vsJ d<|d=kst$% d>ksJ d?|d@v r|	rJ dA|j&t'dB |||ddC |j(|d|d|||ddD}|j)|
 |j*dE }}t+dF||  dG}|,|dHt+t-|dt+|dIt+|dG|g W qv t.yf } z5|rAt|t/u sAJ dJ| dK| t01dJ| dK|  |,||t+t-|ddddg W Y d}~qvd}~ww t2|dL j3|dMdNdO|
dPdQgdR}| j"}t | }dS}dT| dU| dV| dW|dXdY| dZ|4d4 dZ} t05|  t6d[d\d]d^d_}!|!7|  W d   n	1 sw   Y  |rt|t8r||
 j9}"| t: fd`da|"D sJ db  |S )caU  
    Benchmark a YOLO model across different formats for speed and accuracy.

    Args:
        model (str | Path): Path to the model file or directory.
        data (str | None): Dataset to evaluate on, inherited from TASK2DATA if not passed.
        imgsz (int): Image size for the benchmark.
        half (bool): Use half-precision for the model if True.
        int8 (bool): Use int8-precision for the model if True.
        device (str): Device to run the benchmark on, either 'cpu' or 'cuda'.
        verbose (bool | float): If True or a float, assert benchmarks pass with given metric.
        eps (float): Epsilon value for divide by zero prevention.
        format (str): Export format for benchmarking. If not supplied all formats are benchmarked.

    Returns:
        (pandas.DataFrame): A pandas DataFrame with benchmark results for each format, including file size, metric,
            and inference time.

    Examples:
        Benchmark a YOLO model with default settings:
        >>> from ultralytics.utils.benchmarks import benchmark
        >>> benchmark(model="yolo11n.pt", imgsz=640)
    r      Tz'benchmark() only supports square imgsz.N
   x   F)verboseend2endArgumentzExpected format to be one of z, but got 'z'.)   ❌N   obbz.TensorFlow GraphDef not supported for OBB task	   z3Edge TPU export only supported on non-aarch64 Linux>      r   zECoreML and TF.js export only supported on macOS and non-aarch64 Linux>   r(   z#CoreML not supported on Python 3.13>      r%      r'   r   z;YOLOWorldv2 TensorFlow exports not supported by onnx2tf yet   z,YOLOWorldv2 Paddle exports not supported yetzBPaddle OBB bug https://github.com/PaddlePaddle/Paddle/issues/72024z3End-to-end models not supported by PaddlePaddle yetz(Windows Paddle exports not supported yet   z)YOLOWorldv2 MNN exports not supported yet   z*YOLOWorldv2 NCNN exports not supported yet   z%YOLOWorldv2 IMX exports not supporteddetectz%IMX only supported for detection taskC2fzIMX only supported for YOLOv8   z*YOLOWorldv2 RKNN exports not supported yetz+End-to-end models not supported by RKNN yetzRKNN only supported on Linuxz1RKNN Inference only supported on Rockchip devicesr   zinference not supported on CPUcudazinference not supported on GPU-)imgszformathalfint8datadevicer    )taskzexport failedu   ❎posez(GraphDef Pose inference is not supported>   r'   r   zinference not supportedr(   Darwinz(inference only supported on macOS>=10.13>   r-   zHEnd-to-end torch.topk operation is not supported for NCNN prediction yetzbus.jpg)r4   r9   r6   r    )r8   batchr4   plotsr9   r6   r7   r    	inference     u   ✅   zBenchmark failure for : )r9   Formatu	   Status❔z	Size (MB)zInference time (ms/im)FPS)columnsud   Benchmarks legend:  - ✅ Success  - ❎ Export passed but validation failed  - ❌️ Export failedz
Benchmarks complete for z on z
 at imgsz=z (z.2fzs)

zbenchmarks.logaignoreutf-8)errorsencodingc                 3   s"    | ]} |r| kV  qd S N)notna).0xfloorpd P/var/www/vscode/kcb/lib/python3.10/site-packages/ultralytics/utils/benchmarks.py	<genexpr>        zbenchmark.<locals>.<genexpr>z%Benchmark failure: metric(s) < floor );r   
isinstancelistpandasoptionsdisplaymax_columnswidthr   strr   r   getattrmodelr   r:   r   timelower	frozensetr   	enumeratezipvaluesr   r	   r   r   r   __str__r   typept_path	ckpt_path
model_nameexportplatformsystempredictr
   valresults_dictspeedroundappendr   	ExceptionAssertionErrorr   errorr   	DataFramefillnainfoopenwritefloatarrayall)#ra   r8   r4   r6   r7   r9   r    epsr5   
is_end2endkeyyt0
format_argformatsinamesuffixr   gpu_emojifilenameexported_modelresultsmetricrs   fpsedfdtlegendsfmetricsrT   rQ   rU   	benchmark3   s   "$


(





 
0",
2

(r   c                   @   s>   e Zd ZdZdd Zdd ZdddZed	d
 Zdd Z	dS )RF100Benchmarka  
    Benchmark YOLO model performance across various formats for speed and accuracy.

    This class provides functionality to benchmark YOLO models on the RF100 dataset collection.

    Attributes:
        ds_names (List[str]): Names of datasets used for benchmarking.
        ds_cfg_list (List[Path]): List of paths to dataset configuration files.
        rf (Roboflow): Roboflow instance for accessing datasets.
        val_metrics (List[str]): Metrics used for validation.

    Methods:
        set_key: Set Roboflow API key for accessing datasets.
        parse_dataset: Parse dataset links and download datasets.
        fix_yaml: Fix train and validation paths in YAML files.
        evaluate: Evaluate model performance on validation results.
    c                 C   s    g | _ g | _d| _g d| _dS )zcInitialize the RF100Benchmark class for benchmarking YOLO model performance across various formats.Nclassimagestargets	precisionrecallmap50map95)ds_namesds_cfg_listrfval_metrics)selfrT   rT   rU   __init__   s   zRF100Benchmark.__init__c                 C   s$   t d ddlm} ||d| _dS )a%  
        Set Roboflow API key for processing.

        Args:
            api_key (str): The API key.

        Examples:
            Set the Roboflow API key for accessing datasets:
            >>> benchmark = RF100Benchmark()
            >>> benchmark.set_key("your_roboflow_api_key")
        roboflowr   )Roboflow)api_keyN)r   r   r   r   )r   r   r   rT   rT   rU   set_key   s   zRF100Benchmark.set_keydatasets_links.txtc           
   
   C   s   t jdrtdt dfnt d t d t d td t|ddY}|D ]N}zCt	
d| \}}}}}| j| | d| }	t|	 s_| j|||d ntd	 | jt |	 d
  W q, tyz   Y q,w W d   n1 sw   Y  | j| jfS )a  
        Parse dataset links and download datasets.

        Args:
            ds_link_txt (str): Path to the file containing dataset links.

        Returns:
            ds_names (List[str]): List of dataset names.
            ds_cfg_list (List[Path]): List of paths to dataset configuration files.

        Examples:
            >>> benchmark = RF100Benchmark()
            >>> benchmark.set_key("api_key")
            >>> benchmark.parse_dataset("datasets_links.txt")
        zrf-100zultralytics-benchmarkszQhttps://github.com/ultralytics/assets/releases/download/v0.0.0/datasets_links.txtrJ   rL   z/+r3   yolov8zDataset already downloaded.z	data.yamlN)ospathexistsshutilrmtreemkdirchdirr   r|   resplitstripr   ru   r   r   	workspaceprojectversiondownloadr   r{   r   cwdrv   )
r   ds_link_txtfileliner   urlr   r   r   proj_versionrT   rT   rU   parse_dataset   s*   (

 
zRF100Benchmark.parse_datasetc                 C   s   t | dd}t|}W d   n1 sw   Y  d|d< d|d< t | ddd}t|| W d   dS 1 s<w   Y  dS )	z8Fix the train and validation paths in a given YAML file.rJ   r   Nztrain/imagestrainzvalid/imagesrq   w)r|   yaml	safe_load	safe_dump)r   r   	yaml_datarT   rT   rU   fix_yaml  s   "zRF100Benchmark.fix_yamlc                    s  g d}t |dd}t|d  W d   n1 sw   Y  t |ddA}| }g }	|D ]0tfdd|D r>q0dttd	d
 dd D |	 fddD  q0W d   n1 skw   Y  d}
t	|	dkrt
d |	D ]}|d dkr|d }
qnt
d dd |	D d }
t |ddd}|| j|  d|
 d W d   dS 1 sw   Y  dS )a  
        Evaluate model performance on validation results.

        Args:
            yaml_path (str): Path to the YAML configuration file.
            val_log_file (str): Path to the validation log file.
            eval_log_file (str): Path to the evaluation log file.
            list_ind (int): Index of the current dataset in the list.

        Returns:
            (float): The mean average precision (mAP) value for the evaluated model.

        Examples:
            Evaluate a model on a specific dataset
            >>> benchmark = RF100Benchmark()
            >>> benchmark.evaluate("path/to/data.yaml", "path/to/val_log.txt", "path/to/eval_log.txt", 0)
        )u   🚀u   ⚠️u   💡r$   rJ   r   namesNc                 3   s    | ]}| v V  qd S rM   rT   )rO   symbol)r   rT   rU   rV   >  s    z*RF100Benchmark.evaluate.<locals>.<genexpr> c                 S   s   | dkS )Nr   rT   )rq   rT   rT   rU   <lambda>A  s    z)RF100Benchmark.evaluate.<locals>.<lambda>c                 S   s   g | ]}| d qS )rG   )r   rO   r   rT   rT   rU   
<listcomp>B  s    z+RF100Benchmark.evaluate.<locals>.<listcomp>c              	   3   s`    | ]+}| v s|d krdvrdvrd d d d d d d	 d
V  qdS )r   z(AP)z(AR)r   r   rA      rB   r(   r)   r   NrT   r   )class_namesentriesrT   rU   rV   C  s    
 
        r   zMultiple dicts foundr   r   r   zSingle dict foundc                 S   s   g | ]}|d  qS )r   rT   )rO   resrT   rT   rU   r   X      r   rH   rC   rG   )r|   r   r   	readlinesanyr   rY   filterextendlenr   r{   r}   r   )r   	yaml_pathval_log_fileeval_log_filelist_indskip_symbolsstreamr   lines
eval_linesmap_vallstrT   )r   r   r   rU   evaluate%  s>   




"zRF100Benchmark.evaluateN)r   )
__name__
__module____qualname____doc__r   r   r   staticmethodr   r   rT   rT   rT   rU   r      s    
%
	r   c                   @   s   e Zd ZdZ							d#defd	d
Zdd Zdd Zede	fddZ
ed$ddZd%de	defddZd%de	defddZdd Zedd  Zed!d" ZdS )&ProfileModelsa(  
    ProfileModels class for profiling different models on ONNX and TensorRT.

    This class profiles the performance of different models, returning results such as model speed and FLOPs.

    Attributes:
        paths (List[str]): Paths of the models to profile.
        num_timed_runs (int): Number of timed runs for the profiling.
        num_warmup_runs (int): Number of warmup runs before profiling.
        min_time (float): Minimum number of seconds to profile for.
        imgsz (int): Image size used in the models.
        half (bool): Flag to indicate whether to use FP16 half-precision for TensorRT profiling.
        trt (bool): Flag to indicate whether to profile using TensorRT.
        device (torch.device): Device used for profiling.

    Methods:
        profile: Profiles the models and prints the result.
        get_files: Gets all relevant model files.
        get_onnx_model_info: Extracts metadata from an ONNX model.
        iterative_sigma_clipping: Applies sigma clipping to remove outliers.
        profile_tensorrt_model: Profiles a TensorRT model.
        profile_onnx_model: Profiles an ONNX model.
        generate_table_row: Generates a table row with model metrics.
        generate_results_dict: Generates a dictionary of profiling results.
        print_table: Prints a formatted table of results.

    Examples:
        Profile models and print results
        >>> from ultralytics.utils.benchmarks import ProfileModels
        >>> profiler = ProfileModels(["yolo11n.yaml", "yolov8s.yaml"], imgsz=640)
        >>> profiler.profile()
    d   r   <     TNpathsc	           	      C   sL   || _ || _|| _|| _|| _|| _|| _|p"ttj	
 r dnd| _dS )a[  
        Initialize the ProfileModels class for profiling models.

        Args:
            paths (List[str]): List of paths of the models to be profiled.
            num_timed_runs (int): Number of timed runs for the profiling.
            num_warmup_runs (int): Number of warmup runs before the actual profiling starts.
            min_time (float): Minimum time in seconds for profiling a model.
            imgsz (int): Size of the image used during profiling.
            half (bool): Flag to indicate whether to use FP16 half-precision for TensorRT profiling.
            trt (bool): Flag to indicate whether to profile using TensorRT.
            device (torch.device | None): Device used for profiling. If None, it is determined automatically.

        Notes:
            FP16 'half' argument option removed for ONNX as slower on CPU than FP32.

        Examples:
            Initialize and profile models
            >>> from ultralytics.utils.benchmarks import ProfileModels
            >>> profiler = ProfileModels(["yolo11n.yaml", "yolov8s.yaml"], imgsz=640)
            >>> profiler.profile()
        r   r   N)r   num_timed_runsnum_warmup_runsmin_timer4   r6   trttorchr9   r2   is_available)	r   r   r   r   r   r4   r6   r   r9   rT   rT   rU   r     s   !"zProfileModels.__init__c              	   C   s  |   }|std dS g }g }|D ]t}|d}|jdv rStt|}|  | }| j	rG| j
jdkrG| sG|jd| j| j| j
dd}|jd	| j| j
dd
}n|jdkr`| |}|}nq| t|}	| t|}
|| |j|
|	| || |j|
|	| q| | |S )a  
        Profile YOLO models for speed and accuracy across various formats including ONNX and TensorRT.

        Returns:
            (List[Dict]): List of dictionaries containing profiling results for each model.

        Examples:
            Profile models and print results
            >>> from ultralytics.utils.benchmarks import ProfileModels
            >>> profiler = ProfileModels(["yolo11n.yaml", "yolov8s.yaml"])
            >>> results = profiler.profile()
        z'No matching *.pt or *.onnx files found.Nz.engine   .pt.yml.yamlr   engineF)r5   r6   r4   r9   r    onnx)r5   r4   r9   r    z.onnx)	get_filesr   warningwith_suffixr   r   r_   fuser{   r   r9   ri   is_filerm   r6   r4   get_onnx_model_infoprofile_tensorrt_modelprofile_onnx_modelru   generate_table_rowstemgenerate_results_dictprint_table)r   files
table_rowsoutputr   engine_filera   
model_info	onnx_filet_enginet_onnxrT   rT   rU   profile  sH   





zProfileModels.profilec                    s   g }| j D ]2 t    r g d}| fdd|D  q jdv r-|t  q|tt  qt	dt
|  dd t
|D S )z
        Return a list of paths for all relevant model files given by the user.

        Returns:
            (List[Path]): List of Path objects for the model files.
        )z*.ptz*.onnxz*.yamlc                    s(   g | ]}t  t | D ]}|qqS rT   )globr_   )rO   extr   r   rT   rU   r     s   ( z+ProfileModels.get_files.<locals>.<listcomp>r   zProfiling: c                 S   s   g | ]}t |qS rT   r   )rO   r   rT   rT   rU   r     r   )r   r   is_dirr   r   ru   r_   r  r   r{   sorted)r   r  
extensionsrT   r  rU   r     s   

zProfileModels.get_filesr  c                 C   s   dS )zXExtracts metadata from an ONNX model file including parameters, GFLOPs, and input shape.)r   r   r   r   rT   )r  rT   rT   rU   r    s   z!ProfileModels.get_onnx_model_inforA   r   c                 C   sp   t | } t|D ],}t | t | }}| | |||  k| |||  k @  }t|t| kr3 | S |} q	| S )a  
        Apply iterative sigma clipping to data to remove outliers.

        Args:
            data (numpy.ndarray): Input data array.
            sigma (float): Number of standard deviations to use for clipping.
            max_iters (int): Maximum number of iterations for the clipping process.

        Returns:
            (numpy.ndarray): Clipped data array with outliers removed.
        )npr   rangemeanstdr   )r8   sigma	max_itersr   r  r  clipped_datarT   rT   rU   iterative_sigma_clipping  s   
$z&ProfileModels.iterative_sigma_clippingr   r  r   c                 C   s
  | j r	t| sdS t|}tj| j| jdftjd}d}tdD ]}t		 }t| j
D ]
}||| jdd q-t		 | }q"tt| j||  | j
 | jd }g }	tt||dD ]}||| jdd}
|	|
d	 jd
  q[| jt|	ddd}	t|	t|	fS )a  
        Profile YOLO model performance with TensorRT, measuring average run time and standard deviation.

        Args:
            engine_file (str): Path to the TensorRT engine file.
            eps (float): Small epsilon value to prevent division by zero.

        Returns:
            mean_time (float): Mean inference time in milliseconds.
            std_time (float): Standard deviation of inference time in milliseconds.
        )r   r   r   )dtyper   F)r4   r    2   descr   r?   rA   r  r  )r   r   r  r   r  zerosr4   uint8r  rb   r   maxrt   r   r   r   ru   rs   r!  r   r  r  )r   r  r   ra   
input_dataelapsedr   
start_timenum_runs	run_timesr   rT   rT   rU   r    s"   $z$ProfileModels.profile_tensorrt_modelc                 C   s  t d ddl}| }|jj|_d|_|j||dgd}| d }|j	}t
dd |jD  }|r;d	d
| j| jfn|j}	d|v rFtj}
n'd|v rNtj}
nd|v rVtj}
nd|v r^tj}
nd|v rftj}
ntd| tjj|	 |
}|j}| d j}d}td
D ]}t }t| jD ]}||g||i qt | }qtt| j||  | j | j }g }t!t||dD ]}t }||g||i |"t | d  q| j#t$|ddd}t%|t&|fS )a  
        Profile an ONNX model, measuring average inference time and standard deviation across multiple runs.

        Args:
            onnx_file (str): Path to the ONNX model file.
            eps (float): Small epsilon value to prevent division by zero.

        Returns:
            mean_time (float): Mean inference time in milliseconds.
            std_time (float): Standard deviation of inference time in milliseconds.
        onnxruntimer   Nr*   CPUExecutionProvider)	providersc                 s   s"    | ]}t |to|d kV  qdS )r   N)rX   int)rO   dimrT   rT   rU   rV   O  rW   z3ProfileModels.profile_onnx_model.<locals>.<genexpr>r   r   float16r~   doubleint64int32zUnsupported ONNX datatype r   r$  r@   rA   r(   r&  )'r   r/  SessionOptionsGraphOptimizationLevelORT_ENABLE_ALLgraph_optimization_levelintra_op_num_threadsInferenceSession
get_inputsri   r   shaper4   r  r4  float32float64r6  r7  
ValueErrorrandomrandastyper   get_outputsr  rb   r   runr)  rt   r   r   r   ru   r!  r   r  r  )r   r  r   ortsess_optionssessinput_tensor
input_typedynamicinput_shapeinput_dtyper*  
input_nameoutput_namer+  r   r,  r-  r.  rT   rT   rU   r  8  sL   
 z ProfileModels.profile_onnx_modelc           	      C   sf   |\}}}}d|dd| j  d|d dd|d dd	|d dd|d dd	|d
 dd|ddS )a  
        Generate a table row string with model performance metrics.

        Args:
            model_name (str): Name of the model.
            t_onnx (tuple): ONNX model inference time statistics (mean, std).
            t_engine (tuple): TensorRT engine inference time statistics (mean, std).
            model_info (tuple): Model information (layers, params, gradients, flops).

        Returns:
            (str): Formatted table row string with model metrics.
        z| 18sz | z | - | r   z.1f   ±r   z ms | g    .Az |)r4   )	r   rl   r  r  r  layersparams	gradientsflopsrT   rT   rU   r  y  s   6z ProfileModels.generate_table_rowc                 C   s6   |\}}}}| |t |dt |d dt |d ddS )a  
        Generate a dictionary of profiling results.

        Args:
            model_name (str): Name of the model.
            t_onnx (tuple): ONNX model inference time statistics (mean, std).
            t_engine (tuple): TensorRT engine inference time statistics (mean, std).
            model_info (tuple): Model information (layers, params, gradients, flops).

        Returns:
            (dict): Dictionary containing profiling results.
        r   r   )z
model/namezmodel/parameterszmodel/GFLOPszmodel/speed_ONNX(ms)zmodel/speed_TensorRT(ms))rt   )rl   r  r  r  rT  rU  rV  rW  rT   rT   rU   r	    s   z#ProfileModels.generate_results_dictc                 C   s   t j rt jdnd}ddddt  dd| d	d
dg}dddd |D  d }dddd |D  d }td|  t| | D ]}t| qJdS )z
        Print a formatted table of model profiling results.

        Args:
            table_rows (List[str]): List of formatted table row strings.
        r   GPUModelzsize<br><sup>(pixels)zmAP<sup>val<br>50-95zSpeed<br><sup>CPU (z) ONNX<br>(ms)zSpeed<br><sup>z TensorRT<br>(ms)zparams<br><sup>(M)zFLOPs<br><sup>(B)|c                 s   s    | ]	}d | d V  qdS )r   NrT   rO   hrT   rT   rU   rV     s    z,ProfileModels.print_table.<locals>.<genexpr>c                 s   s     | ]}d t |d  V  qdS )r3   rA   N)r   r[  rT   rT   rU   rV     s    z

N)r   r2   r   get_device_namer   joinr   r{   )r  r   headersheader	separatorrowrT   rT   rU   r
    s    
	
zProfileModels.print_table)r   r   r   r   TTN)rA   r   )r   )r   r   r   r   rY   r   r  r   r   r_   r  r!  r~   r  r  r  r	  r
  rT   rT   rT   rU   r   ^  s2    $
*7'A
r   ).r   r  r   rn   r   r   rb   pathlibr   numpyr  
torch.cudar   r   ultralyticsr   r   ultralytics.cfgr   r   ultralytics.engine.exporterr   ultralytics.utilsr	   r
   r   r   r   r   r   ultralytics.utils.checksr   r   r   r   r   ultralytics.utils.downloadsr   ultralytics.utils.filesr   ultralytics.utils.torch_utilsr   r   r   r   r   rT   rT   rT   rU   <module>   sB   $
  