Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .github/workflows/security-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
severity-level: "LOW"
confidence-level: "LOW"
config_file: "${{ matrix.project }}/pyproject.toml"
artifact-name: "bandit-results-${{ matrix.project }}"
fail-on-findings: ${{ (github.event_name == 'pull_request' || github.event_name == 'merge_group') && 'true' || 'false' }}

bandit-scan:
Expand Down
4 changes: 2 additions & 2 deletions model_api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,6 @@ pythonpath = ["src"]
skips = ["B101", "B310"]

[tool.coverage.report]
# Fail if total coverage is below 50%
fail_under = 50
# Fail if total coverage is below 100%
fail_under = 100
show_missing = true
5 changes: 1 addition & 4 deletions model_api/src/model_api/adapters/openvino_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,7 @@ def reshape_dynamic_inputs(self) -> None:
static_shape.append(1)
elif len(shape) == 4:
if is_nchw:
if i == 1:
static_shape.append(3)
else:
static_shape.append(224)
static_shape.append(224)
else:
if i == 3:
static_shape.append(3)
Expand Down
32 changes: 20 additions & 12 deletions model_api/src/model_api/adapters/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,14 @@ def crop_resize_graph(input: Output, size: tuple[int, int], input_dtype: str = "
cropped_frame = if_node.set_output(then_body_res_1, else_body_res_1)

elif desired_aspect_ratio < 1:
new_width = opset.floor(
opset.multiply(
opset.convert(ih, destination_type="f32"),
desired_aspect_ratio,
new_width = opset.convert(
opset.floor(
opset.multiply(
opset.convert(ih, destination_type="f32"),
np.float32(desired_aspect_ratio),
),
),
destination_type="i32",
)
offset = opset.unsqueeze(
opset.divide(
Expand All @@ -272,11 +275,14 @@ def crop_resize_graph(input: Output, size: tuple[int, int], input_dtype: str = "
axes=[w_axis],
)
elif desired_aspect_ratio > 1:
new_hight = opset.floor(
opset.multiply(
opset.convert(iw, destination_type="f32"),
desired_aspect_ratio,
new_hight = opset.convert(
opset.floor(
opset.multiply(
opset.convert(iw, destination_type="f32"),
np.float32(desired_aspect_ratio),
),
),
destination_type="i32",
)
offset = opset.unsqueeze(
opset.divide(
Expand Down Expand Up @@ -461,6 +467,7 @@ def window_preprocess_graph(
"""OV graph: window intensity scaling [center-width/2, center+width/2] to [0, 1]."""
low = window_center - window_width / 2.0
span = window_width
# opset.clamp requires scalar float min/max, not opset.constant nodes
return opset.clamp(
opset.divide(
opset.subtract(
Expand All @@ -469,8 +476,8 @@ def window_preprocess_graph(
),
opset.constant(span, dtype=Type.f32),
),
opset.constant(0.0, dtype=Type.f32),
opset.constant(1.0, dtype=Type.f32),
0.0,
1.0,
)


Expand Down Expand Up @@ -500,13 +507,14 @@ def range_scale_preprocess_graph(
Multiplies by *scale_factor*, clamps to [min_value, max_value], then
normalises to [0, 1] via ``(clamped - min) / (max - min)``.
"""
# opset.clamp requires scalar float min/max, not opset.constant nodes
clamped = opset.clamp(
opset.multiply(
opset.convert(output, destination_type="f32"),
opset.constant(scale_factor, dtype=Type.f32),
),
opset.constant(min_value, dtype=Type.f32),
opset.constant(max_value, dtype=Type.f32),
min_value,
max_value,
)
range = max_value - min_value
if range == 0:
Expand Down
2 changes: 1 addition & 1 deletion model_api/src/model_api/models/keypoint_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def _get_simcc_maximum(
msg = f"Invalid shape {simcc_y.shape}"
raise ValueError(msg)
if simcc_x.ndim != simcc_y.ndim:
msg = f"{simcc_x.shape} != {simcc_y.shape}"
msg = f"Invalid shape: {simcc_x.shape} != {simcc_y.shape}"
raise ValueError(msg)

if simcc_x.ndim == 3:
Expand Down
Loading
Loading