Installation and Usage of the Paddle2ONNX Plugin¶
The Paddle2ONNX plugin for PaddleX provides the ability to convert PaddlePaddle static models to ONNX format models, leveraging the underlying Paddle2ONNX.
1. Installation¶
# Windows users need to use the following command to install the dev version of paddlepaddle
# python -m pip install --pre paddlepaddle -i https://www.paddlepaddle.org.cn/packages/nightly/cpu/
# Install Paddle2ONNX plugin
paddlex --install paddle2onnx
2. Usage¶
2.1 Parameter Introduction¶
Parameter | Type | Description |
---|---|---|
paddle_model_dir | str | Directory containing the Paddle model. |
onnx_model_dir | str | Output directory for the ONNX model, which can be the same as the Paddle model directory. Defaults to onnx . |
opset_version | int | The ONNX opset version to use. If a lower-version opset cannot complete the conversion, a higher-version opset will be automatically selected for the conversion. Defaults to 7 . |
2.2 Usage Method¶
Usage:
paddlex \
--paddle2onnx \ # Use the paddle2onnx function
--paddle_model_dir /your/paddle_model/dir \ # Specify the directory where the Paddle model is located
--onnx_model_dir /your/onnx_model/output/dir \ # Specify the output directory for the converted ONNX model
--opset_version 7 # Specify the ONNX opset version to use
Taking the ResNet18 model from the image_classification module as an example: