Fast AI Library for iOS

Is it possible to use the Fast AI library for an iOS app? If not, are there any resources I could use to make an image classifier for mobile?

Thanks!

You can write your model in pytorch and export it to CoreML (which is Apple’s Machine Learning framework which only supports iOS 11). This might get you started: http://pytorch.org/docs/0.3.0/onnx.html

2 Likes

Thanks! So I would not be using the fastai library but rather pytorch?

Yes.
Here is an official demo app by Apple which might come in handy :grinning:
https://developer.apple.com/documentation/vision/classifying_images_with_vision_and_core_ml

2 Likes

Understood! Thanks a lot for the reference, Nishant :slight_smile:

Vikas
Showbox Tutuapp

fastai is mainly for training, not inference. Once you’ve trained, you’ve got a fairly standard pytorch model, which you can export to onnx / coreml.

6 Likes

I’m curious; I’ve managed to train an adapted Tiramisu (https://github.com/bfortuner/pytorch_tiramisu) for my data, and it seems to be working quite well. But I’d like to get it over to coreml, to try it in a real-world context. I converted to ONNX successfully (afaik), but onnx-coreml fails on: “TypeError: Error while converting op of type: Slice. Error message: Only single axis Slice is supported now”. I’ve opened an issue, but no responses, so far (it sounds like it’s on the roadmap, but no idea when). Do you know of any workarounds?

It appears to me that its just a porting issue.

You can try training in Tensorflow. You can also use ONNX model to get a tensorflow model. Then apply tf-coreml to get a core-ml model.

I am not aware if Slice is limited to single axis Slice in core-ml. But I am sure that core-ml 2.0 coming this fall, will be supporting all kind of slicing.

You can also get port your model to Keras/Caffe. Then you can use coremltools to get it run on iOS

Okay, thanks. Yes, I saw the keras version, so I’m going to give that a try with my data.

Hi,

I also tried to export fast.ai model to iOS. Then I’ve written a tutorial for it. Check it out here

3 Likes