
    uki                     :    d Z ddlZddlmZ ddlmZ ddlmZ d Z	y)zMediaPipe vision benchmarker.    N)benchmark_utils)base_vision_benchmark_api)base_optionsc           
         t        j                  t         j                        }|j                  dddd       |j                  ddd	
       |j                  ddt        d       |j                  ddt
        d       |j                         }t        j                  t        j                  |      }t        j                  |j                  |      }d|j                  ii d}|j                  |vrt        d|j                         ||j                     }i }t         j"                  j$                  j&                  t         j"                  j$                  j(                  fD ]g  }	 | ||j*                  |	      }
|j                  dk(  rt        j,                  |
fi |||	<   @|j                  dk(  sPt        j.                  |
      ||	<   i |j1                         D ](  \  }	}t3        d|	 d||j                      d|dd       * y	)a  Executes a benchmarking process using a specified function ann model.

  Args:
      benchmark_function: A callable function to be executed for benchmarking.
        This function should contain the logic of the task to be benchmarked and
        should be capable of utilizing a model specified by its name.
      default_model_name: The name or path of the default model to be used in
        the benchmarking process. This is useful when the benchmarking function
        requires a model and no other model is explicitly specified.
  )formatter_classz--modez+Benchmarking mode (e.g., "nth_percentile").Fnth_percentile)helprequireddefaultz--modelzPath to the model.N)r	   r   z--iterationsz&Number of iterations for benchmarking.d   )r	   typer   z--percentilez'Percentile for benchmarking statistics.g     W@
percentile)r   averagezUnsupported benchmarking mode: r   zInference time  z: z.6fz milliseconds)argparseArgumentParserArgumentDefaultsHelpFormatteradd_argumentintfloat
parse_argsbuget_test_data_pathr   VISION_TEST_DATA_DIRget_model_pathmodelr   mode
ValueErrorr   BaseOptionsDelegateCPUGPU
iterationsr   r   itemsprint)benchmark_functiondefault_model_nameparserargsdefault_model_path
model_pathmode_args_mapping	mode_argsresultsdelegate_typeinference_timesresults               l/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/mediapipe/tasks/python/benchmark/vision/benchmark.pybenchmarkerr3      s    ""<<& 	8	   	i&:DI3	   	4	   
			$ ,,446H   -?@* &t7 
YY''
6tyykB
CC		*) '''++''++ ;m )DOO]O
 yy$$!00NINgm	i	!zz/:gm;  '}} mV	
-*;DII*F)Gr#,m	%    )
__doc__r    mediapipe.tasks.python.benchmarkr   r   ,mediapipe.tasks.python.benchmark.vision.corer   mediapipe.tasks.python.corer   r3    r4   r2   <module>r:      s    $  B R 4Lr4   