Skip to content

Commit

Permalink
LuxonisML 0.3.0 Updates (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlov721 authored Aug 28, 2024
1 parent 19a5d2b commit 8870968
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 25 deletions.
3 changes: 1 addition & 2 deletions luxonis_train/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def thread_exception_hook(args):
self.thread.start()

def export(
self, onnx_save_path: str | None = None, *, weights: str | None = None
self, onnx_save_path: str | None = None, *, weights: str | Path | None = None
) -> None:
"""Runs export.
Expand Down Expand Up @@ -429,7 +429,6 @@ def _objective(trial: optuna.trial.Trial) -> float:
for a in cfg_copy.trainer.preprocessing.augmentations
if a.name != "Normalize"
] # manually remove Normalize so it doesn't duplicate it when creating new cfg instance
Config.clear_instance()
cfg = Config.get_config(cfg_copy.model_dump(), curr_params)

child_tracker.log_hyperparams(curr_params)
Expand Down
2 changes: 1 addition & 1 deletion luxonis_train/utils/loaders/base_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def get_classes(self) -> dict[str, list[str]]:
@rtype: dict[LabelType, list[str]]
@return: A dictionary mapping tasks to their classes.
"""
pass
...

def get_n_keypoints(self) -> dict[str, int] | None:
"""Returns the dictionary defining the semantic skeleton for each class using
Expand Down
19 changes: 8 additions & 11 deletions luxonis_train/utils/loaders/luxonis_loader_torch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from pathlib import Path
from typing import Literal, cast
from typing import Literal

import numpy as np
from luxonis_ml.data import (
Expand Down Expand Up @@ -158,13 +158,10 @@ def _parse_dataset(

logger.info(f"Parsing dataset from {dataset_dir} with name '{dataset_name}'")

return cast(
LuxonisDataset,
LuxonisParser(
dataset_dir,
dataset_name=dataset_name,
dataset_type=dataset_type,
save_dir="data",
delete_existing=True,
).parse(),
)
return LuxonisParser(
dataset_dir,
dataset_name=dataset_name,
dataset_type=dataset_type,
save_dir="data",
delete_existing=True,
).parse()
10 changes: 1 addition & 9 deletions luxonis_train/utils/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,7 @@ def from_missing_task(cls, task: str, present_tasks: list[str], class_name: str)
class BaseProtocol(BaseModel):
class Config:
arbitrary_types_allowed = True

@classmethod
def get_task(cls) -> str:
if len(cls.__annotations__) == 1:
return list(cls.__annotations__)[0]
raise ValueError(
"Protocol must have exactly one field for automatic task inference. "
"Implement custom `prepare` method in your attached module."
)
extra = "forbid"


class FeaturesProtocol(BaseProtocol):
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/test_sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from multi_input_modules import *

from luxonis_train.core import LuxonisModel
from luxonis_train.utils.config import Config

TEST_OUTPUT = Path("tests/integration/_test-output")
INFER_PATH = Path("tests/integration/_infer_save_dir")
Expand All @@ -35,7 +34,6 @@ def manage_out_dir():

@pytest.fixture(scope="function", autouse=True)
def clear_files():
Config.clear_instance()
yield
STUDY_PATH.unlink(missing_ok=True)
ONNX_PATH.unlink(missing_ok=True)
Expand Down

0 comments on commit 8870968

Please sign in to comment.