Skip to content

Commit

Permalink
Corrected config valid sequence for predefined models
Browse files Browse the repository at this point in the history
  • Loading branch information
klemen1999 committed Sep 16, 2024
1 parent 0df07a5 commit f0c0ff8
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions luxonis_train/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,6 @@ class ModelConfig(BaseModelExtraForbid):
visualizers: list[AttachedModuleConfig] = []
outputs: list[str] = []

@model_validator(mode="after")
def check_main_metric(self) -> Self:
for metric in self.metrics:
if metric.is_main_metric:
logger.info(f"Main metric: `{metric.name}`")
return self

logger.warning("No main metric specified.")
if self.metrics:
metric = self.metrics[0]
metric.is_main_metric = True
name = metric.alias or metric.name
logger.info(f"Setting '{name}' as main metric.")
else:
logger.error(
"No metrics specified. "
"This is likely unintended unless "
"the configuration is not used for training."
)
return self

@model_validator(mode="after")
def check_predefined_model(self) -> Self:
from luxonis_train.utils.registry import MODELS
Expand All @@ -120,6 +99,27 @@ def check_predefined_model(self) -> Self:

return self

@model_validator(mode="after")
def check_main_metric(self) -> Self:
for metric in self.metrics:
if metric.is_main_metric:
logger.info(f"Main metric: `{metric.name}`")
return self

logger.warning("No main metric specified.")
if self.metrics:
metric = self.metrics[0]
metric.is_main_metric = True
name = metric.alias or metric.name
logger.info(f"Setting '{name}' as main metric.")
else:
logger.error(
"No metrics specified. "
"This is likely unintended unless "
"the configuration is not used for training."
)
return self

@model_validator(mode="after")
def check_graph(self) -> Self:
from luxonis_train.utils.general import is_acyclic
Expand Down

0 comments on commit f0c0ff8

Please sign in to comment.