Welcome to our Support Center

Convert ONNX To Pytorch

Description

This VI exports an ONNX model into the PyTorch .pt format using a Python-based toolchain. Because TorchScript requires explicit input shapes for tracing, the user must provide input shapes and their corresponding ranks. Optionally, the ONNX model can be opened in Netron after conversion.

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 to the .onnx file to convert. Must contain a valid and traceable ONNX graph.
 Pytorch Model Path : pathpath to the .pt file where the TorchScript model will be saved.
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