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

E2E Tests: ImageManip node and better checks. #140

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
38 changes: 33 additions & 5 deletions tests/end_to_end/manual.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import argparse

import depthai as dai
from utils import get_input_shape, parse_model_slug
from utils import get_input_shape, get_num_inputs, parse_model_slug

from depthai_nodes.parsing_neural_network import ParsingNeuralNetwork

Expand All @@ -25,7 +25,8 @@

try:
device = dai.Device(dai.DeviceInfo(args.ip))
except Exception:
except Exception as e:
print(e)
print("Can't connect to the device with IP/mxid: ", args.ip)
exit(6)

Expand All @@ -41,13 +42,20 @@
)
try:
nn_archive_path = dai.getModelFromZoo(model_desc, useCached=False)
nn_archive = dai.NNArchive(nn_archive_path)
except Exception:
except Exception as e:
print(e)
print(
f"Couldn't find model {args.model_slug} for {device.getPlatform().name} in the ZOO"
)
device.close()
exit(7)
try:
nn_archive = dai.NNArchive(nn_archive_path)
except Exception as e:
print(e)
print(f"Couldn't load the model {args.model_slug} from NN archive.")
device.close()
exit(9)

else:
nn_archive = dai.NNArchive(args.nn_archive)
Expand All @@ -59,7 +67,27 @@
device.close()
exit(5)

input_size = get_input_shape(nn_archive)
if get_num_inputs(nn_archive) > 1:
print(
"This model has more than one input. Currently, only models with one input are supported."
)
device.close()
exit(8)

try:
input_size = get_input_shape(nn_archive)
except Exception as e:
print(e)
device.close()
exit(8)

if input_size[0] % 2 != 0 or input_size[1] % 2 != 0:
print(
f"We only support even numbers for resolution sizes. Got {input_size[0]}x{input_size[1]}."
)
device.close()
exit(8)

if input_size[0] < 128 and input_size[1] < 128:
print("Input size is too small for the device.")
device.close()
Expand Down
6 changes: 4 additions & 2 deletions tests/end_to_end/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,17 @@ def test_pipelines(IP: str, ip_platform: str, nn_archive_path, slug):
)
except subprocess.CalledProcessError as e:
if e.returncode == 5:
pytest.skip(f"Model not supported on {ip_platform}.")
pytest.skip(f"Model {slug} not supported on {ip_platform}.")
elif e.returncode == 6:
pytest.skip(f"Can't connect to the device with IP/mxid: {IP}")
elif e.returncode == 7:
pytest.skip(f"Couldn't find model {slug} in the ZOO")
elif e.returncode == 8:
pytest.skip(
"The model is not supported in this test. (small input size, grayscale image, etc.)"
f"The model {slug} is not supported in this test. (small input size, grayscale image, etc.)"
)
elif e.returncode == 9:
pytest.skip(f"Couldn't load the model {slug} from NN archive.")
else:
raise RuntimeError("Pipeline crashed.") from e
except subprocess.TimeoutExpired:
Expand Down
7 changes: 7 additions & 0 deletions tests/end_to_end/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ def get_input_shape(nn_archive: dai.NNArchive) -> Tuple[int, int]:
return input_shape


def get_num_inputs(nn_archive: dai.NNArchive) -> int:
"""Get the number of inputs of the model from the NN archive."""
inputs = get_inputs_from_archive(nn_archive)

return len(inputs)


def parse_model_slug(full_slug) -> Tuple[str, str]:
"""Parse the model slug into model_slug and model_version_slug."""
if ":" not in full_slug:
Expand Down
Loading