The conversion of neural networks to onnx format may exchange certain layer with structures, that cannot be processed by DRP-AI.

To reduce that effect, please evaluate ONNX Simplifier.

"ONNX Simplifier infers the whole computation graph and then replaces the redundant operators with their constant outputs (a.k.a. constant folding). "


Example:

Dependencies:

  • tensorflow-cpu==2.17.0
  • onnx==1.17.0
  • tf2onnx==1.16.1
  • onnx-simplifier

Conversion flow (assuming Tensorflow is installed):

$ pip install --upgrade pip
$ pip install onnx==1.17.0
$ pip install tf2onnx==1.16.1
$ pip install onnx-simplifier

$ python -m tf2onnx.convert \
    --saved-model exported_pb \
    --output <name>.onnx \
    --inputs-as-nchw keras_tensor

$ onnxsim \
    <name>.onnx \
    <name>_simplified.onnx \
    --overwrite-input-shape "keras_tensor:1,3,224,224"


  • No labels