tutorials icon indicating copy to clipboard operation
tutorials copied to clipboard

If I want to convert a PyTorch model to CoreMl what is the first thing I should do?

Open Seanbakko opened this issue 7 years ago • 1 comments

I am new to this and not sure exactly what the first step from the PyTorch model would be to convert to CorelMl? Any help would be awesome.

Thanks and Merry Christmas!

Seanbakko avatar Dec 25 '18 17:12 Seanbakko

Hi @Seanbakko. The best path currently would be to save your PyTorch model in ONNX format. For that you can make use of PyTorch's built-in API "torch.onnx.export(model, dummy_input, "model.onnx")". Once you are done with this, you can then use ONNX-CoreML framework to convert your ONNX model to CoreML model using "onnx_coreml.convert" API. You can take a look at these for an example: https://github.com/onnx/tutorials/tree/master/examples/CoreML/ONNXLive https://medium.com/@alexiscreuzot/building-a-neural-style-transfer-app-on-ios-with-pytorch-and-coreml-76e00cd14b28 Hope this helps.

anujdutt9 avatar Jan 22 '19 16:01 anujdutt9