Skip to content

Commit

Permalink
Fix breakage with ONNX 1.9.0
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mdraw committed Apr 19, 2021
1 parent 4fd379c commit c4b375b
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions deface/centerface.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,15 @@ 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
onnxruntime.set_default_logger_severity(3)

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}.')
Expand Down

0 comments on commit c4b375b

Please sign in to comment.