https://github.com/justinchuby/model-explorer-onnx
Visualize ONNX models with model-explorer
https://github.com/justinchuby/model-explorer-onnx
deep-learning onnx visualization
Last synced: 6 months ago
JSON representation
Visualize ONNX models with model-explorer
- Host: GitHub
- URL: https://github.com/justinchuby/model-explorer-onnx
- Owner: justinchuby
- License: mit
- Created: 2024-05-17T15:11:46.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-07T00:35:51.000Z (over 1 year ago)
- Last Synced: 2025-04-10T04:54:38.441Z (about 1 year ago)
- Topics: deep-learning, onnx, visualization
- Language: Python
- Homepage: https://pypi.org/project/model-explorer-onnx/
- Size: 359 KB
- Stars: 30
- Watchers: 1
- Forks: 5
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Model Explorer ONNX Adapter
[](https://pypi.org/project/model-explorer-onnx) [](https://pypi.org/project/model-explorer-onnx) [](https://github.com/astral-sh/ruff)
ONNX Adapter for [google-ai-edge/model-explorer](https://github.com/google-ai-edge/model-explorer)
## 🌟 Use it on HuggingFace Spaces
https://huggingface.co/spaces/justinchuby/model-explorer
## Installation
```bash
pip install --upgrade model-explorer-onnx
```
## Usage
```bash
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](https://github.com/google-ai-edge/model-explorer/wiki/2.-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](./themes)
## Visualizing PyTorch ONNX exporter (`dynamo=True`) accuracy results
> [!NOTE]
> `verify_onnx_program` requires PyTorch 2.7 or newer
```py
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:
```sh
onnxvis model.onnx --node_data_paths=model_max_abs_diff.json,model_max_rel_diff.json
```

## Screenshots




