onnx_exporter
sleap_nn.export.exporters.onnx_exporter
¶
ONNX export utilities.
Functions:
| Name | Description |
|---|---|
export_to_onnx |
Export a PyTorch model to ONNX. |
export_to_onnx(model, save_path, input_shape=(1, 1, 512, 512), input_dtype=torch.uint8, opset_version=17, dynamic_axes=None, input_names=None, output_names=None, do_constant_folding=True, verify=True, numerical_check=False, numerical_atol=0.001, numerical_rtol=0.001)
¶
Export a PyTorch model to ONNX.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Module
|
The PyTorch module to export. |
required |
save_path
|
str | Path
|
Destination path for the |
required |
input_shape
|
Iterable[int]
|
Shape of the dummy input used to trace the graph. |
(1, 1, 512, 512)
|
input_dtype
|
dtype
|
Dtype of the dummy input ( |
uint8
|
opset_version
|
int
|
ONNX opset for the (default) TorchScript exporter. |
17
|
dynamic_axes
|
Optional[Dict[str, Dict[int, str]]]
|
Dynamic-axis spec; defaults to batch/height/width dynamic on
the |
None
|
input_names
|
Optional[List[str]]
|
ONNX input names; defaults to |
None
|
output_names
|
Optional[List[str]]
|
ONNX output names; inferred from a reference forward if
|
None
|
do_constant_folding
|
bool
|
Whether to constant-fold during export. |
True
|
verify
|
bool
|
If |
True
|
numerical_check
|
bool
|
If |
False
|
numerical_atol
|
float
|
Absolute tolerance for the numerical parity check. |
0.001
|
numerical_rtol
|
float
|
Relative tolerance for the numerical parity check. |
0.001
|
Source code in sleap_nn/export/exporters/onnx_exporter.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |