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 本身不依赖其他组件,但是我们建议您在以下环境下使用 Paddle2ONNX :

  • PaddlePaddle == 2.6.0
  • onnxruntime >= 1.10.0

3 安装 Paddle2ONNX

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

pip install paddle2onnx

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

4 快速使用教程

4.1 获取PaddlePaddle部署模型

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

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

4.2 调整Paddle模型

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

4.3 使用命令行转换 PaddlePaddle 模型

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

paddle2onnx --model_dir model_dir \
            --model_filename inference.pdmodel \
            --params_filename inference.pdiparams \
            --save_file model.onnx

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

参数 参数说明
--model_dir 配置包含 Paddle 模型的目录路径
--model_filename [可选] 配置位于 --model_dir 下存储网络结构的文件名
--params_filename [可选] 配置位于 --model_dir 下存储模型参数的文件名称
--save_file 指定转换后的模型保存目录路径
--opset_version [可选] 配置转换为 ONNX 的 OpSet 版本,目前支持 7~16 等多个版本,默认为 9
--enable_onnx_checker [可选] 配置是否检查导出为 ONNX 模型的正确性, 建议打开此开关, 默认为 True
--enable_auto_update_opset [可选] 是否开启 opset version 自动升级功能,当低版本 opset 无法转换时,自动选择更高版本的 opset进行转换, 默认为 True
--deploy_backend [可选] 量化模型部署的推理引擎,支持 onnxruntime/rknn/tensorrt, 默认为 onnxruntime
--save_calibration_file [可选] TensorRT 8.X版本部署量化模型需要读取的 cache 文件的保存路径,默认为 calibration.cache
--version [可选] 查看 paddle2onnx 版本
--external_filename [可选] 当导出的 ONNX 模型大于 2G 时,需要设置 external data 的存储路径,推荐设置为:external_data
--export_fp16_model [可选] 是否将导出的 ONNX 的模型转换为 FP16 格式,并用 ONNXRuntime-GPU 加速推理,默认为 False
--custom_ops [可选] 将 Paddle OP 导出为 ONNX 的 Custom OP,例如:--custom_ops '{"paddle_op":"onnx_op"},默认为 {}

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-1.3.1-cp312-cp312-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.12Windows x86-64

paddle2onnx-1.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

paddle2onnx-1.3.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

paddle2onnx-1.3.1-cp312-cp312-macosx_12_0_universal2.whl (2.7 MB view details)

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

paddle2onnx-1.3.1-cp311-cp311-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.11Windows x86-64

paddle2onnx-1.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

paddle2onnx-1.3.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

paddle2onnx-1.3.1-cp311-cp311-macosx_12_0_universal2.whl (2.7 MB view details)

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

paddle2onnx-1.3.1-cp310-cp310-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.10Windows x86-64

paddle2onnx-1.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

paddle2onnx-1.3.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

paddle2onnx-1.3.1-cp310-cp310-macosx_12_0_universal2.whl (2.7 MB view details)

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

paddle2onnx-1.3.1-cp39-cp39-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.9Windows x86-64

paddle2onnx-1.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

paddle2onnx-1.3.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.4 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

paddle2onnx-1.3.1-cp39-cp39-macosx_12_0_universal2.whl (2.7 MB view details)

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

paddle2onnx-1.3.1-cp38-cp38-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.8Windows x86-64

paddle2onnx-1.3.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

paddle2onnx-1.3.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.4 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

paddle2onnx-1.3.1-cp38-cp38-macosx_12_0_universal2.whl (2.7 MB view details)

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

File details

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

File metadata

File hashes

Hashes for paddle2onnx-1.3.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0b125615c4a9a27020f398835392d254b9875fae1fb7dac94f9f3872e03a69ca
MD5 8ba7b1521844b9a1b5171afd651305ca
BLAKE2b-256 149ecc2ddb81cce717daa928b5f7ba346c68d8a5e715a38df4a346d3161b55ea

See more details on using hashes here.

File details

Details for the file paddle2onnx-1.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for paddle2onnx-1.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ddae52e3672145f262a1dd64ed109ce5f6952b21df0f9e35018d07db1ff71b2a
MD5 bb0ee631cc1a9de70e983e0481ad1a37
BLAKE2b-256 0d87b537277a84c696bfc29c9c296db4fcfd0c0e8055a30ba2b1aea55cb3b8b2

See more details on using hashes here.

File details

Details for the file paddle2onnx-1.3.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for paddle2onnx-1.3.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7f1b2eb9ba64340d6c1a305fb79ae29f608992e411b9bdeff589994d4c31a44f
MD5 88d3d34e3e717b87868e193cd89b20af
BLAKE2b-256 b33d9407cc4752c6c370490fd0281610c5954e97666323d4678019bb48c8b235

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for paddle2onnx-1.3.1-cp312-cp312-macosx_12_0_universal2.whl
Algorithm Hash digest
SHA256 a79dd16d0fe29ac9a434b925660f65dd5893adde9db3527ce41850e72c428ea3
MD5 e6d8f6398360a37d8233d9c81ce63064
BLAKE2b-256 1444b984fd6ab4b7adfc7ced1c30aa6b84f297235ae5ea0024739fbd01dcbfa2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for paddle2onnx-1.3.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f3ae071d64f1d90aebf25a540d7609517f93fc6f0ad6c5f4a1bdc2bc5c26fc6d
MD5 99e224293ee6996bd5094f8e8867cfe2
BLAKE2b-256 bbb75c65ee9161fd0f818dd832e3d9860c0be3585a8bcb2bc006f894afe29cc7

See more details on using hashes here.

File details

Details for the file paddle2onnx-1.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for paddle2onnx-1.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 438abb3117a045386fbeee4f3bfdcb4dcf4ff50975490be899def17d9a697e87
MD5 938d9af2dbcebdb92ac47a2860a6e652
BLAKE2b-256 3c748a39614f7ce9a5a0326c3646fc90c0cfc1020ed289db3b585107086bd0f8

See more details on using hashes here.

File details

Details for the file paddle2onnx-1.3.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for paddle2onnx-1.3.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3d222c3862ec010687c0e1179a547233f3caa36bde93dec189453aa184a319d6
MD5 eb5087349d03b8bbcf7751a5254efeff
BLAKE2b-256 b8eb370c67f3b197bb294d87579839c758b436d83c2a12b5d2bcdcd892d5541d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for paddle2onnx-1.3.1-cp311-cp311-macosx_12_0_universal2.whl
Algorithm Hash digest
SHA256 e7b60c963de241fd493fd57dbfd64f6cde633c5c043fd3bc0d8733d36a4410b0
MD5 529c76cf2789833c0ae0b00c942c2fc3
BLAKE2b-256 e51f4246ce4ddcd0b07217ccc165cd5a685f9eae2a36bb8195151334179888ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for paddle2onnx-1.3.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e84f67078acd5f5742c37ac69527996daf6bee721b71280768e2dbda909570d4
MD5 815818c06cfd3195edff65597d8683a3
BLAKE2b-256 28e93a21ab92c59f859da05f31a4d7fbf41c15399ce8fd43ac3c776499640ec8

See more details on using hashes here.

File details

Details for the file paddle2onnx-1.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for paddle2onnx-1.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 26cbefbdd8b041065db01ba93e4a14e0b089c7cb5307df7bc4fb9f8e932ca57a
MD5 307cf64e26d12a62502161e59630b2ba
BLAKE2b-256 468e16be8f3061868adedbcc28185c3dd5b4f72463ddddefe0e92d08b15c897e

See more details on using hashes here.

File details

Details for the file paddle2onnx-1.3.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for paddle2onnx-1.3.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4d27d2b673d999a13678f6d79aa600c116823a33761261daa9eaa8566ad9be63
MD5 3d6362ad264c16753adcc1c08208f55d
BLAKE2b-256 c06d770e0580e21f4f77961483e3cd2c73ded5030cc9c851ff40c082c0ac2eb0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for paddle2onnx-1.3.1-cp310-cp310-macosx_12_0_universal2.whl
Algorithm Hash digest
SHA256 0756da3c211825e0e5f8a1623925aa4db40a85d173df16a83491d37ac019f6bb
MD5 5335c42ce2a8f5dac1fadabee9af5ab5
BLAKE2b-256 34bccbecdcae3a2230115804663d9cb820e054f1aa85b09b1fdfae275d1c7be3

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for paddle2onnx-1.3.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 d62c957cc905910642e261e1a37dfe6bce21add77f0b525c8866d17f6a5039ad
MD5 f6acbcf14cf169a4f9d15e3d6d357d10
BLAKE2b-256 b65b7918904bab2b9d92d19b4828f416527fc87b898c7ae4d4472ae44db0d22d

See more details on using hashes here.

File details

Details for the file paddle2onnx-1.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for paddle2onnx-1.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 adf4c2f101ca0f981496bbe83e484cfb23a5575daf4a0cff4c221e4a218afc28
MD5 88e31129ac1a700265313273c10e53fa
BLAKE2b-256 a27b3003f9627a57fa60265e80cb310299c8774919fcad21854d3f18ceeb4837

See more details on using hashes here.

File details

Details for the file paddle2onnx-1.3.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for paddle2onnx-1.3.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 14854287d0e7627774d5735a3cf1868e7230832884056bfe932b23e3e7d0f341
MD5 f7be3957482eaf401873107deb12f79f
BLAKE2b-256 628a8520c078224f7c2a29f85f8b7b48bdd84b5dcffcc4fddb22e7cddc5bb3ab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for paddle2onnx-1.3.1-cp39-cp39-macosx_12_0_universal2.whl
Algorithm Hash digest
SHA256 c79385a5e8e375c87f303c7fc69d6b35e387c28b2dc19492c37746eafd528da7
MD5 6e823ca999eee4d1b6db0a880526b25b
BLAKE2b-256 a3e7b71dc70aca7c51aa0384ad2a74fe86f4ea3ce8c886c8a36748495c590ff9

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for paddle2onnx-1.3.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 5535f9a7c4b1c93bdb117ab586b0239b2b857ff471ae9f2dae0343c0e6603508
MD5 eba35c6844b6b04ebb0e7439ace09158
BLAKE2b-256 ff2d274c1c53a903b6771350ee8978277eb8b0fa7bce5dd5d4947bc5d3547bba

See more details on using hashes here.

File details

Details for the file paddle2onnx-1.3.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for paddle2onnx-1.3.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5581df36b80eaed927fd01abc82eb91aee0ed3a6a20cf7c29e5f90f26bb76cdd
MD5 f7607863bed38bcc6c856b30ff46e1f6
BLAKE2b-256 fd009c0088045d1a395bbeba9aa0ef9833cf66e20f8c59042be12e83f190bcc3

See more details on using hashes here.

File details

Details for the file paddle2onnx-1.3.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for paddle2onnx-1.3.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7aef436ebfc1cac63c363fde4dc05330c3f5fbaf3ababaf840400244e8986698
MD5 18094c1f485447887216a02bcce19955
BLAKE2b-256 ca6968d93a959454650ae2f103aa59845acf415a45b2376f865e9a7d67673848

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for paddle2onnx-1.3.1-cp38-cp38-macosx_12_0_universal2.whl
Algorithm Hash digest
SHA256 1584414cd24b2ca5b06cad25a99550717a5134a7a95ff7ed059c0f939fa92ac3
MD5 6ec5ebedbd87a6f42981d3393eb747e3
BLAKE2b-256 fa033b101a832ac5c9c3a2527f89e1cef150d4612768172cbe5d07cf95cbda63

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