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

Export the flattened config in benchmark CSV. #2391

Merged
merged 7 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Changed

- Export flat configurations in benchmark CSV results by [mzweilin](https://github.com/mzweilin) in https://github.com/openvinotoolkit/anomalib/pull/2391

### Deprecated

### Fixed
Expand Down
4 changes: 4 additions & 0 deletions src/anomalib/pipelines/benchmark/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from anomalib.pipelines.components import JobGenerator
from anomalib.pipelines.components.utils import get_iterator_from_grid_dict
from anomalib.pipelines.types import PREV_STAGE_RESULT
from anomalib.utils.config import flatten_dict
from anomalib.utils.logging import hide_output

from .job import BenchmarkJob
Expand Down Expand Up @@ -39,9 +40,12 @@ def generate_jobs(
"""Return iterator based on the arguments."""
del previous_stage_result # Not needed for this job
for _container in get_iterator_from_grid_dict(args):
# Pass experimental configs as a flatten dictionary to the job runner.
flat_cfg = flatten_dict(_container)
yield BenchmarkJob(
accelerator=self.accelerator,
seed=_container["seed"],
model=get_model(_container["model"]),
datamodule=get_datamodule(_container["data"]),
flat_cfg=flat_cfg,
)
16 changes: 11 additions & 5 deletions src/anomalib/pipelines/benchmark/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,25 @@ class BenchmarkJob(Job):
model (AnomalyModule): The model to use.
datamodule (AnomalibDataModule): The data module to use.
seed (int): The seed to use.
flat_cfg (dict): The flat dictionary of configs with dotted keys.
"""

name = "benchmark"

def __init__(self, accelerator: str, model: AnomalyModule, datamodule: AnomalibDataModule, seed: int) -> None:
def __init__(
self,
accelerator: str,
model: AnomalyModule,
datamodule: AnomalibDataModule,
seed: int,
flat_cfg: dict,
) -> None:
super().__init__()
self.accelerator = accelerator
self.model = model
self.datamodule = datamodule
self.seed = seed
self.flat_cfg = flat_cfg

@hide_output
def run(
Expand All @@ -64,11 +73,8 @@ def run(
# TODO(ashwinvaidya17): Restore throughput
# https://github.com/openvinotoolkit/anomalib/issues/2054
output = {
"seed": self.seed,
"accelerator": self.accelerator,
"model": self.model.__class__.__name__,
"data": self.datamodule.__class__.__name__,
"category": self.datamodule.category,
**self.flat_cfg,
**test_results[0],
}
logger.info(f"Completed with result {output}")
Expand Down
Loading