Skip to content

Commit

Permalink
eval task save avg_time_per_images as result
Browse files Browse the repository at this point in the history
  • Loading branch information
eunwoosh committed Oct 30, 2023
1 parent c0299bc commit d59ac04
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/otx/algorithms/classification/adapters/openvino/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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")

Expand Down
8 changes: 7 additions & 1 deletion src/otx/algorithms/segmentation/adapters/openvino/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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:
Expand Down Expand Up @@ -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")

Expand Down
8 changes: 7 additions & 1 deletion src/otx/algorithms/visual_prompting/tasks/openvino.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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:
Expand Down Expand Up @@ -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")

Expand Down

0 comments on commit d59ac04

Please sign in to comment.