From c4b375bbf6fb15171d8de5b75f260277ccbe18c5 Mon Sep 17 00:00:00 2001 From: mdraw Date: Mon, 19 Apr 2021 18:38:14 +0200 Subject: [PATCH] Fix breakage with ONNX 1.9.0 Remove the call to onnx.utils.polish_model() because it has been removed without replacement in ONNX 1.9.0. This should be fine though, because onnxruntime now actually performs graph optimizations itself by default: https://www.onnxruntime.ai/docs/resources/graph-optimizations.html --- deface/centerface.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/deface/centerface.py b/deface/centerface.py index 29f30e3..a5cfb95 100644 --- a/deface/centerface.py +++ b/deface/centerface.py @@ -34,7 +34,6 @@ def __init__(self, onnx_path=None, in_shape=None, backend='auto'): self.net = cv2.dnn.readNetFromONNX(onnx_path) elif self.backend == 'onnxrt': import onnx - import onnx.utils import onnxruntime # Silence warnings about unnecessary bn initializers @@ -42,9 +41,8 @@ def __init__(self, onnx_path=None, in_shape=None, backend='auto'): static_model = onnx.load(onnx_path) dyn_model = self.dynamicize_shapes(static_model) - dyn_model = onnx.utils.polish_model(dyn_model) self.sess = onnxruntime.InferenceSession(dyn_model.SerializeToString()) - + preferred_provider = self.sess.get_providers()[0] preferred_device = 'GPU' if preferred_provider.startswith('CUDA') else 'CPU' # print(f'Running on {preferred_device}.')