Error converting PyTorch scripted model to ONNX

I’m trying to convert a Pytorch model to ONNX using this code:

import onnx
import torch
import onnxruntime
import numpy as np

device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")


batch_size = 1
model = torch.jit.load('../saved_weights/autotissue_mobilenetv3_lrassp.pt')

x = torch.randn(1, 3, 224, 224, requires_grad=True)
x = x.to(device)
torch_out = model(x)
torch_out = torch_out['out']


torch.onnx.export(model, x, "../saved_weights/autotissue_mobilenetV3.onnx",
              export_params=True,
              opset_version=12,
              do_constant_folding=True,
              input_names=['input'],
              output_names=['out'],
              dynamic_axes={ 'input': {0 : 'batch_size'},
                            'output': {0 : 'batch_size'}})

However I’m getting the following error:

raise errors.UnsupportedOperatorError(
 torch.onnx.errors.UnsupportedOperatorError: Exporting the operator 
 'aten::dict' to ONNX opset version 12 is not supported. 

Is this due to:

  1. The fact that model was saved as a scripted model?
  2. The torchvision model outputs an OrderedDict ?