Onnx to mlmodel conversion fails to generate .mlmodel file

I’m trying to convert Pytorch model to MLModel with Onnx.

My code:

import torch
from onnx_coreml import convert
import coremltools

net = BiSeNet(19)
net.cuda()
net.load_state_dict(torch.load('model.pth'))

dummy = torch.rand(1,3,512,512).cuda()

torch.onnx.export(net, dummy, "Model.onnx", input_names=["image"], output_names=["output"], opset_version=11)

finalModel = convert(model='Model.onnx', minimum_ios_deployment_target='12')
finalModel.save('ModelML.mlmodel')

After the code runs Model.onnx is generated, however, .mlmodel file is not generated. There’re no errors in the console.

What could be the issue?

Did you verify that the generated ONNX model is running fine?
If that’s the case, it seems that onnx_coreml fails to store it properly, so I would recommend to create an issue here.

How can I verify ONNX model? This is my model.

You could run it with e.g. onnxruntime as described here.