paddle 51 dynamic map to onnx (realize dynamic size)

Paddle does not support exporting dynamic graphs to onnx models that support dynamic sizes. Reference: https://blog.csdn.net/ab0902cd/article/details/120200557 , modify the exported onnx model. Finally, the model exported by paddle supports dynamic size. Taking the semantic segmentation model as an example, modify the exported static size model to a dynamic size.

pre-install command

pip install paddle2onnx
pip install onnx
pip install onnxruntime-gpu

Among them, paddle2onnx is used to convert the static graph model into an onnx model, the onnx library is used to modify the input and output nodes of the model, and the onnxruntime-gpu library is used to infer the onnx model

1. Model wrap operation

This operation is not necessary, it is just a wrap operation on a dynamic graph model to facilitate modification of the input and output results of the model.

import paddle
from paddle import nn
from paddle.static import InputSp

Guess you like

Origin blog.csdn.net/a486259/article/details/130115358