Skip to content

Commit

Permalink
Add export_type for exporting OpenVINO (#419)
Browse files Browse the repository at this point in the history
* Add export_type for exporting OpenVINO 

* Fix bugs
  • Loading branch information
triple-Mu committed Jun 6, 2022
1 parent fb7e120 commit a744106
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions yolort/relay/head_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,21 @@ class FakePostProcess(nn.Module):
Default to 0.35
detections_per_img (int, optional): Number of best detections to keep after NMS.
Default to 100
export_type (str, optional): Export onnx backend support onnxruntime and openvino
"""

def __init__(
self,
iou_thresh: float = 0.45,
score_thresh: float = 0.35,
detections_per_img: int = 100,
export_type="onnxruntime",
):
super().__init__()
self.detections_per_img = detections_per_img
self.iou_thresh = iou_thresh
self.score_thresh = score_thresh
self.export_type = export_type
self.nms_func = NonMaxSupressionOp.apply

def forward(self, x: Tensor):
Expand All @@ -72,6 +75,8 @@ def forward(self, x: Tensor):
selected_indices = self.nms_func(boxes, scores_t, detections_per_img, iou_thresh, score_thresh)

i, k = selected_indices[:, 0], selected_indices[:, 2]
if self.export_type == "openvino":
i, k = i[i >= 0], k = k[k >= 0]
boxes_keep = boxes[i, k, :]
classes_keep = classes[i, k, :]
scores_keep = scores[i, k, :]
Expand Down

0 comments on commit a744106

Please sign in to comment.