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

[Fix] Corrected config valid sequence for predefined models #72

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all 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
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
Loading