You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The results are pretty amazing. I would love to convert the model to onnx for further development.
Here are the steps that I have done:
I loaded the model
Active the inference-mode: model = network(num_classes=num_classes, pretrained=None) model = nn.DataParallel(model) state_dict = torch.load(args.restore_weight,map_location=torch.device('cpu')) model.load_state_dict(state_dict) model.train(False)
Set size for input: x = torch.randn(batch_size, 3, 512, 512, requires_grad=True)
Export to onnx: torch.onnx.export( model.module, # model being run x, 'schp.onnx', export_params=True, # store the trained parameter weights inside the model file opset_version=11, # the ONNX version to export the model to do_constant_folding=True, # whether to execute constant folding for optimization input_names=['input'], # the model's input names output_names=['output'], # the model's output names dynamic_axes={'input': {0: 'batch_size'}, # variable lenght axes 'output': {0: 'batch_size'},}, verbose=False)
Dear @PeikeLi,
The results are pretty amazing. I would love to convert the model to onnx for further development.
Here are the steps that I have done:
I loaded the model
Active the inference-mode:
model = network(num_classes=num_classes, pretrained=None) model = nn.DataParallel(model) state_dict = torch.load(args.restore_weight,map_location=torch.device('cpu')) model.load_state_dict(state_dict) model.train(False)
Set size for input:
x = torch.randn(batch_size, 3, 512, 512, requires_grad=True)
Export to onnx:
torch.onnx.export( model.module, # model being run x, 'schp.onnx', export_params=True, # store the trained parameter weights inside the model file opset_version=11, # the ONNX version to export the model to do_constant_folding=True, # whether to execute constant folding for optimization input_names=['input'], # the model's input names output_names=['output'], # the model's output names dynamic_axes={'input': {0: 'batch_size'}, # variable lenght axes 'output': {0: 'batch_size'},}, verbose=False)
However, I am getting the error like this:
Here is the full error message:
pytorch_onnx_error.pdf
I would like to ask if you or anyone have done any of this before, if so Can you please share me the code that you make it work?
Thank you in advance!
Vy
The text was updated successfully, but these errors were encountered: