TrojanXu / yolov5-tensorrt

A tensorrt implementation of yolov5: https://github.com/ultralytics/yolov5
Apache License 2.0
191 stars 46 forks source link

RuntimeError: Exporting the operator hardswish to ONNX opset version 11 is not supported. Please open a bug to request ONNX export support for the missing operator. #44

Open ll553664391 opened 3 years ago

ll553664391 commented 3 years ago

Can you help me solve this problem

RuntimeError: Exporting the operator hardswish to ONNX opset version 11 is not supported. Please open a bug to request ONNX export support for the missing operator.

linsongxue commented 3 years ago

Use custom-defined Hardswish instead of the nn.Hardswish. You can find the Hardswish function in yolov5/utils/activations.py, and then, before exporting into onnx model, plz insert this code for k, m in model.named_modules(): m._non_persistent_buffers_set = set() if isinstance(m, models.common.Conv) and isinstance(m.act, nn.Hardswish): m.act = Hardswish()