I have one pre-trained model into format of .pth extension. I want to convert that into Tensorflow protobuf. But I am not finding any way to do that. I have seen onnx can convert models from pytorch into onnx and then from onnx to Tensorflow. But with that approach I got following error in the first stage of conversion.
from torch.autograd import Variable
import torch.onnx
import torchvision
import torch
dummy_input = Variable(torch.randn(1, 3, 256, 256))
model = torch.load('./my_model.pth')
torch.onnx.export(model, dummy_input, "moment-in-time.onnx")`
It gives error like this.
File "t.py", line 9, in <module>
torch.onnx.export(model, dummy_input, "moment-in-time.onnx")
File "/usr/local/lib/python3.5/dist-packages/torch/onnx/__init__.py", line 75, in export
_export(model, args, f, export_params, verbose, training)
File "/usr/local/lib/python3.5/dist-packages/torch/onnx/__init__.py", line 108, in _export
orig_state_dict_keys = model.state_dict().keys()
AttributeError: 'dict' object has no attribute 'state_dict'
What is possible solution ?