onnx / tutorials

Tutorials for creating and using ONNX models
Apache License 2.0
3.37k stars 629 forks source link

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

Open Seanbakko opened 5 years ago

Seanbakko commented 5 years ago

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!

anujdutt9 commented 5 years ago

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.