Skip to content

Commit

Permalink
[HPO] Enabling ote_anomalib to report score for hpopt
Browse files Browse the repository at this point in the history
  • Loading branch information
SangdaeNam authored and eunwoosh committed May 31, 2022
1 parent f003a20 commit ad032dd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions external/anomaly/ote_anomalib/callbacks/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ def _get_progress(self, stage: str = "train") -> float:
raise ValueError(f"Unknown stage {stage}. Available: train, predict and test")

return self._progress

def on_validation_epoch_end(self, trainer, pl_module):
super().on_validation_epoch_end(trainer, pl_module)
score = None
metric = self.update_progress_callback.metric if hasattr(self.update_progress_callback, 'metric') else None
if metric in list(trainer.logged_metrics.keys()):
score = float(trainer.logged_metrics[metric])
progress = int(self._get_progress('predict'))
self.update_progress_callback(progress=progress, score=score)

def _update_progress(self, stage: str):
progress = self._get_progress(stage)
Expand Down

0 comments on commit ad032dd

Please sign in to comment.