Skip to main content

Export PaddlePaddle to ONNX

Project description

Paddle2ONNX

简体中文 | English

1 Paddle2ONNX 简介

Paddle2ONNX 支持将 PaddlePaddle 模型格式转化到 ONNX 模型格式。通过 ONNX 可以完成将 Paddle 模型到多种推理引擎的部署,包括 TensorRT/OpenVINO/MNN/TNN/NCNN,以及其它对 ONNX 开源格式进行支持的推理引擎或硬件。

2 Paddle2ONNX 环境依赖

Paddle2ONNX 依赖PaddlePaddle3.0,我们建议您在以下环境下使用 Paddle2ONNX :

  • PaddlePaddle == 3.0.0
  • onnxruntime >= 1.10.0

3 安装 Paddle2ONNX

如果您只是想要安装 Paddle2ONNX 且没有二次开发的需求,你可以通过执行以下代码来快速安装 Paddle2ONNX

pip install paddle2onnx

如果你希望对 Paddle2ONNX 进行二次开发,请按照Github 源码安装方式编译Paddle2ONNX。

4 快速使用教程

4.1 获取PaddlePaddle部署模型

Paddle2ONNX 在导出模型时,需要传入部署模型格式,包括两个文件

  • model_name.json: 表示模型结构
  • model_name.pdiparams: 表示模型参数

4.2 调整Paddle模型

如果对Paddle模型的输入输出需要做调整,可以前往Paddle 相关工具查看教程。

4.3 使用命令行转换 PaddlePaddle 模型

你可以通过使用命令行并通过以下命令将Paddle模型转换为ONNX模型

paddle2onnx --model_dir model_dir \
            --model_filename model.json \
            --params_filename model.pdiparams \
            --save_file model.onnx

可调整的转换参数如下表:

参数 参数说明
--model_dir 配置包含 Paddle 模型的目录路径
--model_filename [可选] 配置位于 --model_dir 下存储网络结构的文件名
--params_filename [可选] 配置位于 --model_dir 下存储模型参数的文件名
--save_file 指定转换后的模型保存目录路径
--opset_version [可选] 配置转换为ONNX的OpSet版本,目前支持7~19等多个版本,默认为 9
--enable_auto_update_opset [可选] 是否开启opset version自动升级功能,当低版本opset无法转换时,自动选择更高版本的opset进行转换, 默认为 True
--enable_onnx_checker [可选] 配置是否检查导出为 ONNX 模型的正确性, 建议打开此开关, 默认为 True
--enable_dist_prim_all [可选] 是否开启组合算子拆解,默为 False
--optimize_tool [可选] ONNX模型优化工具,可选择onnxoptimizer、polygraphy、None, 默认为 onnxoptimizer
--enable_verbose [可选] 是否打印更更详细的日志信息,默认为 False
--version [可选] 查看 paddle2onnx 版本

4.4 裁剪ONNX

如果你需要调整 ONNX 模型,请参考 ONNX 相关工具

4.5 优化ONNX

如你对导出的 ONNX 模型有优化的需求,推荐使用 onnxslim 对模型进行优化:

pip install onnxslim
onnxslim model.onnx slim.onnx

5 代码贡献

繁荣的生态需要大家的携手共建,开发者可以参考 Paddle2ONNX 贡献指南 来为 Paddle2ONNX 贡献代码。

6 License

Provided under the Apache-2.0 license.

7 感谢捐赠

  • 感谢 PaddlePaddle 团队提供服务器支持 Paddle2ONNX 的 CI 建设。
  • 感谢社区用户 chenwhql, luotao1, goocody, jeff41404, jzhang553, ZhengBicheng 于2024年03月28日向 Paddle2ONNX PMC 捐赠共 10000 元人名币用于 Paddle2ONNX 的发展。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

paddle2onnx-2.1.0-cp312-cp312-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.12Windows x86-64

paddle2onnx-2.1.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

