Welcome to our Support Center

Convert Pytorch To ONNX

Description

This VI uses a Python-based export pipeline to convert a PyTorch model saved as .pt (TorchScript) into a .onnx file. Input shapes and ranks must be provided to define the tracing inputs. The generated ONNX model can be optionally opened in Netron.

Input parameters

 

 Open Netron : boolean, indicating whether to automatically open the resulting ONNX file in Netron after conversion. If true opens in Netron else conversion only.

 Conversion Parameters : cluster,

 ONNX Model Path : pathpath where the ONNX file will be saved.
 Pytorch Model Path : pathpath to the source PyTorch model file (TorchScript format).
Shapes : array, a flattened 1D array representing all input tensor shapes, concatenated. Each shape must be fully specified (e.g., [1, 3, 224, 224, 1, 10]).
Ranks : array, specifying the rank (number of dimensions) of each input tensor. This array is used to split the flat Shapes array into individual shapes for each input.

 

 

Output parameters

 

 standard output : string, text output from the underlying Python process. Can include logs, conversion info, or warnings.
 standard error : string, text output capturing any error messages from the Python process, useful for debugging failed conversions.

 

Example

All these exemples are snippets PNG, you can drop these Snippet onto the block diagram and get the depicted code added to your VI (Do not forget to install Deep Learning library to run it).
Table of Contents