Yolov5: Converting model including NMS to ONNX

Created on 7 Dec 2020  ·  2Comments  ·  Source: ultralytics/yolov5

Dear @glenn-jocher ,

Have you ever converted a full model either including NMS or all (NMS, autoshape) to ONNX successfully?

question

All 2 comments

Current autoshape use OpenCV resize function, so it has difficultly to conclude it to the ONNX model (I guess). torchvision has a similar funciton named GeneralizedRCNNTransform. Replace it to GeneralizedRCNNTransform should make sense to export yolov5 to a full model. I have made some experiments in my own repo, and here is a working jupyter notebook.

And If we replace opencv function to GeneralizedRCNNTransform (which key ops is torch.nn.functional.interpolate comparing to OpenCV's cv2.resize), there maybe some numerical difference for using different interpolation mode.

Point it out if I'm wrong here.

BTW, NMS in this repo should be exported successfully now.

@zhiqwang autoshape() models can accept PIL, cv2, and numpy inputs, or any combination of the above in a list. Some examples are:
https://github.com/ultralytics/yolov5/blob/68e6ab668b30a6014215b94e399151f8c76e471a/models/common.py#L131-L138

Was this page helpful?
0 / 5 - 0 ratings