
    uki                     :    d Z ddlZddlZd Zd ZdedefdZd Zy)	z$Benchmark utils for MediaPipe Tasks.    Nc                 .    t        j                  | |      S )z4Calculate the nth percentile of the inference times.)np
percentile)inference_timesr   s     k/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/mediapipe/tasks/python/benchmark/benchmark_utils.pynth_percentiler      s    	
	33    c                 ,    t        j                  |       S )z-Calculate the average of the inference times.)r   mean)r   s    r   averager      s    		!!r	   file_or_dirname_pathreturnc                     t        j                  |       D ]G  \  }}}||z   D ]9  }t         j                  j                  ||      }|j	                  |      s5|c c S  I t        d|d| d      )zDetermine the test data path.

  Args:
      test_srcdir: The path to the test source directory.
      file_or_dirname_path: The path to the file or directory.

  Returns:
      The full test data path.
  zNo z in test directory: .)oswalkpathjoinendswith
ValueError)test_srcdirr   	directorysubdirsfilesfr   s          r   get_test_data_pathr      ss     $&77;#7 i%u_ WW\\)Q'd	+	,
 	(<kJ	 r	   c                     | /t         j                  j                  |       rt        d|         | S | t        d|  d       t        d|        |S )a  Determine the model path based on the existence of the custom model.

  Args:
      custom_model: The path to the custom model provided by the user.
      default_model_path: The path to the default model.

  Returns:
      The path to the model to be used.
  zUsing provided model: zWarning: Provided model 'z)' not found. Using default model instead.zUsing default model: )r   r   existsprint)custom_modeldefault_model_paths     r   get_model_pathr"   2   sh     "''..">	"<.
12%l^ 4) ) 
!"4!5
67r	   )	__doc__r   numpyr   r   r   strr   r"    r	   r   <module>r'      s2    + 	 4
"
# # (r	   