Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added tests, fix in docstring
Browse files Browse the repository at this point in the history
klemen1999 committed Nov 6, 2024
1 parent 4511ce9 commit e81ec85
Showing 2 changed files with 47 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -24,8 +24,8 @@ class PreprocessingBlock(BaseModelExtraForbid):
@type interleaved_to_planar: bool | None
@ivar interleaved_to_planar: If True input to the model is
interleaved (NHWC) else planar (NCHW).
@type layout: str | None
@ivar layout: DepthAI input type which is read by DepthAI to
@type dai_type: str | None
@ivar dai_type: DepthAI input type which is read by DepthAI to
automatically setup the pipeline.
"""

45 changes: 45 additions & 0 deletions tests/test_nn_archive/test_nn_archive.py
Original file line number Diff line number Diff line change
@@ -132,6 +132,51 @@ def test_archive_generator(
assert "config.json" in tar.getnames()


def test_config_version():
from luxonis_ml.nn_archive import Config

cfg_dict = {
"config_version": "1.0",
"model": {
"metadata": {
"name": "test_model",
"path": "test_model.onnx",
},
"inputs": [
{
"name": "input",
"shape": [1, 3, 224, 224],
"input_type": "image",
"layout": "nchw",
"dtype": "float32",
"preprocessing": {
"mean": [0.485, 0.456, 0.406],
"scale": [0.229, 0.224, 0.225],
"reverse_channels": False,
"interleaved_to_planar": False,
},
}
],
"outputs": [
{
"name": "output",
"dtype": "float32",
}
],
"heads": [],
},
}
Config(**cfg_dict)
cfg_dict["config_version"] = "1.2"
Config(**cfg_dict)
cfg_dict["config_version"] = "1.2.2"
with pytest.raises(ValidationError):
Config(**cfg_dict)
cfg_dict["config_version"] = "1.a"
with pytest.raises(ValidationError):
Config(**cfg_dict)


def test_optional_head_name():
from luxonis_ml.nn_archive.config_building_blocks.base_models.head_metadata import (
HeadMetadata,

0 comments on commit e81ec85

Please sign in to comment.