diff --git a/src/otx/algorithms/classification/adapters/openvino/task.py b/src/otx/algorithms/classification/adapters/openvino/task.py index 91cfb3de5fa..50329d5d343 100644 --- a/src/otx/algorithms/classification/adapters/openvino/task.py +++ b/src/otx/algorithms/classification/adapters/openvino/task.py @@ -176,6 +176,11 @@ def __init__(self, task_environment: TaskEnvironment): self.inferencer = self.load_inferencer() template_file_path = self.task_environment.model_template.model_template_path self._base_dir = os.path.abspath(os.path.dirname(template_file_path)) + self._avg_time_per_image = None + + @property + def avg_time_per_image(self): + return self._avg_time_per_image def load_inferencer(self) -> ClassificationOpenVINOInferencer: """load_inferencer function of ClassificationOpenVINOTask.""" @@ -270,7 +275,8 @@ def add_prediction(id: int, predicted_scene: AnnotationSceneEntity, aux_data: tu self.inferencer.await_all() - logger.info(f"Avg time per image: {total_time/len(dataset)} secs") + self._avg_time_per_image = total_time / len(dataset) + logger.info(f"Avg time per image: {self._avg_time_per_image} secs") logger.info(f"Total time: {total_time} secs") logger.info("Classification OpenVINO inference completed") diff --git a/src/otx/algorithms/segmentation/adapters/openvino/task.py b/src/otx/algorithms/segmentation/adapters/openvino/task.py index 51b27286910..23774af0826 100644 --- a/src/otx/algorithms/segmentation/adapters/openvino/task.py +++ b/src/otx/algorithms/segmentation/adapters/openvino/task.py @@ -162,6 +162,7 @@ def __init__(self, task_environment: TaskEnvironment): self.model = self.task_environment.model self.model_name = self.task_environment.model_template.model_template_id self.inferencer = self.load_inferencer() + self._avg_time_per_image = None labels = task_environment.get_labels(include_empty=False) self._label_dictionary = dict(enumerate(labels, 1)) @@ -173,6 +174,10 @@ def hparams(self): """Hparams of OpenVINO Segmentation Task.""" return self.task_environment.get_hyper_parameters(SegmentationConfig) + @property + def avg_time_per_image(self): + return self._avg_time_per_image + def load_inferencer(self) -> OpenVINOSegmentationInferencer: """load_inferencer function of OpenVINO Segmentation Task.""" if self.model is None: @@ -248,7 +253,8 @@ def add_prediction( self.inferencer.await_all() - logger.info(f"Avg time per image: {total_time/len(dataset)} secs") + self._avg_time_per_image = total_time / len(dataset) + logger.info(f"Avg time per image: {self._avg_time_per_image} secs") logger.info(f"Total time: {total_time} secs") logger.info("Segmentation OpenVINO inference completed") diff --git a/src/otx/algorithms/visual_prompting/tasks/openvino.py b/src/otx/algorithms/visual_prompting/tasks/openvino.py index 8bc2ff8c861..8a09df72942 100644 --- a/src/otx/algorithms/visual_prompting/tasks/openvino.py +++ b/src/otx/algorithms/visual_prompting/tasks/openvino.py @@ -258,6 +258,7 @@ def __init__(self, task_environment: TaskEnvironment) -> None: self.model = self.task_environment.model self.model_name = self.task_environment.model_template.model_template_id self.inferencer = self.load_inferencer() + self._avg_time_per_image = None labels = task_environment.get_labels(include_empty=False) self._label_dictionary = dict(enumerate(labels, 1)) @@ -270,6 +271,10 @@ def hparams(self): """Hparams of OpenVINO Visual Prompting Task.""" return self.task_environment.get_hyper_parameters(VisualPromptingBaseConfig) + @property + def avg_time_per_image(self): + return self._avg_time_per_image + def load_inferencer(self) -> OpenVINOVisualPromptingInferencer: """Load OpenVINO Visual Prompting Inferencer.""" if self.model is None: @@ -328,7 +333,8 @@ def add_prediction(id: int, annotations: List[Annotation]): self.inferencer.await_all() - logger.info(f"Avg time per image: {total_time/len(dataset)} secs") + self._avg_time_per_image = total_time / len(dataset) + logger.info(f"Avg time per image: {self._avg_time_per_image} secs") logger.info(f"Total time: {total_time} secs") logger.info("Visual Prompting OpenVINO inference completed")