|
1 | 1 | # Importing ONNX Models in Burn
|
2 | 2 |
|
3 |
| -## Table of Contents |
4 |
| - |
5 |
| -1. [Introduction](#introduction) |
6 |
| -2. [Why Import Models?](#why-import-models) |
7 |
| -3. [Understanding ONNX](#understanding-onnx) |
8 |
| -4. [Burn's ONNX Support](#burns-onnx-support) |
9 |
| -5. [ONNX Compatibility](#onnx-compatibility) |
10 |
| -6. [Step-by-Step Guide](#step-by-step-guide) |
11 |
| -7. [Advanced Configuration](#advanced-configuration) |
12 |
| -8. [Loading and Using Models](#loading-and-using-models) |
13 |
| -9. [Troubleshooting](#troubleshooting) |
14 |
| -10. [Examples and Resources](#examples-and-resources) |
15 |
| -11. [Conclusion](#conclusion) |
16 |
| - |
17 | 3 | ## Introduction
|
18 | 4 |
|
19 | 5 | As deep learning evolves, interoperability between frameworks becomes crucial. Burn, a modern deep
|
@@ -68,19 +54,27 @@ version, you'll need to upgrade it using the ONNX version converter.
|
68 | 54 |
|
69 | 55 | ### Upgrading ONNX Models
|
70 | 56 |
|
71 |
| -You can upgrade your ONNX models with this simple Python script: |
| 57 | +There are two simple ways to upgrade your ONNX models to the required opset version: |
| 58 | + |
| 59 | +Option 1: Use the provided utility script: |
| 60 | + |
| 61 | +``` |
| 62 | +uv run --script https://raw.githubusercontent.com/tracel-ai/burn/refs/heads/main/crates/burn-import/onnx-opset-upgrade.py |
| 63 | +``` |
| 64 | + |
| 65 | +Option 2: Use a custom Python script: |
72 | 66 |
|
73 | 67 | ```python
|
74 | 68 | import onnx
|
75 | 69 | from onnx import version_converter
|
76 | 70 |
|
77 |
| -# Load your ONNX model |
| 71 | +# Load the ONNX model |
78 | 72 | model = onnx.load('path/to/your/model.onnx')
|
79 | 73 |
|
80 |
| -# Convert the model to opset version 16 |
| 74 | +# Upgrade to opset version 16 |
81 | 75 | converted_model = version_converter.convert_version(model, 16)
|
82 | 76 |
|
83 |
| -# Save the converted model |
| 77 | +# Save the upgraded model |
84 | 78 | onnx.save(converted_model, 'upgraded_model.onnx')
|
85 | 79 | ```
|
86 | 80 |
|
|
0 commit comments