Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a tool to help conduct experiments #2651

Merged
merged 42 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
9cd65a7
implement run and experiment
eunwoosh Aug 24, 2023
7843d51
implement experiment result aggregator
eunwoosh Aug 28, 2023
10427a4
refactor experiment.py
eunwoosh Aug 29, 2023
01b2607
refactor run.py
eunwoosh Aug 30, 2023
1585af9
get export model speed
eunwoosh Aug 30, 2023
9c6dd76
add var collumn
eunwoosh Aug 31, 2023
9d7eef1
refactor experiment.py
eunwoosh Sep 1, 2023
0b20391
refine a way to update argument in cmd
eunwoosh Sep 1, 2023
e2428d9
refine resource tracker
eunwoosh Sep 1, 2023
132a757
support anomaly on research framework
eunwoosh Sep 14, 2023
3355182
refine code aggregating exp result
eunwoosh Sep 18, 2023
fb84669
bugfix
eunwoosh Sep 19, 2023
47cff18
make other task available
eunwoosh Sep 19, 2023
fe88850
eval task save avg_time_per_images as result
eunwoosh Sep 19, 2023
c6b838f
Add new argument to track CPU&GPU utilization and memory usage (#2500)
eunwoosh Sep 14, 2023
61647d2
apply new resource tracker format
eunwoosh Sep 19, 2023
4ea2313
refactor run.py
eunwoosh Sep 20, 2023
72c66b4
support optimize in research framework
eunwoosh Sep 20, 2023
9c3a934
cover edge case
eunwoosh Sep 20, 2023
db5cc7a
Handle a case where fail cases exist
eunwoosh Sep 20, 2023
ed2b4fa
make argparse raise error rather than exit if problem exist
eunwoosh Sep 21, 2023
bcb03e0
revert tensorboard aggregator
eunwoosh Sep 21, 2023
0b3c1fe
bugfix
eunwoosh Sep 21, 2023
3bacccd
save failed cases as yaml file
eunwoosh Sep 25, 2023
d711c50
deal with integer in variables
eunwoosh Oct 19, 2023
0ff2e69
add epoch to metric
eunwoosh Oct 24, 2023
cc458dd
use latest log.json file
eunwoosh Nov 9, 2023
b183fed
align with otx logging method
eunwoosh Nov 13, 2023
463baf6
move experiment.py from cli to tools
eunwoosh Nov 13, 2023
9b56498
refactor experiment.py
eunwoosh Nov 16, 2023
ee15964
merge otx run feature into experiment.py
eunwoosh Nov 16, 2023
e7c2146
move set_arguments_to_cmd definition into experiment.py
eunwoosh Nov 16, 2023
c85579e
refactor experiment.py
eunwoosh Nov 17, 2023
cb92a0b
bugfix
eunwoosh Nov 17, 2023
133aae8
minor bugfix
eunwoosh Nov 17, 2023
82467f3
use otx.cli instead of each otx entry
eunwoosh Nov 17, 2023
bdc9857
add feature to parse single workspace
eunwoosh Nov 17, 2023
c371d77
add comments
eunwoosh Nov 17, 2023
44a97d9
fix bugs
eunwoosh Nov 17, 2023
ffbf7a6
align with pre-commit
eunwoosh Nov 17, 2023
b82666e
revert parser argument
eunwoosh Nov 17, 2023
020bcd9
align with pre-commit
eunwoosh Nov 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ 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: Optional[float] = None

@property
def avg_time_per_image(self) -> Optional[float]:
"""Average inference time per image."""
return self._avg_time_per_image

def load_inferencer(self) -> ClassificationOpenVINOInferencer:
"""load_inferencer function of ClassificationOpenVINOTask."""
Expand Down Expand Up @@ -270,7 +276,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
9 changes: 8 additions & 1 deletion src/otx/algorithms/detection/adapters/openvino/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,13 +387,19 @@ def __init__(self, task_environment: TaskEnvironment):
self.confidence_threshold: float = 0.0
self.config = self.load_config()
self.inferencer = self.load_inferencer()
self._avg_time_per_image: Optional[float] = None
logger.info("OpenVINO task initialization completed")

@property
def hparams(self):
"""Hparams of OpenVINO Detection Task."""
return self.task_environment.get_hyper_parameters(DetectionConfig)

@property
def avg_time_per_image(self) -> Optional[float]:
"""Average inference time per image."""
return self._avg_time_per_image

def load_config(self) -> ADDict:
"""Load configurable parameters from model adapter.

Expand Down Expand Up @@ -557,7 +563,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("OpenVINO inference completed")
return dataset
Expand Down
9 changes: 8 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: Optional[float] = None

labels = task_environment.get_labels(include_empty=False)
self._label_dictionary = dict(enumerate(labels, 1))
Expand All @@ -173,6 +174,11 @@ def hparams(self):
"""Hparams of OpenVINO Segmentation Task."""
return self.task_environment.get_hyper_parameters(SegmentationConfig)

@property
def avg_time_per_image(self) -> Optional[float]:
"""Average inference time per image."""
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 +254,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
9 changes: 8 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: Optional[float] = None

labels = task_environment.get_labels(include_empty=False)
self._label_dictionary = dict(enumerate(labels, 1))
Expand All @@ -270,6 +271,11 @@ def hparams(self):
"""Hparams of OpenVINO Visual Prompting Task."""
return self.task_environment.get_hyper_parameters(VisualPromptingBaseConfig)

@property
def avg_time_per_image(self) -> Optional[float]:
"""Average inference time per image."""
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 +334,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
8 changes: 4 additions & 4 deletions src/otx/cli/tools/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ def main():
print(resultset.performance)

output_path = Path(args.output) if args.output else config_manager.output_path
performance = {resultset.performance.score.name: resultset.performance.score.value}
if hasattr(task, "avg_time_per_image"):
performance["avg_time_per_image"] = task.avg_time_per_image
with open(output_path / "performance.json", "w", encoding="UTF-8") as write_file:
json.dump(
{resultset.performance.score.name: resultset.performance.score.value},
write_file,
)
json.dump(performance, write_file)

return dict(retcode=0, template=template.name)

Expand Down
Loading