Hi there
Cannot use the following code
from torch.autograd import Variable
import torch.onnx
import torch
dummy_input = Variable(torch.randn(1, 3, 256, 256))
model = torch.load(‘Paramecium.pth’, map_location=torch.device(‘cpu’))
torch.onnx.export(model, dummy_input, “fromTorch.onnx”)
to convert the pth to onnx. It throws the ‘collections.OrderedDict’ object has no attribute ‘state_dict’ at the last line execution.
The way I create the .pth file is following (Colab):
from detecto import core, utils, visualize
dataset = core.Dataset(’/content/drive/My Drive/Paramecium’)
model = core.Model([‘Paramecium’, ‘Noise’])
model.fit(dataset)
model.save(‘Paramecium.pth’)
The model looks good, works and can be visualized with visualize.show_labeled_image
How come it throws the error when converting to ONNX?
Thanks.