There is no native solution and some people are currently working on it : https://github.com/ENOT-AutoDL/onnx2torch
Also to be clear, a .pth
checkpoint , usually only contains the parameters such as weights, biases... not the operations like conv2d
, batchnorm2d
, pooling
. An onnx model, in another hand, contains both operations and parameters that's why you can infer them. If, from an onnx, you only need the weights & biases in order to load a state into a torch model already implemented, it might be quite easy, if you want to automatically build a torch model from an onnx, that's the hard part.