Skip to content

Commit 410f388

Browse files
committed
Add numpy conversion to shape
1 parent ca6568e commit 410f388

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/python/model_api/models/result/segmentation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ def __init__(
167167
shape: np.ndarray | list[tuple[int, int]],
168168
excluded_shapes: list[np.ndarray] | list[tuple[int, int]] | None = None,
169169
):
170-
self.shape = shape
170+
self.shape = np.array(shape)
171171
self.label = label
172172
self.probability = probability
173-
self.excluded_shapes = excluded_shapes
173+
self.excluded_shapes = np.array(excluded_shapes) if excluded_shapes is not None else None
174174

175175
def __str__(self):
176176
num_children = len(self.excluded_shapes) if self.excluded_shapes is not None else 0
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# Copyright (C) 2025 Intel Corporation
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
6+
import numpy as np
7+
from model_api.models.result import Contour
8+
9+
10+
def test_contour_type():
11+
contour = Contour(
12+
shape=[(100, 100)],
13+
label=1,
14+
probability=0.9,
15+
excluded_shapes=[(50, 50), (60, 60)],
16+
)
17+
18+
assert isinstance(contour.shape, np.ndarray)
19+
assert isinstance(contour.excluded_shapes, np.ndarray)
20+
assert contour.label == 1
21+
assert contour.probability == 0.9
22+
assert np.array_equal(contour.excluded_shapes, np.array([(50, 50), (60, 60)]))

0 commit comments

Comments
 (0)