Skip to content

Latest commit

 

History

History
41 lines (21 loc) · 1.04 KB

Pytorch_Instructionss.md

File metadata and controls

41 lines (21 loc) · 1.04 KB

Pytorch will be run in a slightly different manner due to posibilities of using pretrained models whose architecture is not saved in any specific files and need to be imported.

The steps to follow to convert a Pytorch model are the following:

  1. Open a terminal in the nnvmt directory

  2. Execute python

python

  1. Import model

import NN_Model or from XXXX import NN_Model

  1. Load model

torch_model = NN_Model(*args)

  1. Run Pytorch to ONNX parser file

exec(open(r'src\TheseNeedReformulating\PytorchToONNX.py').read())

  1. Convert the model

PytorchPrinterCNN(WeightsFile, OutputFilePath, torch_model, input_size, batch_size = 1 ,inname = ['inputs'], outname = ['outputs'])

Notes

- WeightsFile = 'xxxx.pth'

- OutFilePath = '.../model.onnx'

- torch_model = torch_model

- input_size = [channels, height, width]

- batch_size = optional argument, set to 1 as default

- inname = name of inputs (optional), set to ['inputs'] as default value

- outname = name of outputs (optional), set to ['outputs'] as default value