Skip to content

How to export onnx model ? RuntimeError: ONNX export failed: Couldn't export Python operator ModulatedDeformConvFunction #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
zccyman opened this issue Mar 24, 2020 · 3 comments

Comments

@zccyman
Copy link

zccyman commented Mar 24, 2020

def transformModel2onnx(model_file, inference_file, tensor_size):
    model = torch.load(model_file)
    model = model.cuda()
    
    dummy_input = Variable(torch.randn(tensor_size)).cuda()
    
   #pytorch2onnx
    torch.onnx.export(model, dummy_input, inference_file,
              export_params=True, verbose=True, training=False)

if __name__ == "__main__":
    tensor_size = [1, 7, 3, 64, 128]
    transformModel2onnx(model_file, inference_file, tensor_size)

RuntimeError: ONNX export failed: Couldn't export Python operator ModulatedDeformConvFunction

@shaominghe
Copy link

hi ,what has this problem been solved

@xinntao
Copy link
Collaborator

xinntao commented Jul 8, 2020

Not familiar with ONNX, you may google it ~

@xinntao xinntao closed this as completed Jul 8, 2020
@Jeck-Liu-Create
Copy link

In order to solve this runtimeerror: onnx export failed: couldn't export python operator modulateddeformconvfunctio problem, you need to make the following adjustments; add the following code to ModulatedDeformConvFunction in dcn/functions/deform_conv.py:

@staticmethod
def symbolic(g, input, offset, mask, weight, bias, stride, padding,
                dilation, groups, deform_groups):
    input_tensors = [input, offset, mask, weight]
    if bias is not None:
        input_tensors.append(bias)
    return g.op(
        'mmcv::MMCVModulatedDeformConv2d',
        *input_tensors,
        stride_i=stride,
        padding_i=padding,
        dilation_i=dilation,
        groups_i=groups,
        deform_groups_i=deform_groups)

The solution comes from: https://zhuanlan.zhihu.com/p/684415514

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants