Skip to main content

onnxdumper

这是一个用于 ONNX 推理会话的 Python 包,通过额外创建一个 ONNX 推理会话加载修改了输出接口的 ONNX 模型,以便在导出 ONNX 推理中间层的输出。

安装

pip install onnxdumper

使用

import onnxruntime
import onnxdumper

# 将 onnxruntime.InferenceSession 替换为 onnxdumper.InferenceSession 即可
# session = onnxdumper.InferenceSession("path/to/your/model.onnx")
session = onnxdumper.InferenceSession("path/to/your/model.onnx")

# 准备输入数据
input_feed = {
    "input_name": input_data
}

# 运行推理并导出中间层输出
output_names = ["output_name"]
results = session.run(output_names, input_feed, dump_path="path/to/save/outputs")

导出格式

导出格式为 npz,使用 numpy 进行加载,data 的 key 为输出节点的名称,value 为输出节点的数据。

import numpy as np
data = np.load("path/to/save/outputs.npz")
for key in data.keys():
    print(key, data[key], data[key].shape, data[key].dtype)

节点输出的key查看方式

1. 使用 onnx 加载模型查看

model = onnx.load(path_or_bytes)
for node in model.graph.node:
    print(node.output)

2. 使用 netron 查看

License

MIT

Metadata

Release files for onnxdumper 0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for onnxdumper 0.7
File Size Uploaded Provenance
onnxdumper-0.7.tar.gz 2.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for onnxdumper 0.7
File Interpreter ABI Platform
onnxdumper-0.7-py3-none-any.whl Python 3 none any Details

Total release size: 5.6 kB

Release files / onnxdumper-0.7.tar.gz

Download URL onnxdumper-0.7.tar.gz
Size 2.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7bd8511ec374e713a295b5eaa36e92fc3705e20d43b5540836e5ed273b4dbc91
BLAKE2b-256 checksum
How to use checksums
e2058493fb9a84cff6621c95dab3eaeb159a39c8fe7134df3a214d1d0e63508d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release files / onnxdumper-0.7-py3-none-any.whl

Download URL onnxdumper-0.7-py3-none-any.whl
Size 2.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
953ed271ebda09426703a09773bfbf5079209b34e4c92c8fa5d57ef39eafdc36
BLAKE2b-256 checksum
How to use checksums
d0af1ba868b60cdaccc19d85e61956dea9c1e54d0954304d9e04fac1c4ee7ffb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Security for onnxdumper 0.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page