paddle2onnx-2.1.0-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (3.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

paddle2onnx-2.1.0-cp312-cp312-macosx_12_0_universal2.whl (2.8 MB view details)

Uploaded CPython 3.12macOS 12.0+ universal2 (ARM64, x86-64)

paddle2onnx-2.1.0-cp311-cp311-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.11Windows x86-64

paddle2onnx-2.1.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

paddle2onnx-2.1.0-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (3.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

paddle2onnx-2.1.0-cp311-cp311-macosx_12_0_universal2.whl (2.8 MB view details)

Uploaded CPython 3.11macOS 12.0+ universal2 (ARM64, x86-64)

paddle2onnx-2.1.0-cp310-cp310-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.10Windows x86-64

paddle2onnx-2.1.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

paddle2onnx-2.1.0-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (3.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

paddle2onnx-2.1.0-cp310-cp310-macosx_12_0_universal2.whl (2.8 MB view details)

Uploaded CPython 3.10macOS 12.0+ universal2 (ARM64, x86-64)

paddle2onnx-2.1.0-cp39-cp39-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.9Windows x86-64

paddle2onnx-2.1.0-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

paddle2onnx-2.1.0-cp39-cp39-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (3.3 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

paddle2onnx-2.1.0-cp39-cp39-macosx_12_0_universal2.whl (2.8 MB view details)

Uploaded CPython 3.9macOS 12.0+ universal2 (ARM64, x86-64)

paddle2onnx-2.1.0-cp38-cp38-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.8Windows x86-64

paddle2onnx-2.1.0-cp38-cp38-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

paddle2onnx-2.1.0-cp38-cp38-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (3.3 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

paddle2onnx-2.1.0-cp38-cp38-macosx_12_0_universal2.whl (2.8 MB view details)

Uploaded CPython 3.8macOS 12.0+ universal2 (ARM64, x86-64)

File details

Details for the file paddle2onnx-2.1.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for paddle2onnx-2.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 55fe0b6eba1227b3a9b362a0881f60a3fedb4c6251c3de7d42f0113ab26bbbf9
MD5 79f56b6f9f91ef7675d1aac86ef931c2
BLAKE2b-256 9fb1b7a4b875cd61063dd5945fde212925493042a7e9f2a9346afa401e3d1510

See more details on using hashes here.

File details

Details for the file paddle2onnx-2.1.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for paddle2onnx-2.1.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7fef03d6c40bbe5e2ebc6e895b25b8860acd28803601195884e8ffec5ffa1109
MD5 c19383eaa21efa4bd72a6d0103ce340d
BLAKE2b-256 0653a775d7e27318f7a2f80ed494c28d8ede7a32359bf0f01c16444aaf3a9044

See more details on using hashes here.

File details

Details for the file paddle2onnx-2.1.0-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for paddle2onnx-2.1.0-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f4ce08eb1be27553adbda65bff01c96713a5d2d0b1219062bf7c4107e971285f
MD5 68d5db49fd067c19017c8f5b5b32a94a
BLAKE2b-256 f10d8ba572c1e41d34504ffc40e895216e7c74ba28e6f45f5e278f51a0bfa4f2

See more details on using hashes here.

File details

Details for the file paddle2onnx-2.1.0-cp312-cp312-macosx_12_0_universal2.whl.

File metadata

File hashes

Hashes for paddle2onnx-2.1.0-cp312-cp312-macosx_12_0_universal2.whl
Algorithm Hash digest
SHA256 0c45e24ff9174f2e74d01e93cbcca98fa84c5030499f87f333d3d4d6452b3b08
MD5 71e43ad72514c7a95a4c160603034826
BLAKE2b-256 4fac6d6ac7e3dd8c36649131eda15f36230e6595cb31b46f0e45c59db390e72f

See more details on using hashes here.

File details

Details for the file paddle2onnx-2.1.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for paddle2onnx-2.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 478993e17ed0212b79a4d6e2d8d0582ebb19c7230b7f365d51222833e98581b3
MD5 1513a449a818f35ba73adcd07d3f9ba2
BLAKE2b-256 c1c70f29de6caa243e1d951f378d69b311da51d0bd6d944778e36def9266d990

See more details on using hashes here.

File details

Details for the file paddle2onnx-2.1.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for paddle2onnx-2.1.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b21af246598deb3b0ee4b2b5c3c671816e0f29b3594c5b311cbe6e356dffca8c
MD5 aa8812c5c5b706b73017269a435efbc7
BLAKE2b-256 e5a196ae5163999567d7104f20f09c391810fc025c47c78da23216a8c5668f63

See more details on using hashes here.

File details

Details for the file paddle2onnx-2.1.0-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for paddle2onnx-2.1.0-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f2f357001a935419ed4abc1463d78fa4606553e783793b9a8fe5876129d9d315
MD5 568b86b84062411e370e266147dd49c6
BLAKE2b-256 13ae4a1b0e9ab7b815782d76c921bf462d8c8d146c164a56d29861cf6b45d9d0

See more details on using hashes here.

File details

Details for the file paddle2onnx-2.1.0-cp311-cp311-macosx_12_0_universal2.whl.

File metadata

File hashes

Hashes for paddle2onnx-2.1.0-cp311-cp311-macosx_12_0_universal2.whl
Algorithm Hash digest
SHA256 1f412901114faf76ab715bf948f9b44dd1fdebb39657ccb8cdfc381d2d7ca641
MD5 8b2131d3d0d5f12f97f442363fc38fd7
BLAKE2b-256 3402a34e24c0eb098084f0f21a36b682da9ac148a2b44c54c34078e127f8153e

See more details on using hashes here.

File details

Details for the file paddle2onnx-2.1.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for paddle2onnx-2.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 327ba7b5e0174054e315ed8f5983755000ff5e56844b6f394d55a5156b11e158
MD5 c3f0d4fa93c5b03176c1095c07e1b9e3
BLAKE2b-256 be95bdda235cd820cd5062713f1a9a89b33b4a19d0aca6ef13d9e2211e5ff1d0

See more details on using hashes here.

File details

Details for the file paddle2onnx-2.1.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for paddle2onnx-2.1.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2d69e0d1bd96a8d80452dfd7fda9e8869ff37f333c0a504530983baf5f221b21
MD5 2bed536a004d6cd1a57914dfdfe85f40
BLAKE2b-256 5731b9fb0b373f7a0db4e39c8cb4a708b4a016920e284b5b37dffae8ab7dac90

See more details on using hashes here.

File details

Details for the file paddle2onnx-2.1.0-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for paddle2onnx-2.1.0-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c744ec54b43f7b1050b1e1d9d429786e684950a62fc3b274efd2afcb00cde552
MD5 b58c13046faa4dbd785ebe6ec8df45b6
BLAKE2b-256 2f286539a7f5d8b7ea1a5f322a2cd2ba60734c1321608152a1761db559c1c45e

See more details on using hashes here.

File details

Details for the file paddle2onnx-2.1.0-cp310-cp310-macosx_12_0_universal2.whl.

File metadata

File hashes

Hashes for paddle2onnx-2.1.0-cp310-cp310-macosx_12_0_universal2.whl
Algorithm Hash digest
SHA256 c1c4e3e2996044ea4f67b8e3af90da08d86962aa411286532012c72f271bab5d
MD5 b4a95102d740f053c122b5380fa8d47b
BLAKE2b-256 aa7b0807064f09428609cc02b8ada510bb31c1df8db5316597a41a0769e62143

See more details on using hashes here.

File details

Details for the file paddle2onnx-2.1.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: paddle2onnx-2.1.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 2.0 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.13

File hashes

Hashes for paddle2onnx-2.1.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 2b205945d058cbb3cb2e322408bf279f8e746aaeb85b51c0f3e461708af40686
MD5 ad420fd533d389b93e6c256fc52beb97
BLAKE2b-256 ffa370eca4fd0e818dada6f0058567c529dd3f3ac850b3aec40c4e70a3af01bf

See more details on using hashes here.

File details

Details for the file paddle2onnx-2.1.0-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for paddle2onnx-2.1.0-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 289c56d041ee51b9e70d42b0262d4cf93d931ad8c8bc23441c25881f78d18786
MD5 815908de085c080e44b339458f017809
BLAKE2b-256 d18fb007aa8e4d2b2924a335fd14e0be41e3731c33c20f5b7a5426f057e50d90

See more details on using hashes here.

File details

Details for the file paddle2onnx-2.1.0-cp39-cp39-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for paddle2onnx-2.1.0-cp39-cp39-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 25ae5c20210166a1692acd5414fc9f50307f45bdd0a4aee2fb755ca08bda27b3
MD5 0a5b0239614f35827f86718bf6dec6c9
BLAKE2b-256 46c3de304aaa2e96ef3a6e38c5d1b66e3d77efe8d2e25c0f87820286d3fb71f8

See more details on using hashes here.

File details

Details for the file paddle2onnx-2.1.0-cp39-cp39-macosx_12_0_universal2.whl.

File metadata

File hashes

Hashes for paddle2onnx-2.1.0-cp39-cp39-macosx_12_0_universal2.whl
Algorithm Hash digest
SHA256 53c52eb28ce7785459dfd75ea930d0e4a316982384ca65b950ace1075648252f
MD5 7436b2a75c5be607b178b97fdc7a75ab
BLAKE2b-256 a9a0148f216002ea760c43945ff9d0d794ae8204529fe2017d739e1719bf0a83

See more details on using hashes here.

File details

Details for the file paddle2onnx-2.1.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: paddle2onnx-2.1.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 2.0 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for paddle2onnx-2.1.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 141eca67a2f2af4033a4b26e746e0c987ea4d4468bd102802cd408cc28fe17ad
MD5 6193907dc878dff5cd192567a0956a50
BLAKE2b-256 c0acea558b624c22d7044cc245d54b1fd0955b5da58ffd2ad7622e7923b36562

See more details on using hashes here.

File details

Details for the file paddle2onnx-2.1.0-cp38-cp38-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for paddle2onnx-2.1.0-cp38-cp38-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1619149ca27dd1dc282f7497ef152c96a36738a9ee9f88ecac2e20203ab9b39a
MD5 6bae74c71733d06d2ca499a61c100fb2
BLAKE2b-256 cd6cb467b89ba461dd71109ae9ac311cc800370f5153b0ed8c17971a8db45297

See more details on using hashes here.

File details

Details for the file paddle2onnx-2.1.0-cp38-cp38-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for paddle2onnx-2.1.0-cp38-cp38-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 792474f6fe612116a850e7f0f33d162d90f8c7a1cfa60e9bdf2cc6a80b1bda85
MD5 0086cd9f7d3cf27b90bdf82253aca209
BLAKE2b-256 591d26f3ce1fb98469779031e04f81a691fa17f7ac59f046117a668d483e9f49

See more details on using hashes here.

File details

Details for the file paddle2onnx-2.1.0-cp38-cp38-macosx_12_0_universal2.whl.

File metadata

File hashes

Hashes for paddle2onnx-2.1.0-cp38-cp38-macosx_12_0_universal2.whl
Algorithm Hash digest
SHA256 b00ae06bcd212264135399e1667e14bf21a5a195c0e4b429bb6ba6f8df9e04a8
MD5 5bfe1d4895bb4db63a88b5aff7831a23
BLAKE2b-256 a21c1bc0009b5b57440038320699548e70f055be464e34d8acbe3f9a7151d602

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page