Skip to content

Commit

Permalink
Makes batch size dynamic (#2339)
Browse files Browse the repository at this point in the history
Made batch dimension of ONNX export dynamic when specifying input shape.
  • Loading branch information
Marcus1506 authored Oct 3, 2024
1 parent 191e21f commit 404e896
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/anomalib/models/components/base/export_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ def to_onnx(
export_root = _create_export_root(export_root, ExportType.ONNX)
input_shape = torch.zeros((1, 3, *input_size)) if input_size else torch.zeros((1, 3, 1, 1))
dynamic_axes = (
None if input_size else {"input": {0: "batch_size", 2: "height", 3: "weight"}, "output": {0: "batch_size"}}
{"input": {0: "batch_size"}, "output": {0: "batch_size"}}
if input_size
else {"input": {0: "batch_size", 2: "height", 3: "weight"}, "output": {0: "batch_size"}}
)
_write_metadata_to_json(self._get_metadata(task), export_root)
onnx_path = export_root / "model.onnx"
Expand Down

0 comments on commit 404e896

Please sign in to comment.