Skip to content

Commit

Permalink
Export static shape for detection/instance-segmentation models (#4113)
Browse files Browse the repository at this point in the history
* Add onnxruntime dependency and update dynamic axes in detection/inst-seg models
  • Loading branch information
eugene123tw authored Nov 19, 2024
1 parent 046602d commit 0bb3f2e
Show file tree
Hide file tree
Showing 11 changed files with 156 additions and 139 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ dev = [
"pytest-mock",
"pytest-csv",
"pytest-cov",
"onnxruntime==1.20.0",
]

docs = [
Expand Down
2 changes: 1 addition & 1 deletion src/otx/algo/detection/atss.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def _exporter(self) -> OTXModelExporter:
"input_names": ["image"],
"output_names": ["boxes", "labels"],
"dynamic_axes": {
"image": {0: "batch", 2: "height", 3: "width"},
"image": {0: "batch"},
"boxes": {0: "batch", 1: "num_dets"},
"labels": {0: "batch", 1: "num_dets"},
},
Expand Down
2 changes: 1 addition & 1 deletion src/otx/algo/detection/rtmdet.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def _exporter(self) -> OTXModelExporter:
"input_names": ["image"],
"output_names": ["boxes", "labels"],
"dynamic_axes": {
"image": {0: "batch", 2: "height", 3: "width"},
"image": {0: "batch"},
"boxes": {0: "batch", 1: "num_dets"},
"labels": {0: "batch", 1: "num_dets"},
},
Expand Down
2 changes: 1 addition & 1 deletion src/otx/algo/detection/ssd.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def _exporter(self) -> OTXModelExporter:
"input_names": ["image"],
"output_names": ["boxes", "labels"],
"dynamic_axes": {
"image": {0: "batch", 2: "height", 3: "width"},
"image": {0: "batch"},
"boxes": {0: "batch", 1: "num_dets"},
"labels": {0: "batch", 1: "num_dets"},
},
Expand Down
2 changes: 1 addition & 1 deletion src/otx/algo/detection/yolov9.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def _exporter(self) -> OTXModelExporter:
"export_params": True,
"opset_version": 11,
"dynamic_axes": {
"image": {0: "batch", 2: "height", 3: "width"},
"image": {0: "batch"},
"boxes": {0: "batch", 1: "num_dets"},
"labels": {0: "batch", 1: "num_dets"},
},
Expand Down
2 changes: 1 addition & 1 deletion src/otx/algo/detection/yolox.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def _exporter(self) -> OTXModelExporter:
"export_params": True,
"opset_version": 11,
"dynamic_axes": {
"image": {0: "batch", 2: "height", 3: "width"},
"image": {0: "batch"},
"boxes": {0: "batch", 1: "num_dets"},
"labels": {0: "batch", 1: "num_dets"},
},
Expand Down
2 changes: 1 addition & 1 deletion src/otx/algo/instance_segmentation/maskdino.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def _exporter(self) -> OTXModelExporter:
onnx_export_configuration={
"input_names": ["image"],
"dynamic_axes": {
"image": {0: "batch", 2: "height", 3: "width"},
"image": {0: "batch"},
"boxes": {0: "batch", 1: "num_dets"},
"labels": {0: "batch", 1: "num_dets"},
"masks": {0: "batch", 1: "num_dets", 2: "height", 3: "width"},
Expand Down
2 changes: 1 addition & 1 deletion src/otx/algo/instance_segmentation/maskrcnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def _exporter(self) -> OTXModelExporter:
"input_names": ["image"],
"output_names": ["boxes", "labels", "masks"],
"dynamic_axes": {
"image": {0: "batch", 2: "height", 3: "width"},
"image": {0: "batch"},
"boxes": {0: "batch", 1: "num_dets"},
"labels": {0: "batch", 1: "num_dets"},
"masks": {0: "batch", 1: "num_dets", 2: "height", 3: "width"},
Expand Down
2 changes: 1 addition & 1 deletion src/otx/algo/instance_segmentation/maskrcnn_tv.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def _exporter(self) -> OTXModelExporter:
"input_names": ["image"],
"output_names": ["boxes", "labels", "masks"],
"dynamic_axes": {
"image": {0: "batch", 2: "height", 3: "width"},
"image": {0: "batch"},
"boxes": {0: "batch", 1: "num_dets"},
"labels": {0: "batch", 1: "num_dets"},
"masks": {0: "batch", 1: "num_dets", 2: "height", 3: "width"},
Expand Down
2 changes: 1 addition & 1 deletion src/otx/algo/instance_segmentation/rtmdet_inst.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def _exporter(self) -> OTXModelExporter:
"input_names": ["image"],
"output_names": ["boxes", "labels", "masks"],
"dynamic_axes": {
"image": {0: "batch", 2: "height", 3: "width"},
"image": {0: "batch"},
"boxes": {0: "batch", 1: "num_dets"},
"labels": {0: "batch", 1: "num_dets"},
"masks": {0: "batch", 1: "num_dets", 2: "height", 3: "width"},
Expand Down
Loading

0 comments on commit 0bb3f2e

Please sign in to comment.