Skip to main content

Adapter for ai-edge-model-explorer to support ONNX models

Project description

Model Explorer ONNX Adapter

PyPI - Version PyPI - Downloads Ruff

ONNX Adapter for google-ai-edge/model-explorer

🌟 Use it on HuggingFace Spaces

https://huggingface.co/spaces/justinchuby/model-explorer

Installation

pip install --upgrade model-explorer-onnx

Usage

model-explorer --extensions=model_explorer_onnx

# Or as a shortcut
onnxvis

# Supply model path
onnxvis model.onnx

[!NOTE] Model Explorer only supports WSL on Windows.

Read more on the Model Explorer User Guide.

Notes on representation

Graph input/output/initializers in ONNX are values (edges), not nodes. A node is displayed here for visualization. Graph inputs that are initialized by initializers are displayed as InitializedInput, and are displayed closer to nodes that use them.

Nodes that implicitly capture values for their sub-graphs (Loop, Scan, etc.) will have an additional (Capture) node as input that connects all of the implicitly captured values with itself. As a special case, the subgraphs of an If node are flattened. The outputs of the two branches of an If node will be gathered by a (Phi) node to show connectivity. This modification in the graph ensures that all value dependencies are shown in the visualization.

Color Themes

Get node color themes here

Visualizing PyTorch ONNX exporter (dynamo=True) accuracy results

[!NOTE] verify_onnx_program requires PyTorch 2.7 or newer

import torch
from torch.onnx.verification import verify_onnx_program

from model_explorer_onnx.torch_utils import save_node_data_from_verification_info

# Export the and save model
onnx_program = torch.onnx.export(model, args, dynamo=True)
onnx_program.save("model.onnx")

verification_infos = verify_onnx_program(onnx_program, compare_intermediates=True)

# Produce node data for Model Explorer for visualization
save_node_data_from_verification_info(
    verification_infos, onnx_program.model, model_name="model"
)

You can then use Model Explorer to visualize the results by loading the generated node data files:

onnxvis model.onnx --node_data_paths=model_max_abs_diff.json,model_max_rel_diff.json

node_data

Screenshots

image image image image image image

Project details


Download files

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

Source Distribution

model_explorer_onnx-0.4.2.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

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

model_explorer_onnx-0.4.2-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file model_explorer_onnx-0.4.2.tar.gz.

File metadata

  • Download URL: model_explorer_onnx-0.4.2.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for model_explorer_onnx-0.4.2.tar.gz
Algorithm Hash digest
SHA256 eb40d4df8637a81211a1b12f2cac1a8c26d8b9737304b8173efc91e167e8ec19
MD5 15f9578ba233b89abd9b7b47c1fa3218
BLAKE2b-256 3f401a138d3653ae1050ab979b6022b56aa32da6e6b6150a5c758413dba28150

See more details on using hashes here.

Provenance

The following attestation bundles were made for model_explorer_onnx-0.4.2.tar.gz:

Publisher: main.yaml on justinchuby/model-explorer-onnx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file model_explorer_onnx-0.4.2-py3-none-any.whl.

File metadata

File hashes

Hashes for model_explorer_onnx-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cb2da48ca8da37e024a3793bf31c3e08842f871f9ef60e70a24cb7c557dbcdf5
MD5 a37bda63535d3d50cfa0e52fa03820ea
BLAKE2b-256 df0b66fecc462be89bc5e014b2f44935b0f958c2aa02ba66fe0ce1dc32289e6f

See more details on using hashes here.

Provenance

The following attestation bundles were made for model_explorer_onnx-0.4.2-py3-none-any.whl:

Publisher: main.yaml on justinchuby/model-explorer-onnx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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