PyTorch Cross-platform Development (Android & iOS)

Hi everyone !
I’m planning to do an app that will be using a PyTorch model. I would like this app to be compatible with both Android and iOS (like a React Native app).
What are the best solutions to do that (considering the use of a PyTorch model) ?

Up! Is there any way to do a React Native App with a working PyTorch model inside ?

I have not used PyTorch with React Native, but what you can do is to write your model using PyTorch, adapt it to ONNX (for Android) and CoreML (for iOS). You can export to ONNX directly from PyTorch, and you can convert from ONNX to CoreML using https://github.com/onnx/onnx-coreml .

1 Like

And so you think that if I’m detecting the OS inside the React Native app and then I use the proper model (ONNX for Android, CoreML for iOS) it could potentially work ?

I would presume so, yes. I have managed to get a TensorFlow model working on Android / iOS using a very similar approach. I have to imagine it would have been possible with PyTorch as well. I do need to stress that I am not not up-to-date with PyTorch and mobile devices, so it is entirely possible that there exists an easier approach. I encourage you to do further research on your own just to be sure. However, checking the ONNX repository, this example should get you started: https://github.com/onnx/tutorials/blob/master/tutorials/PytorchCaffe2MobileSqueezeNet.ipynb

Okay, thank you very much!